# yusufwav/nexus architecture

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

- Interactive diagram: https://gitdiagram.com/yusufwav/nexus
- Repository: https://github.com/yusufwav/nexus

## Overview

Main is a student learning platform for browsing course modules, using an AI tutor, and managing an account and purchases. The clearest evidenced runtime workflow is authenticated chat: the chat API checks the session, reads or mutates conversation history through database queries, and stores threads and messages in PostgreSQL. Module catalogue, purchase, authentication, dashboard, and PWA capabilities are represented as separate product areas. Source excerpts establish the chat and auth/database links; connections for unsampled routes and integrations are intentionally omitted.

Main entry points: [`packages/db/src/queries.ts`](https://github.com/yusufwav/nexus/blob/main/packages/db/src/queries.ts) (Database queries), [`apps/web/src/app/api/chat/route.ts`](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/chat/route.ts) (Chat API), [`packages/auth/src/index.ts`](https://github.com/yusufwav/nexus/blob/main/packages/auth/src/index.ts) (Auth service), [`apps/fumadocs/src/lib/source.ts`](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/lib/source.ts) (Docs content source)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning experience"]
  node_web["Web experience<br/>[page.tsx]"]
  node_modules["Module catalogue"]
  node_module_content["Module content<br/>[module-content.ts]"]
  node_topics["Topic learning<br/>[module-topics.ts]"]
  node_ai_tutor["AI tutor<br/>[page.tsx]"]
  node_chat_api["Chat API<br/>[route.ts]"]
  node_ai_api["AI API<br/>[route.ts]"]
  node_topic_api["Topic API<br/>[route.ts]"]
  node_pwa["PWA support"]
end

subgraph group_account["Accounts and commerce"]
  node_auth_ui["Sign-in experience<br/>[page.tsx]"]
  node_auth_api["Auth API<br/>[route.ts]"]
  node_auth_service["Auth service<br/>[index.ts]"]
  node_dashboard["Student dashboard<br/>[page.tsx]"]
  node_purchases["Purchases<br/>[page.tsx]"]
  node_payments["Payment integration<br/>[payments.ts]"]
  node_trial["Trial materials<br/>[route.ts]"]
end

subgraph group_data["Persistence"]
  node_db_queries["Database queries<br/>[queries.ts]"]
  node_catalog_data["Module catalogue data<br/>[module-catalog.ts]"]
  node_auth_schema[("Auth schema<br/>[auth.ts]")]
  node_chat_schema[("Chat schema<br/>[chat.ts]")]
  node_module_schema[("Module and purchase schema<br/>[modules.ts]")]
end

subgraph group_docs["Documentation"]
  node_docs_site["Documentation site<br/>[page.tsx]"]
  node_docs_source["Docs content source<br/>[source.ts]"]
  node_docs_shared["Docs URL helpers<br/>[shared.ts]"]
  node_docs_search["Docs search<br/>[route.ts]"]
  node_docs_export["LLM content export<br/>[route.ts]"]
end

node_student(("Student"))

node_student -.->|"uses"| node_web
node_chat_api -->|"checks session"| node_auth_service
node_chat_api -->|"reads and writes"| node_db_queries
node_db_queries -->|"queries"| node_chat_schema
node_db_queries -->|"queries"| node_module_schema
node_auth_service -->|"configures adapter"| node_auth_schema
node_docs_source -->|"uses URL helpers"| node_docs_shared

click node_web "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/page.tsx"
click node_modules "https://github.com/yusufwav/nexus/tree/main/apps/web/src/app/modules"
click node_module_content "https://github.com/yusufwav/nexus/blob/main/apps/web/src/content/module-content.ts"
click node_topics "https://github.com/yusufwav/nexus/blob/main/apps/web/src/content/module-topics.ts"
click node_ai_tutor "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/(app)/ai/page.tsx"
click node_chat_api "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/chat/route.ts"
click node_ai_api "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/ai/route.ts"
click node_topic_api "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/topics/%5Bslug%5D/route.ts"
click node_auth_ui "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/login/page.tsx"
click node_auth_api "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/auth/%5B...all%5D/route.ts"
click node_auth_service "https://github.com/yusufwav/nexus/blob/main/packages/auth/src/index.ts"
click node_dashboard "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/dashboard/page.tsx"
click node_purchases "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/dashboard/purchases/page.tsx"
click node_payments "https://github.com/yusufwav/nexus/blob/main/apps/web/src/lib/payments.ts"
click node_trial "https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/trial/route.ts"
click node_pwa "https://github.com/yusufwav/nexus/blob/main/apps/web/src/components/pwa-registration.tsx"
click node_db_queries "https://github.com/yusufwav/nexus/blob/main/packages/db/src/queries.ts"
click node_catalog_data "https://github.com/yusufwav/nexus/blob/main/packages/db/src/module-catalog.ts"
click node_auth_schema "https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/auth.ts"
click node_chat_schema "https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/chat.ts"
click node_module_schema "https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/modules.ts"
click node_docs_site "https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/(home)/page.tsx"
click node_docs_source "https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/lib/source.ts"
click node_docs_shared "https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/lib/shared.ts"
click node_docs_search "https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/api/search/route.ts"
click node_docs_export "https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/llms-full.txt/route.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_web,node_modules,node_module_content,node_topics,node_ai_tutor,node_chat_api,node_ai_api,node_topic_api,node_pwa toneBlue
class node_auth_ui,node_auth_api,node_auth_service,node_dashboard,node_purchases,node_payments,node_trial toneAmber
class node_db_queries,node_catalog_data,node_auth_schema,node_chat_schema,node_module_schema toneMint
class node_docs_site,node_docs_source,node_docs_shared,node_docs_search,node_docs_export toneRose
class node_student toneIndigo
```

## Components

### Learning experience

- [Web experience](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/page.tsx): `apps/web/src/app/page.tsx`
- [Module catalogue](https://github.com/yusufwav/nexus/tree/main/apps/web/src/app/modules): `apps/web/src/app/modules`
- [Module content](https://github.com/yusufwav/nexus/blob/main/apps/web/src/content/module-content.ts): `apps/web/src/content/module-content.ts`
- [Topic learning](https://github.com/yusufwav/nexus/blob/main/apps/web/src/content/module-topics.ts): `apps/web/src/content/module-topics.ts`
- [AI tutor](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/(app)/ai/page.tsx): `apps/web/src/app/(app)/ai/page.tsx`
- [Chat API](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/chat/route.ts): `apps/web/src/app/api/chat/route.ts`
- [AI API](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/ai/route.ts): `apps/web/src/app/api/ai/route.ts`
- [Topic API](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/topics/%5Bslug%5D/route.ts): `apps/web/src/app/api/topics/[slug]/route.ts`
- [PWA support](https://github.com/yusufwav/nexus/blob/main/apps/web/src/components/pwa-registration.tsx): `apps/web/src/components/pwa-registration.tsx`

### Accounts and commerce

- [Sign-in experience](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/login/page.tsx): `apps/web/src/app/login/page.tsx`
- [Auth API](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/auth/%5B...all%5D/route.ts): `apps/web/src/app/api/auth/[...all]/route.ts`
- [Auth service](https://github.com/yusufwav/nexus/blob/main/packages/auth/src/index.ts): `packages/auth/src/index.ts`
- [Student dashboard](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/dashboard/page.tsx): `apps/web/src/app/dashboard/page.tsx`
- [Purchases](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/dashboard/purchases/page.tsx): `apps/web/src/app/dashboard/purchases/page.tsx`
- [Payment integration](https://github.com/yusufwav/nexus/blob/main/apps/web/src/lib/payments.ts): `apps/web/src/lib/payments.ts`
- [Trial materials](https://github.com/yusufwav/nexus/blob/main/apps/web/src/app/api/trial/route.ts): `apps/web/src/app/api/trial/route.ts`

### Persistence

- [Database queries](https://github.com/yusufwav/nexus/blob/main/packages/db/src/queries.ts): `packages/db/src/queries.ts`
- [Module catalogue data](https://github.com/yusufwav/nexus/blob/main/packages/db/src/module-catalog.ts): `packages/db/src/module-catalog.ts`
- [Auth schema](https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/auth.ts): `packages/db/src/schema/auth.ts`
- [Chat schema](https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/chat.ts): `packages/db/src/schema/chat.ts`
- [Module and purchase schema](https://github.com/yusufwav/nexus/blob/main/packages/db/src/schema/modules.ts): `packages/db/src/schema/modules.ts`

### Documentation

- [Documentation site](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/(home)/page.tsx): `apps/fumadocs/src/app/(home)/page.tsx`
- [Docs content source](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/lib/source.ts): `apps/fumadocs/src/lib/source.ts`
- [Docs URL helpers](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/lib/shared.ts): `apps/fumadocs/src/lib/shared.ts`
- [Docs search](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/api/search/route.ts): `apps/fumadocs/src/app/api/search/route.ts`
- [LLM content export](https://github.com/yusufwav/nexus/blob/main/apps/fumadocs/src/app/llms-full.txt/route.ts): `apps/fumadocs/src/app/llms-full.txt/route.ts`

### Other components

- **Student**

## Connections

- Student → Web experience: uses (evidence: `README.md`)
- Chat API → Auth service: checks session (evidence: `apps/web/src/app/api/chat/route.ts`)
- Chat API → Database queries: reads and writes (evidence: `apps/web/src/app/api/chat/route.ts`)
- Database queries → Chat schema: queries (evidence: `packages/db/src/queries.ts`)
- Database queries → Module and purchase schema: queries (evidence: `packages/db/src/queries.ts`)
- Auth service → Auth schema: configures adapter (evidence: `packages/auth/src/index.ts`)
- Docs content source → Docs URL helpers: uses URL helpers (evidence: `apps/fumadocs/src/lib/source.ts`)
