Skip to content

refactor(serve): split edda-serve/src/lib.rs into sub-modules #375

@fagemx

Description

@fagemx

Problem

edda-serve/src/lib.rs is 8,722 lines with 12 distinct concerns mixed into a single file. It is both the largest file and one of the most frequently changed (churn hotspot), creating merge conflict risk and poor navigability.

Mixed concerns include: auth/pairing, decisions, drafts, events, telemetry, snapshots, analytics, metrics, policy, sync, dashboard/UI, ingestion, SSE streaming.

Proposed Structure

src/
├── lib.rs              (~100 lines: re-exports, serve() entrypoint)
├── error.rs            (~50 lines: AppError enum)
├── state.rs            (~50 lines: AppState, config)
├── middleware.rs        (~100 lines: auth middleware)
├── api/
│   ├── mod.rs          (router setup)
│   ├── decisions.rs    (~350 lines)
│   ├── drafts.rs       (~500 lines)
│   ├── events.rs       (~220 lines)
│   ├── telemetry.rs    (~310 lines)
│   ├── snapshots.rs    (~315 lines)
│   ├── analytics.rs    (~275 lines)
│   ├── metrics.rs      (~335 lines)
│   ├── sync.rs         (~110 lines)
│   ├── briefs.rs       (~405 lines)
│   ├── ingestion.rs    (~280 lines)
│   └── stream.rs       (~120 lines)

Notes

  • No sub-modules currently exist — this would be the first split
  • handle_draft_action (245 lines) is the largest single function
  • Tests (~4,300 lines) should mirror the module split
  • Pure refactor — no behavior change

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode refactoring

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions