Backend

This directory contains all server-side code organized by functionality.

Architecture

  • routes/ - HTTP route handlers organized by functionality
  • api/ - JSON API endpoints for frontend/backend communication
  • tasks/ - Webhook handlers for Notion integrations
  • views/ - Server-side rendered views for frontend
  • services/ - External API integrations (pure API calls only)
  • controllers/ - Business logic coordination between routes and services
  • crons/ - Scheduled task handlers
  • types/ - Shared TypeScript type definitions
  • utils/ - Common utility functions

Layer Responsibilities

Services: Single-purpose functions that make direct API calls to external systems. Pure functions that handle HTTP transport layer.

Controllers: Business logic and orchestration between services. Handle environment variables and configuration.

Routes: HTTP request/response handling only. Call controllers, never services directly.