How rajat-wyrm/apogee works
1. Repository shape
- This is a monorepo with a Node/Express backend at the root and a React/Vite frontend in apps/web.
- The architecture is clearly split into a server API, a browser client, shared operational scripts, and an extensive integration test suite.
2. Backend entry and request pipeline
- The backend starts from src/index.js, with configuration in src/config, database access in src/db, middleware in src/middleware, and feature routes under src/modules/*/routes.js.
- Incoming HTTP requests flow through middleware first, then into domain modules, then to database/service layers.
- The middleware layer includes authentication, rate limiting, and caching, which are architectural concerns rather than feature code.
3. Domain-driven API layout
- The backend is organized by business capability: auth, organizations, workspaces, projects, tasks, documents, files, analytics, AI, billing, admin, notifications, teams, search, wiki, whiteboards, calendar, goals, automations, exports, webhooks, presence, sharing, and more.
- Each module owns its REST endpoints, which makes the API surface easy to diagram as a set of bounded contexts behind the same Express server.
4. Multi-tenant and access-control boundaries
- The product is multi-tenant: organizations and workspaces are the core isolation units.
- Auth, role-based access control, and tenant-aware database access are central boundaries; most routes are authenticated, and admin routes are explicitly separated.
- The README indicates tenant isolation is enforced at the query layer, so the diagram should show tenancy being validated server-side, not just in the UI.
5. Data layer and migrations
- PostgreSQL is the primary persistent store, accessed through src/db/pool.js.
- Schema evolution is explicit via SQL schema files (schema.sql, schema-phase2.sql, schema-advanced.sql) and migration scripts (scripts/migrate.js, src/db/migrate.js).
- There is also a seed script (scripts/seed.js) that bootstraps demo data, showing the app expects a structured DB setup before the API runs.
6. Service layer and external integrations
- Cross-cutting backend services live in src/services: AI, audit logging, email, files, notifications, cache, and tokens.
- These are where external dependencies matter: AI providers, email delivery, file storage (Cloudinary), billing (Stripe), and notification dispatch are abstracted away from route handlers.
- src/utils/crypto.js and src/utils/http.js support lower-level security and HTTP concerns.
7. Real-time subsystem
- Socket.IO is a separate subsystem under src/sockets, with its own setup and server wiring.
- It appears to power live notifications and presence-style collaboration, complementing the REST API rather than replacing it.
- In a diagram, this is a second inbound channel alongside HTTP, sharing auth/context with the backend but serving push updates.
8. Frontend application structure
- The frontend entry is apps/web/src/main.jsx, with the UI built from pages, features, components, layouts, store, hooks, lib, and theme.
- pages represent route-level screens, features group business domains, and components contain reusable UI primitives and shells.
- This suggests a composition model: page → feature → shared component, rather than a tightly coupled SPA.
9. Client-side state and API access
- apps/web/src/lib/api.js is the primary HTTP client boundary to the backend, and apps/web/src/lib/socket.js is the client connection for real-time events.
- Zustand stores in apps/web/src/store handle auth, organization/workspace context, and theme.
- The frontend therefore has two major outbound dependencies: REST for data mutation/query and Socket.IO for live updates.
10. UI shell and navigation
- The app has a reusable application shell (AppLayout, Layout, Sidebar, Topbar, WorkspaceSwitcher, command palette, drawers, etc.) that wraps the feature pages.
- There are separate auth layouts/screens for login, registration, forgot password, and two-factor flows.
- This is important for the diagram because authenticated product flows and unauthenticated onboarding flows are structurally distinct.
11. Product surface areas on the client
- The frontend mirrors the backend domains: dashboard, projects, tasks, documents, whiteboards, wiki, calendar, notifications, reports, billing, admin, settings, team, search, automations, goals, and helpdesk.
- Many of these are likely feature views backed by the matching API module, so the safest diagram is a one-to-one alignment of client feature areas to backend route modules.
12. Operational and delivery concerns
- Docker is first-class: there are separate Dockerfiles for backend and frontend, plus docker-compose.yml.
- CI is handled through GitHub Actions (.github/workflows/ci.yml), and Jest/Supertest provide integration coverage for the backend contract.
- The frontend also has PWA-oriented setup via Vite config and manifest assets, indicating offline-capable browser behavior is part of the delivery model.
13. Main end-to-end data flow
- A user interacts with the React app, which reads auth/org state from client stores, calls the Express API via lib/api.js, and subscribes to Socket.IO for live events.
- The backend authenticates and authorizes the request, resolves the tenant/workspace context, performs DB operations in PostgreSQL, and may invoke services for files, email, billing, AI, or notifications.
- The result is returned synchronously over HTTP and, when relevant, broadcast asynchronously over sockets.
14. What to emphasize in an architecture diagram
- Show three major zones: browser frontend, Node/Express backend, PostgreSQL data store.
- Add side integrations for Socket.IO, AI providers, Stripe, Cloudinary, and email/notification services.
- Inside the backend, depict middleware, domain modules, and shared services as the main internal boundaries; inside the frontend, depict layouts/shell, page-level features, shared components, and client state/API layers.
Main entry points: modules API modules · index.js API entry · pool.js PostgreSQL · services Services
Components 32
Frontend
React/Vite browser app and its UI composition layers.
- Web entry · Browser app bootstrap and root rendering.
apps/web/src/main.jsx - App shell · Authenticated app layout, navigation, drawers, and command palette.
apps/web/src/layouts/AppLayout.jsx - Auth UI · Login, register, forgot password, and two-factor screens.
apps/web/src/features/auth - Pages · Route-level screens for product areas like dashboard, projects, tasks, and settings.
apps/web/src/pages - Features · Business-domain UI modules aligned to backend capabilities.
apps/web/src/features - Components · Reusable UI primitives and shell components.
apps/web/src/components - State · Client auth, org context, and theme state.
apps/web/src/store - API client · Primary HTTP boundary to the backend.
apps/web/src/lib/api.js - Socket client · Client connection for live events and collaboration signals.
apps/web/src/lib/socket.js
Backend
Express API, domain modules, services, and realtime wiring.
- API entry · Backend bootstrap and HTTP server startup.
src/index.js - Config · Environment and app configuration.
src/config/index.js - Middleware · Shared HTTP concerns such as auth, rate limiting, and cache.
src/middleware/index.js - API modules · Feature bounded contexts exposed as REST routes.
src/modules - Services · Shared service layer for AI, audit, email, files, notifications, cache, and tokens.
src/services - Sockets · Socket.IO setup for live notifications and presence.
src/sockets - Utils · Low-level crypto and HTTP utilities.
src/utils - Auth · Login, registration, two-factor, and token flows.
src/modules/auth/routes.js - Orgs · Organization-level isolation and access boundaries.
src/modules/organizations/routes.js - Workspaces · Workspace context and tenant-scoped routing.
src/modules/workspaces/routes.js - Projects · Project REST endpoints and coordination.
src/modules/projects/routes.js - Tasks · Task management endpoints and workflow.
src/modules/tasks/routes.js - Documents · Document CRUD and editing routes.
src/modules/documents/routes.js - AI · AI-powered backend endpoints and provider integration.
src/modules/ai/routes.js - Billing · Subscription and payment-related routes.
src/modules/billing/routes.js - Admin · Explicit administrative backend surface.
src/modules/admin/routes.js - Notifications · Notification delivery and querying routes.
src/modules/notifications/routes.js
Data
Database schema, migrations, and seeding.
- PostgreSQL · Primary database access layer.
src/db/pool.js - Migrations · SQL schema files and migration runner.
src/db/migrate.js - Seed data · Demo and fixture data bootstrap.
scripts/seed.js
Ops
Build, container, and CI delivery concerns.
- Containers · Backend and frontend container definitions plus compose orchestration.
docker-compose.yml - CI · Continuous integration workflow.
.github/workflows/ci.yml - Integration tests · Backend and end-to-end contract coverage.
tests
Connections 46
- API entry → Config: loads · Bootstraps runtime settings.
- API entry → Middleware: uses · Installs shared request pipeline.
- API entry → API modules: mounts · Registers feature routes.
- API entry → Services: calls · Uses shared services during request handling.
- API entry → Sockets: starts · Wires realtime server alongside HTTP.
- API entry → PostgreSQL: connects · Opens database access.
- Middleware → Auth: protects · Enforces authentication and tenant context.
- Middleware → Admin: gates · Separates privileged admin access.
- API modules → Auth: includes · Auth bounded context.
- API modules → Orgs: includes · Tenant organization context.
- API modules → Workspaces: includes · Workspace isolation context.
- API modules → Projects: includes · Project domain routes.
- API modules → Tasks: includes · Task domain routes.
- API modules → Documents: includes · Document domain routes.
- API modules → AI: includes · AI domain routes.
- API modules → Billing: includes · Billing domain routes.
- API modules → Admin: includes · Admin routes.
- API modules → Notifications: includes · Notification routes.
- Orgs → PostgreSQL: queries · Tenant-aware database access.
- Workspaces → PostgreSQL: queries · Workspace-scoped database access.
- Projects → PostgreSQL: queries · Reads and writes project data.
- Tasks → PostgreSQL: queries · Reads and writes task data.
- Documents → PostgreSQL: queries · Persists documents and related metadata.
- AI → Services: uses · Delegates to AI provider abstraction.
- Billing → Services: uses · Delegates to payment-related service boundary.
- Notifications → Services: uses · Delegates delivery and audit concerns.
- Services → Sockets: publishes · Pushes live updates when needed.
- Services → PostgreSQL: persists · Service-backed data operations.
- Migrations → PostgreSQL: prepares · Defines and evolves the database schema.
- Seed data → PostgreSQL: loads · Bootstraps demo content into PostgreSQL.
- Web entry → App shell: renders · Mounts application shell.
- Web entry → Pages: routes · Connects route-level pages.
- App shell → Components: composes · Uses shared layout and UI primitives.
- Pages → Features: composes · Page screens are built from feature modules.
- Features → Components: uses · Feature views share reusable UI.
- Web entry → State: initializes · Loads client state stores.
- Features → API client: calls · Reads and mutates backend data.
- Features → Socket client: subscribes · Receives live events and presence updates.
- State → API client: configures · Shares auth and tenant context with API calls.
- Socket client → Sockets: connects · Opens realtime channel to backend.
- API client → API entry: requests · Primary HTTP client path to the Express API.
- Containers → API entry: packages · Backend container image.
- Containers → Web entry: packages · Frontend container image.
- CI → Integration tests: runs · CI executes repository tests.
- CI → Containers: builds · CI validates containerized delivery.
- Integration tests → API entry: verifies · Exercises API and integration flows.