Skip to content

Feature Based Organization

We organize code by feature rather than by technical layer (components, utils, services). This approach scales better and makes changes easier by keeping code scoped to specific features. When working on a feature, you only need to navigate within that feature’s directory instead of searching across the entire codebase.

Features live in src/features/ and contain everything related to that feature: components, state, hooks, actions, and types.

  • Directorysrc/
    • Directoryfeatures/
      • Directoryoutline/
        • Directorygenerate/
          • Directorycomponents/
            • Directorychat/
            • Directoryscreens/
            • Directorysettings/
          • Directoryhooks/
            • use-create-presentation.ts
            • use-character-limit.ts
          • Directorystate/
            • outline-generate-store.ts
            • Directoryactions/
              • chat.ts
              • generate.ts
              • settings.ts
          • config.ts
          • Directoryconstants/

All imports from this feature use the feature path prefix:

import { useOutlineGenerateStore } from '@/features/outline/generate/state/outline-generate-store';
import { ChatScreen } from '@/features/outline/generate/components/screens/chat-screen';
  • Directorysrc/
    • Directoryfeatures/
      • Directorypresentation/
        • Directoryedit/
          • Directorycomponents/
          • Directoryhooks/
          • Directorypage/
            • Directoryassistant/
            • Directoryfloating-bar/
            • Directoryside-bar/
            • Directorytop-bar/
          • Directorystate/
            • editor-store.ts
            • Directoryactions/
              • text.ts
              • shape.ts
              • slide.ts
          • Directoryhelpers/

Backend features are organized as top-level packages in app/. Each feature contains its API routes, business logic, workflows, and related code.

  • Directoryapp/
    • Directorydocument/
      • Directoryingestion/
        • api.py
        • config.py
        • models.py
        • workflow.py
        • validation.py
        • exceptions.py
        • Directorytext/

The router registry automatically discovers api.py files and registers them:

router = APIRouter(prefix="/document/ingestion", tags=["Document, Ingestion"])
registry.register(router)
  • Directoryapp/
    • Directorypresentation/
      • Directorygeneration/
        • api.py
        • core.py
        • Directoryai/
        • Directorylayer/
        • Directoryworkflows/
        • tasks.py
  • Self-contained: Each feature contains everything it needs (components, state, API routes, business logic)
  • Clear boundaries: Features import from each other only when necessary, avoiding circular dependencies
  • Scoped changes: When modifying a feature, you work within its directory, reducing the chance of affecting unrelated code
  • Easy to find: Code location follows feature names, making it intuitive to locate functionality