# nalumnsut/nalum architecture

> Architecture diagram of the GitHub repository nalumnsut/nalum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nalumnsut/nalum
- Repository: https://github.com/nalumnsut/nalum

## Overview

1. This is a two-app monorepo with a clear split between a React/Vite frontend and an Express backend. The backend serves as the API and realtime service layer; the frontend is the user-facing SPA and also includes an admin area.

2. The backend is organized by domain rather than by technical layer. Major route/controller/model groupings exist for auth, profiles, posts, comments, queries, reports, notifications, events, giving, alumni verification, search, and chat. There is also a separate admin domain with its own controllers, routes, and models.

3. Data access is centralized in backend models and configuration files. The presence of postgres configuration plus Redis configuration suggests a relational primary datastore with Redis used for caching, sessions, rate limiting, queues, or realtime coordination. The codebase also includes session, OTP, verification token, push subscription, and moderation-related models.

4. The request path is conventional Express flow: route modules map endpoints to controllers, controllers coordinate services/models, and middleware enforces auth, admin auth, bans, validation, rate limiting, and image compression. This creates a boundary between transport concerns and business logic.

5. Authentication and account lifecycle are substantial subsystems. The backend includes sign-up, sign-in, refresh/logout/revoke-token, forgot/reset password, OTP, verification links, and alumni verification flows. The frontend mirrors this with dedicated auth pages and protected routes, indicating stateful session/token handling across the app.

6. Chat is a separate realtime subsystem. It includes conversation, message, connection, community, and search endpoints on the backend, plus socket infrastructure under backend/sockets. The frontend has chat-specific context, hooks, and page components, so chat traffic likely mixes REST for history/state and WebSockets for live messaging, typing, and presence.

7. Notifications are another cross-cutting subsystem. The backend has notification models, notification preferences, a notification service, and mailer/templates. The frontend has notification context/components and push-related hooks, suggesting a combination of in-app notifications, email notifications, and browser push support.

8. Content and community features are modeled as first-class domains: posts, comments, reports, queries, giving, events, and alumni directory/map views. These are exposed both to the public site and to authenticated dashboard users, while admins get separate moderation/management views for approvals, bans, reports, newsletters, and statistics.

9. File handling is a significant boundary in the backend. Multiple multer configurations and upload directories exist for profile pictures, posts, events, giving, newsletters, and queries. This indicates the API accepts and stores user-generated media locally within backend/uploads, with middleware handling compression and upload constraints.

10. The frontend is structured as a routed SPA with public, auth, dashboard, and admin route groups. It uses many reusable UI components, feature-specific components, and page-level route modules. Context providers for auth, chat, notifications, and profile imply that client state is shared across route boundaries rather than fetched independently in each page.

11. The frontend also has platform-level features beyond the SPA shell: PWA support, a service worker, push notification hooks, page tracking, responsive utilities, and theme toggling. That means the client is designed to behave like an app, not just a static website, and participates in background notifications and installability.

12. There is a strong admin boundary in both layers. Backend admin routes/controllers isolate privileged operations such as user management, verification queues, reports, event approvals, posts moderation, newsletters, alumni database, and codes/statistics. Frontend admin pages are separately routed and protected, reinforcing role-based access control end to end.

13. Operationally, the repo is built for containerized development and deployment. Dockerfiles exist for both apps, docker-compose is present, and there are GitHub Actions workflows for CI/CD. Nginx/Vercel config files indicate the frontend is deployed as a static app or edge-hosted site while the backend is container/API deployed separately.

14. The repository also includes a substantial test and automation surface: backend integration and route tests, frontend component/page tests, Bruno API collections, and utility scripts for seeding, verification, consistency checks, and admin/event setup. This suggests the architecture depends on both API correctness and repeatable environment setup.

Main entry points: [`backend/controllers`](https://github.com/nalumnsut/nalum/tree/main/backend/controllers) (Controllers), [`backend/routes`](https://github.com/nalumnsut/nalum/tree/main/backend/routes) (Routes), [`backend/index.js`](https://github.com/nalumnsut/nalum/blob/main/backend/index.js) (Server entry), [`backend/models`](https://github.com/nalumnsut/nalum/tree/main/backend/models) (Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Backend"]
  node_backend_entry["Server entry<br/>express bootstrap<br/>[index.js]"]
  node_backend_routes["Routes<br/>endpoint map"]
  node_backend_controllers["Controllers<br/>request handlers"]
  node_backend_middleware["Middleware<br/>policy layer"]
  node_backend_models[("Models")]
  node_backend_config["Config"]
  node_backend_services["Services"]
  node_backend_sockets["Sockets<br/>realtime layer"]
  node_backend_mail["Mail"]
  node_backend_uploads["Uploads<br/>media storage"]
end

subgraph group_frontend["Frontend"]
  node_frontend_routes["Routes<br/>spa routing"]
  node_frontend_contexts(("Contexts<br/>client state"))
  node_frontend_pages["Pages<br/>view layer"]
  node_frontend_components["Components<br/>ui system"]
  node_frontend_hooks_lib["Hooks & lib<br/>client services"]
  node_frontend_public["PWA shell<br/>web assets"]
end

subgraph group_ops["Ops & QA"]
  node_ops_compose["Compose<br/>container dev<br/>[docker-compose.yml]"]
  node_ops_ci["CI/CD<br/>automation<br/>[workflows]"]
  node_ops_tests["API tests<br/>integration checks"]
  node_ops_scripts["Scripts<br/>ops utilities"]
end

node_backend_entry -->|"mounts"| node_backend_routes
node_backend_entry -->|"uses"| node_backend_middleware
node_backend_entry -->|"connects"| node_backend_models
node_backend_routes -->|"dispatches"| node_backend_controllers
node_backend_controllers -->|"orchestrates"| node_backend_services
node_backend_controllers -->|"reads/writes"| node_backend_models
node_backend_controllers -->|"guards"| node_backend_middleware
node_backend_services -->|"persists"| node_backend_models
node_backend_controllers -->|"sends"| node_backend_mail
node_backend_controllers -->|"stores media"| node_backend_uploads
node_backend_routes -.->|"extends"| node_backend_sockets
node_backend_config -->|"configures"| node_backend_entry
node_backend_config -->|"supports"| node_backend_models
node_frontend_routes -->|"renders"| node_frontend_pages
node_frontend_pages -->|"composes"| node_frontend_components
node_frontend_pages -->|"consumes"| node_frontend_contexts
node_frontend_components -->|"uses"| node_frontend_hooks_lib
node_frontend_hooks_lib -.->|"calls API"| node_backend_routes
node_frontend_contexts -.->|"syncs with"| node_backend_routes
node_frontend_public -->|"boots"| node_frontend_routes
node_ops_compose -->|"runs"| node_backend_entry
node_ops_compose -->|"runs"| node_frontend_routes
node_ops_ci -->|"verifies"| node_ops_tests
node_ops_scripts -.->|"seeds/repairs"| node_backend_models
node_ops_tests -.->|"tests"| node_backend_routes

click node_backend_entry "https://github.com/nalumnsut/nalum/blob/main/backend/index.js"
click node_backend_routes "https://github.com/nalumnsut/nalum/tree/main/backend/routes"
click node_backend_controllers "https://github.com/nalumnsut/nalum/tree/main/backend/controllers"
click node_backend_middleware "https://github.com/nalumnsut/nalum/tree/main/backend/middleware"
click node_backend_models "https://github.com/nalumnsut/nalum/tree/main/backend/models"
click node_backend_config "https://github.com/nalumnsut/nalum/tree/main/backend/config"
click node_backend_services "https://github.com/nalumnsut/nalum/tree/main/backend/services"
click node_backend_sockets "https://github.com/nalumnsut/nalum/tree/main/backend/sockets"
click node_backend_mail "https://github.com/nalumnsut/nalum/tree/main/backend/mail"
click node_backend_uploads "https://github.com/nalumnsut/nalum/tree/main/backend/uploads"
click node_frontend_routes "https://github.com/nalumnsut/nalum/tree/main/frontend/src/routes"
click node_frontend_contexts "https://github.com/nalumnsut/nalum/tree/main/frontend/src/context"
click node_frontend_pages "https://github.com/nalumnsut/nalum/tree/main/frontend/src/pages"
click node_frontend_components "https://github.com/nalumnsut/nalum/tree/main/frontend/src/components"
click node_frontend_hooks_lib "https://github.com/nalumnsut/nalum/tree/main/frontend/src/hooks"
click node_frontend_public "https://github.com/nalumnsut/nalum/tree/main/frontend/public"
click node_ops_compose "https://github.com/nalumnsut/nalum/blob/main/docker-compose.yml"
click node_ops_ci "https://github.com/nalumnsut/nalum/blob/main/.github/workflows"
click node_ops_tests "https://github.com/nalumnsut/nalum/tree/main/api_test/NALUM"
click node_ops_scripts "https://github.com/nalumnsut/nalum/tree/main/backend/scripts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backend_entry,node_backend_routes,node_backend_controllers,node_backend_middleware,node_backend_models,node_backend_config,node_backend_services,node_backend_sockets,node_backend_mail,node_backend_uploads toneBlue
class node_frontend_routes,node_frontend_contexts,node_frontend_pages,node_frontend_components,node_frontend_hooks_lib,node_frontend_public toneAmber
class node_ops_compose,node_ops_ci,node_ops_tests,node_ops_scripts toneMint
```

## Components

### Backend

Express API, realtime services, and domain data layer.

- [Server entry](https://github.com/nalumnsut/nalum/blob/main/backend/index.js): express bootstrap · Starts the API server and wires the backend application together. · `backend/index.js`
- [Routes](https://github.com/nalumnsut/nalum/tree/main/backend/routes): endpoint map · Domain route modules for auth, profiles, posts, chat, admin, and other features. · `backend/routes`
- [Controllers](https://github.com/nalumnsut/nalum/tree/main/backend/controllers): request handlers · Coordinates requests across auth, content, moderation, notifications, and chat. · `backend/controllers`
- [Middleware](https://github.com/nalumnsut/nalum/tree/main/backend/middleware): policy layer · Auth, admin auth, bans, validation, rate limiting, and image compression boundaries. · `backend/middleware`
- [Models](https://github.com/nalumnsut/nalum/tree/main/backend/models): data models · Primary persistence layer for users, auth, posts, chat, moderation, and admin state. · `backend/models`
- [Config](https://github.com/nalumnsut/nalum/tree/main/backend/config): runtime config · Database, Redis, JWT, mail, and upload configuration. · `backend/config`
- [Services](https://github.com/nalumnsut/nalum/tree/main/backend/services): domain services · Shared business logic for notifications, alumni, mentions, geocoding, and comments. · `backend/services`
- [Sockets](https://github.com/nalumnsut/nalum/tree/main/backend/sockets): realtime layer · WebSocket chat transport and message/typing handlers. · `backend/sockets`
- [Mail](https://github.com/nalumnsut/nalum/tree/main/backend/mail): email delivery · Notification mailer and templates for outbound messaging. · `backend/mail`
- [Uploads](https://github.com/nalumnsut/nalum/tree/main/backend/uploads): media storage · Server-side storage for profile, post, event, giving, newsletter, and query assets. · `backend/uploads`

### Frontend

React/Vite SPA with public, dashboard, and admin surfaces.

- [Routes](https://github.com/nalumnsut/nalum/tree/main/frontend/src/routes): spa routing · Public, auth, dashboard, and admin route groups for the client app. · `frontend/src/routes`
- [Contexts](https://github.com/nalumnsut/nalum/tree/main/frontend/src/context): client state · Shared auth, chat, notification, and profile state across the SPA. · `frontend/src/context`
- [Pages](https://github.com/nalumnsut/nalum/tree/main/frontend/src/pages): view layer · Route-level screens for public content, auth flows, dashboard, chat, and admin. · `frontend/src/pages`
- [Components](https://github.com/nalumnsut/nalum/tree/main/frontend/src/components): ui system · Reusable UI plus feature components for posts, profile, notifications, chat, and admin. · `frontend/src/components`
- [Hooks & lib](https://github.com/nalumnsut/nalum/tree/main/frontend/src/hooks): client services · API wrappers, hooks, validation, analytics, PWA, push, and socket helpers. · `frontend/src/hooks`
- [PWA shell](https://github.com/nalumnsut/nalum/tree/main/frontend/public): web assets · Service worker, manifest, static content, and edge/web deployment assets. · `frontend/public`

### Ops & QA

Containers, CI/CD, API collections, and automated checks.

- [Compose](https://github.com/nalumnsut/nalum/blob/main/docker-compose.yml): container dev · Local multi-service orchestration for frontend and backend. · `docker-compose.yml`
- [CI/CD](https://github.com/nalumnsut/nalum/blob/main/.github/workflows): automation · GitHub Actions workflows for backend and frontend build, test, and deploy. · `.github/workflows`
- [API tests](https://github.com/nalumnsut/nalum/tree/main/api_test/NALUM): integration checks · Bruno collections and API smoke tests for auth, profile, chat, and dashboard flows. · `api_test/NALUM`
- [Scripts](https://github.com/nalumnsut/nalum/tree/main/backend/scripts): ops utilities · Seeding, repair, verification, and admin/event setup scripts. · `backend/scripts`

## Connections

- Server entry → Routes: mounts · The server bootstraps the route tree.
- Server entry → Middleware: uses · Global request policies are applied during request handling.
- Server entry → Models: connects · The app initializes persistence-backed features.
- Routes → Controllers: dispatches · Route modules hand off to domain controllers.
- Controllers → Services: orchestrates · Controllers delegate shared business logic to services.
- Controllers → Models: reads/writes · Controllers persist and query domain state through models.
- Controllers → Middleware: guards · Admin/auth/validation middleware protects sensitive flows.
- Services → Models: persists · Services use models for notifications, chat, alumni, and geocoding data.
- Controllers → Mail: sends · Notification and verification flows emit email.
- Controllers → Uploads: stores media · Upload-backed features save images and files through constrained handlers.
- Routes → Sockets: extends · Chat routes complement realtime socket interactions.
- Config → Server entry: configures · Database, Redis, JWT, and mail settings are loaded by the backend.
- Config → Models: supports · Database and cache configuration underpins persistence.
- Routes → Pages: renders · Route groups resolve to page-level screens.
- Pages → Components: composes · Pages are built from reusable feature and UI components.
- Pages → Contexts: consumes · Pages share auth, chat, notification, and profile state.
- Components → Hooks & lib: uses · UI features rely on hooks and API helpers.
- Hooks & lib → Routes: calls API · Client hooks and libraries talk to the backend endpoints.
- Contexts → Routes: syncs with · Client state is hydrated and maintained through API calls.
- PWA shell → Routes: boots · Static assets and the service worker support the SPA shell.
- Compose → Server entry: runs · Compose brings up the API service.
- Compose → Routes: runs · Compose brings up the client app.
- CI/CD → API tests: verifies · CI pipelines use API and app-level checks.
- Scripts → Models: seeds/repairs · Utility scripts manipulate backend data and admin setup.
- API tests → Routes: tests · Bruno collections target core API routes.
