# abraham3stack/migrate-ai architecture

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

- Interactive diagram: https://gitdiagram.com/abraham3stack/migrate-ai
- Repository: https://github.com/abraham3stack/migrate-ai

## Overview

#### Purpose and Deployable Entry Points
MigrateAI is a full-stack migration-services platform: public pathway discovery, authenticated user migration workflows, and role-restricted administration. The Next.js 15 frontend starts at `web/src/app/layout.tsx` and route groups under `web/src/app`; the Express API starts at `server/src/server.ts`, configures middleware/routes in `server/src/app.ts`, and aggregates API modules in `server/src/routes/index.ts`.

#### Frontend Delivery and Route Domains
Next App Router separates marketing, authentication, user dashboard, and admin experiences through layouts and route groups. Feature modules encapsulate UI, API adapters, hooks, and types, while pages mostly compose these modules.
- User application shell: `web/src/app/(dashboard)/layout.tsx`, `web/src/components/layout/dashboard-shell.tsx`
- Marketing/public pathways: `web/src/app/(marketing)/pathways/page.tsx`, `web/src/modules/marketing/components/pathways-content.tsx`
- Admin operations: `web/src/app/(admin)/layout.tsx`, `web/src/modules/admin/components/admin-page.tsx`
- Route protection occurs at `web/src/middleware.ts` and `web/src/modules/auth/components/protected-route.tsx`.

#### Client State, API, and Real-Time Boundary
The browser uses Axios API adapters, TanStack Query feature hooks, and Zustand for cross-page auth/notification/layout state. The API client owns JWT attachment and refresh behavior; UI calls domain-specific adapters rather than Express directly. Socket clients receive real-time notifications/admin events.
- `web/src/lib/api/client.ts`, `web/src/lib/api/auth.api.ts`
- `web/src/store/auth-store.ts`, `web/src/components/providers/query-provider.tsx`
- `web/src/lib/socket/client.ts`, `web/src/modules/notifications/hooks/use-realtime-notifications.ts`

#### API Layer and Security Pipeline
Express follows route → controller → service → Prisma flow. DTOs/validation constrain inputs; shared async/error middleware standardizes failures. JWT authentication, refresh-token handling, role guards, and per-domain rate-limit middleware establish the principal trust boundary between public, user, and admin APIs.
- `server/src/routes/index.ts`, `server/src/common/middleware/error.middleware.ts`
- `server/src/modules/auth/routes/auth.routes.ts`, `server/src/modules/auth/middleware/auth.middleware.ts`, `server/src/modules/auth/middleware/role.guard.ts`
- `server/src/modules/auth/services/auth.service.ts`

#### Migration Workflow Domain
Pathways are the core catalog and user-engagement domain, supporting saved pathways, contact requests, and applications. Profile/assessment data drives readiness and dashboard views; documents support upload and administrative review; fees/payment entries track migration financial steps.
- `server/src/modules/pathways/services/pathway.service.ts`, `server/src/modules/applications/services/application.service.ts`
- `server/src/modules/profile/services/profile.service.ts`, `server/src/modules/dashboard/services/dashboard.service.ts`
- `server/src/modules/documents/services/document.service.ts`, `server/src/modules/fees/services/fee.service.ts`

#### Platform Engagement and Administration
Feeds, notifications/activity, resources, webinars, and success stories provide community and content surfaces. Admin routes manage users and operational entities; Socket.IO authenticates connections and supports event delivery.
- `server/src/modules/feeds/services/feed.service.ts`, `server/src/modules/notifications/services/notification.service.ts`
- `server/src/modules/admin/services/admin.service.ts`, `server/src/common/socket/socket.server.ts`
- `server/src/modules/webinars/services/webinar.service.ts`, `server/src/modules/resources/services/resource.service.ts`

#### Persistence and External Integrations
Prisma models and migrations define a PostgreSQL-backed system of record, including auth/audit, pathways, documents, AI conversations, Google accounts, and payment foundations. AI services abstract Gemini, OpenAI, and OpenRouter behind one domain service. Payments integrate Paystack. Google OAuth is configured server-side. Current avatar/document upload middleware uses server-local storage, requiring object storage for durable production deployments.
- `server/prisma/schema.prisma`, `server/prisma/migrations/20260528100000_add_ai_conversations/migration.sql`
- `server/src/modules/ai/services/ai.service.ts`, `server/src/modules/ai/providers/openai-provider.ts`
- `server/src/modules/payments/services/paystack.service.ts`, `server/src/modules/documents/middleware/document-upload.middleware.ts`

Main entry points: [`server/src/modules/auth/middleware/auth.middleware.ts`](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/auth/middleware/auth.middleware.ts) (Security pipeline), [`server/prisma/schema.prisma`](https://github.com/abraham3stack/migrate-ai/blob/main/server/prisma/schema.prisma) (PostgreSQL system of record), [`web/src/app/(dashboard)/layout.tsx`](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/app/(dashboard)/layout.tsx) (Route domains), [`server/src/modules/documents/services/document.service.ts`](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/documents/services/document.service.ts) (Documents and fees)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Next.js frontend"]
  node_next_app["Next app entry<br/>Next.js 15<br/>[layout.tsx]"]
  node_route_domains["Route domains<br/>App Router layouts<br/>[layout.tsx]"]
  node_pathways_ui["Public pathways UI<br/>marketing feature"]
  node_admin_ui["Admin UI<br/>admin feature<br/>[admin-page.tsx]"]
  node_route_protection["Route protection<br/>middleware and guard<br/>[middleware.ts]"]
  node_client_data["Client data boundary<br/>Axios, Query, Zustand<br/>[client.ts]"]
  node_realtime_client["Realtime client<br/>Socket hooks"]
end

subgraph group_api["Express API"]
  node_express_server["Express server<br/>API entry point<br/>[server.ts]"]
  node_api_routes["API route registry<br/>route aggregation<br/>[index.ts]"]
  node_security_pipeline["Security pipeline<br/>JWT, roles, validation<br/>[auth.middleware.ts]"]
  node_socket_server["Socket.IO server<br/>event delivery<br/>[socket.server.ts]"]
end

subgraph group_domains["Domain services"]
  node_auth_service["Auth service<br/>auth domain<br/>[auth.service.ts]"]
  node_migration_services["Migration workflow<br/>pathways and applications<br/>[pathway.service.ts]"]
  node_user_services["User progress<br/>profile and dashboard<br/>[profile.service.ts]"]
  node_document_fee_services["Documents and fees<br/>workflow services"]
  node_engagement_services["Engagement content<br/>feeds and notifications"]
  node_admin_service["Admin operations<br/>admin domain<br/>[admin.service.ts]"]
end

subgraph group_platform["Persistence &amp; integrations"]
  node_prisma_postgres[("PostgreSQL system of record<br/>Prisma<br/>[schema.prisma]")]
  node_external_services{{"External services<br/>AI, Paystack, Google OAuth<br/>[ai.service.ts]"}}
  node_local_uploads["Local upload storage<br/>upload middleware"]
end

node_next_app -->|"renders"| node_route_domains
node_route_domains -->|"public pathway pages"| node_pathways_ui
node_route_domains -->|"admin pages"| node_admin_ui
node_route_protection -->|"protects"| node_route_domains
node_route_domains -->|"uses"| node_client_data
node_client_data -->|"HTTPS API"| node_express_server
node_realtime_client -->|"Socket.IO"| node_socket_server
node_express_server -->|"mounts"| node_api_routes
node_api_routes -->|"applies trust boundary"| node_security_pipeline
node_security_pipeline -->|"auth requests"| node_auth_service
node_security_pipeline -->|"authorized requests"| node_migration_services
node_security_pipeline -->|"authorized requests"| node_user_services
node_security_pipeline -->|"authorized requests"| node_document_fee_services
node_security_pipeline -->|"authorized requests"| node_engagement_services
node_security_pipeline -->|"role-restricted requests"| node_admin_service
node_auth_service -->|"persists identities"| node_prisma_postgres
node_migration_services -->|"persists workflow"| node_prisma_postgres
node_user_services -->|"persists progress"| node_prisma_postgres
node_document_fee_services -->|"persists records"| node_prisma_postgres
node_document_fee_services -->|"uploads files"| node_local_uploads
node_engagement_services -->|"persists content"| node_prisma_postgres
node_admin_service -->|"manages entities"| node_prisma_postgres
node_engagement_services -->|"emits events"| node_socket_server
node_admin_service -->|"emits admin events"| node_socket_server
node_migration_services -->|"AI assistance"| node_external_services
node_document_fee_services -->|"payment processing"| node_external_services
node_auth_service -->|"Google OAuth"| node_external_services

click node_next_app "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/app/layout.tsx"
click node_route_domains "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/app/(dashboard)/layout.tsx"
click node_pathways_ui "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/marketing/components/pathways-content.tsx"
click node_admin_ui "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/admin/components/admin-page.tsx"
click node_route_protection "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/middleware.ts"
click node_client_data "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/lib/api/client.ts"
click node_realtime_client "https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/notifications/hooks/use-realtime-notifications.ts"
click node_express_server "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/server.ts"
click node_api_routes "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/routes/index.ts"
click node_security_pipeline "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/auth/middleware/auth.middleware.ts"
click node_auth_service "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/auth/services/auth.service.ts"
click node_migration_services "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/pathways/services/pathway.service.ts"
click node_user_services "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/profile/services/profile.service.ts"
click node_document_fee_services "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/documents/services/document.service.ts"
click node_engagement_services "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/notifications/services/notification.service.ts"
click node_admin_service "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/admin/services/admin.service.ts"
click node_socket_server "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/common/socket/socket.server.ts"
click node_prisma_postgres "https://github.com/abraham3stack/migrate-ai/blob/main/server/prisma/schema.prisma"
click node_external_services "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/ai/services/ai.service.ts"
click node_local_uploads "https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/documents/middleware/document-upload.middleware.ts"

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_next_app,node_route_domains,node_pathways_ui,node_admin_ui,node_route_protection,node_client_data,node_realtime_client toneBlue
class node_express_server,node_api_routes,node_security_pipeline,node_socket_server toneAmber
class node_auth_service,node_migration_services,node_user_services,node_document_fee_services,node_engagement_services,node_admin_service toneMint
class node_prisma_postgres,node_external_services,node_local_uploads toneRose
```

## Components

### Next.js frontend

- [Next app entry](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/app/layout.tsx): Next.js 15 · `web/src/app/layout.tsx`
- [Route domains](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/app/(dashboard)/layout.tsx): App Router layouts · Marketing, dashboard, and admin route groups separate experiences. · `web/src/app/(dashboard)/layout.tsx`
- [Public pathways UI](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/marketing/components/pathways-content.tsx): marketing feature · `web/src/modules/marketing/components/pathways-content.tsx`
- [Admin UI](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/admin/components/admin-page.tsx): admin feature · `web/src/modules/admin/components/admin-page.tsx`
- [Route protection](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/middleware.ts): middleware and guard · `web/src/middleware.ts`
- [Client data boundary](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/lib/api/client.ts): Axios, Query, Zustand · Adapters attach and refresh JWTs; hooks manage server state. · `web/src/lib/api/client.ts`
- [Realtime client](https://github.com/abraham3stack/migrate-ai/blob/main/web/src/modules/notifications/hooks/use-realtime-notifications.ts): Socket hooks · `web/src/modules/notifications/hooks/use-realtime-notifications.ts`

### Express API

- [Express server](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/server.ts): API entry point · `server/src/server.ts`
- [API route registry](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/routes/index.ts): route aggregation · `server/src/routes/index.ts`
- [Security pipeline](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/auth/middleware/auth.middleware.ts): JWT, roles, validation · Authentication, refresh handling, role guards, rate limits, and error handling. · `server/src/modules/auth/middleware/auth.middleware.ts`
- [Socket.IO server](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/common/socket/socket.server.ts): event delivery · Authenticates connections and delivers notification/admin events. · `server/src/common/socket/socket.server.ts`

### Domain services

- [Auth service](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/auth/services/auth.service.ts): auth domain · `server/src/modules/auth/services/auth.service.ts`
- [Migration workflow](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/pathways/services/pathway.service.ts): pathways and applications · Catalog, saved pathways, contacts, and migration applications. · `server/src/modules/pathways/services/pathway.service.ts`
- [User progress](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/profile/services/profile.service.ts): profile and dashboard · Profile, assessment, and readiness/dashboard views. · `server/src/modules/profile/services/profile.service.ts`
- [Documents and fees](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/documents/services/document.service.ts): workflow services · Upload/review documents and track financial steps. · `server/src/modules/documents/services/document.service.ts`
- [Engagement content](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/notifications/services/notification.service.ts): feeds and notifications · Feeds, notifications, resources, webinars, and stories. · `server/src/modules/notifications/services/notification.service.ts`
- [Admin operations](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/admin/services/admin.service.ts): admin domain · `server/src/modules/admin/services/admin.service.ts`

### Persistence & integrations

- [PostgreSQL system of record](https://github.com/abraham3stack/migrate-ai/blob/main/server/prisma/schema.prisma): Prisma · Models cover auth, audit, migration data, documents, AI, and payments. · `server/prisma/schema.prisma`
- [External services](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/ai/services/ai.service.ts): AI, Paystack, Google OAuth · AI providers are abstracted behind one service. · `server/src/modules/ai/services/ai.service.ts`
- [Local upload storage](https://github.com/abraham3stack/migrate-ai/blob/main/server/src/modules/documents/middleware/document-upload.middleware.ts): upload middleware · Current document storage needs object storage for durable production use. · `server/src/modules/documents/middleware/document-upload.middleware.ts`

## Connections

- Next app entry → Route domains: renders
- Route domains → Public pathways UI: public pathway pages
- Route domains → Admin UI: admin pages
- Route protection → Route domains: protects
- Route domains → Client data boundary: uses
- Client data boundary → Express server: HTTPS API
- Realtime client → Socket.IO server: Socket.IO
- Express server → API route registry: mounts
- API route registry → Security pipeline: applies trust boundary
- Security pipeline → Auth service: auth requests
- Security pipeline → Migration workflow: authorized requests
- Security pipeline → User progress: authorized requests
- Security pipeline → Documents and fees: authorized requests
- Security pipeline → Engagement content: authorized requests
- Security pipeline → Admin operations: role-restricted requests
- Auth service → PostgreSQL system of record: persists identities
- Migration workflow → PostgreSQL system of record: persists workflow
- User progress → PostgreSQL system of record: persists progress
- Documents and fees → PostgreSQL system of record: persists records
- Documents and fees → Local upload storage: uploads files
- Engagement content → PostgreSQL system of record: persists content
- Admin operations → PostgreSQL system of record: manages entities
- Engagement content → Socket.IO server: emits events
- Admin operations → Socket.IO server: emits admin events
- Migration workflow → External services: AI assistance
- Documents and fees → External services: payment processing
- Auth service → External services: Google OAuth
