Skip to content

refactor: split uteke-server monolith (1,840 lines) into modules #514

Closed

Description

@ajianaz

Summary

uteke-server/src/main.rs is a 1,840-line monolith with all HTTP handling in a single file.

Current Structure

Section Lines Content
Setup/Helpers 530 Request/response types, auth middleware, CORS, query parsing
route() function 860 Giant match-based router — ALL endpoint logic inline
main() 382 Server startup, auto-aging loop, config
Config loading 70 File-based TOML config structs

The route() function is the main pain point — 860 lines of path matching with inline business logic for ~30 endpoints.

Proposed Structure

crates/uteke-server/src/
├── main.rs              (~100 lines — startup, config, server loop)
├── router.rs            (~100 lines — route() dispatcher → handler dispatch)
├── handlers/
│   ├── mod.rs
│   ├── memory.rs        (remember, recall, search, list, get, delete, tags)
│   ├── doc.rs           (doc CRUD, breadcrumbs, descendants, move, search)
│   ├── room.rs          (room CRUD, recall)
│   ├── graph.rs         (graph/edges endpoints)
│   ├── maintenance.rs   (consolidate, aging, stats)
│   └── health.rs        (health, version)
├── middleware/
│   ├── mod.rs
│   ├── auth.rs          (check_auth, token validation)
│   └── cors.rs          (preflight headers)
└── types.rs             (request/response structs, ReqCtx, ApiRole)

Priority

🟡 Low-medium — Server is functional as-is. This refactor becomes necessary when adding new endpoints or middleware.

Activity

  1. added a commit that references this issue on Jul 1, 2026
  2. added 2 commits that reference this issue on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions