man@mndev:~/portfolio/notes/architecture
← portfolio

A feature-first modular monolith with 30 modules

How I structured a solo SaaS so it stayed easy to change through 18 releases: feature folders, hard boundaries and tests at the seams.

Architecture··1 min read

When I built Simple Todo on my own, I wanted two things that usually pull in opposite directions: ship fast, and don’t drown in my own code by month two. The answer was a modular monolith, organised by feature. It grew to 30 feature modules over 18 production releases.

Why not microservices

One developer, one database, one deploy. Microservices would add network calls, separate deploys and distributed debugging, with none of the team-scaling benefits they exist for. A monolith with strict internal boundaries gives you most of the design benefits at a fraction of the cost.

Feature-first layout

src/features/
  tasks/
    ui/          # React components
    server/      # actions, queries, domain logic
    db/          # schema + repository (Drizzle)
    index.ts     # the ONLY public surface
    tasks.test.ts
  notebook/
  reminders/
  sync/
  ...

Everything about one feature lives together. Deleting or rewriting a feature touches one folder.

Boundaries you can’t accidentally cross

Folders alone don’t hold a boundary. Lint rules do. Other modules may import features/tasks (its index.ts) but never features/tasks/server/internal-thing:

// eslint: no-restricted-imports
patterns: [{ group: ['@/features/*/*'], message: 'Import from the feature index only.' }]

When a feature needs another feature’s data, it goes through that feature’s public functions. That makes dependencies visible in code review.

Security as a cross-cutting rule

In a multi-tenant app, the scariest bug is user A reading user B’s data (IDOR). I didn’t want that to depend on remembering. So:

Tests where they pay off

Around 1,500 automated tests sound like a lot for one person. Most are cheap Vitest tests at module boundaries, plus a Playwright layer for critical user flows. Boundary tests survive refactors inside a module. That’s exactly what lets you keep shipping every few days.