# nguyenlephianh56/englishaiweb architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenlephianh56/englishaiweb
- Repository: https://github.com/nguyenlephianh56/englishaiweb

## Overview

EnglishAI is a web app for adaptive, AI-assisted English learning, with student, teacher, and admin experiences. Users enter through the client’s public landing/auth routes; authenticated users reach role-specific workspaces for learning, class and assignment management, or administration. The server exposes API modules for identity, classes, exercises, assignments, and attempts, alongside AI, analytics, reporting, and related capabilities visible in the tree. Shown excerpts establish selected routing and service calls; links to unsampled modules are omitted or marked unverified rather than inferred as confirmed calls.

Main entry points: [`server/src/app.ts`](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/app.ts) (HTTP API), [`server/src/config/prisma.ts`](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/config/prisma.ts) (PostgreSQL data), [`client/src/app/router.tsx`](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/app/router.tsx) (Role-based routes), [`server/src/modules/auth/auth.service.ts`](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/auth/auth.service.ts) (Account and session logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_router["Role-based routes<br/>[router.tsx]"]
  node_landing["Landing experience<br/>[LandingPage.tsx]"]
  node_authui["Login and registration"]
  node_workspaces["Role workspaces"]
  node_apiclient["API client<br/>[client.ts]"]
  node_authhook["Session hook<br/>[useAuth.ts]"]
  node_authapi["Auth API<br/>[auth.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authroutes["Auth endpoints<br/>[auth.routes.ts]"]
  node_authlogic["Account and session logic<br/>[auth.service.ts]"]
  node_access["Authentication and roles<br/>[auth.ts]"]
end

subgraph group_learning["Learning workflow"]
  node_exercises["Exercise library"]
  node_grading["Exercise grading<br/>[grading.service.ts]"]
  node_attempts["Student attempts"]
  node_paths["Learning paths"]
  node_skills["Skill profiles"]
end

subgraph group_operations["Classroom operations"]
  node_admin["Admin management"]
  node_classes["Class management"]
  node_assignments["Assignments"]
end

subgraph group_platform["Platform services"]
  node_server["HTTP API<br/>[app.ts]"]
  node_ai["AI generation and analysis"]
  node_analytics["Analytics and reports"]
  node_notifications["Notifications and reminders"]
  node_database[("PostgreSQL data<br/>[prisma.ts]")]
  node_response["API response format<br/>[response.ts]"]
end

node_learner(("Learners and staff"))

node_learner -->|"opens"| node_router
node_router -->|"routes to"| node_landing
node_router -->|"routes to"| node_authui
node_router -->|"routes by role"| node_workspaces
node_authhook -->|"calls"| node_authapi
node_authapi -->|"uses"| node_apiclient
node_apiclient -.->|"sends API requests"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts admin routes"| node_admin
node_server -->|"mounts class routes"| node_classes
node_server -->|"mounts exercise routes"| node_exercises
node_server -->|"mounts attempt routes"| node_attempts
node_server -->|"mounts assignment routes"| node_assignments
node_authroutes -->|"dispatches"| node_authlogic
node_authlogic -->|"reads and writes"| node_database
node_authlogic -.->|"issues JWT"| node_access
node_access -->|"looks up user"| node_database
node_admin -.->|"manages users"| node_database
node_classes -.->|"manages classes"| node_database
node_exercises -.->|"stores exercises"| node_database
node_attempts -.->|"stores attempts"| node_database
node_assignments -.->|"stores assignments"| node_database
node_attempts -.->|"grades submissions"| node_grading
node_exercises -.->|"may use AI"| node_ai
node_paths -.->|"may personalize with AI"| node_ai
node_skills -.->|"informs insights"| node_analytics
node_analytics -.->|"reads learning data"| node_database
node_notifications -.->|"reads notification data"| node_database
node_server -.->|"uses response helpers"| node_response

click node_router "https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/app/router.tsx"
click node_landing "https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/features/landing/LandingPage.tsx"
click node_authui "https://github.com/nguyenlephianh56/englishaiweb/tree/main/client/src/features/auth"
click node_workspaces "https://github.com/nguyenlephianh56/englishaiweb/tree/main/client/src/features"
click node_apiclient "https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/api/client.ts"
click node_authhook "https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/hooks/useAuth.ts"
click node_authapi "https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/api/auth.ts"
click node_server "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/app.ts"
click node_authroutes "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/auth/auth.routes.ts"
click node_authlogic "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/auth/auth.service.ts"
click node_access "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/middlewares/auth.ts"
click node_admin "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/admin/admin.controller.ts"
click node_classes "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/classes/classes.controller.ts"
click node_exercises "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/exercises/exercises.service.ts"
click node_grading "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/grading/grading.service.ts"
click node_attempts "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/attempts/attempts.controller.ts"
click node_assignments "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/assignments/assignments.service.ts"
click node_paths "https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/learning-paths"
click node_skills "https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/skill-profiles"
click node_ai "https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/ai"
click node_analytics "https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/analytics"
click node_notifications "https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/notifications"
click node_database "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/config/prisma.ts"
click node_response "https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/utils/response.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_router,node_landing,node_authui,node_workspaces,node_apiclient,node_authhook,node_authapi toneBlue
class node_authroutes,node_authlogic,node_access toneAmber
class node_exercises,node_grading,node_attempts,node_paths,node_skills toneMint
class node_admin,node_classes,node_assignments toneRose
class node_server,node_ai,node_analytics,node_notifications,node_database,node_response,node_learner toneIndigo
```

## Components

### Web client

- [Role-based routes](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/app/router.tsx): `client/src/app/router.tsx`
- [Landing experience](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/features/landing/LandingPage.tsx): `client/src/features/landing/LandingPage.tsx`
- [Login and registration](https://github.com/nguyenlephianh56/englishaiweb/tree/main/client/src/features/auth): `client/src/features/auth`
- [Role workspaces](https://github.com/nguyenlephianh56/englishaiweb/tree/main/client/src/features): `client/src/features`
- [API client](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/api/client.ts): `client/src/api/client.ts`
- [Session hook](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/hooks/useAuth.ts): `client/src/hooks/useAuth.ts`
- [Auth API](https://github.com/nguyenlephianh56/englishaiweb/blob/main/client/src/api/auth.ts): `client/src/api/auth.ts`

### Identity and access

- [Auth endpoints](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/auth/auth.routes.ts): `server/src/modules/auth/auth.routes.ts`
- [Account and session logic](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/auth/auth.service.ts): `server/src/modules/auth/auth.service.ts`
- [Authentication and roles](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/middlewares/auth.ts): `server/src/middlewares/auth.ts`

### Learning workflow

- [Exercise library](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/exercises/exercises.service.ts): `server/src/modules/exercises/exercises.service.ts`
- [Exercise grading](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/grading/grading.service.ts): `server/src/modules/grading/grading.service.ts`
- [Student attempts](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/attempts/attempts.controller.ts): `server/src/modules/attempts/attempts.controller.ts`
- [Learning paths](https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/learning-paths): `server/src/modules/learning-paths`
- [Skill profiles](https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/skill-profiles): `server/src/modules/skill-profiles`

### Classroom operations

- [Admin management](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/admin/admin.controller.ts): `server/src/modules/admin/admin.controller.ts`
- [Class management](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/classes/classes.controller.ts): `server/src/modules/classes/classes.controller.ts`
- [Assignments](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/modules/assignments/assignments.service.ts): `server/src/modules/assignments/assignments.service.ts`

### Platform services

- [HTTP API](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/app.ts): `server/src/app.ts`
- [AI generation and analysis](https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/ai): `server/src/ai`
- [Analytics and reports](https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/analytics): `server/src/modules/analytics`
- [Notifications and reminders](https://github.com/nguyenlephianh56/englishaiweb/tree/main/server/src/modules/notifications): `server/src/modules/notifications`
- [PostgreSQL data](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/config/prisma.ts): `server/src/config/prisma.ts`
- [API response format](https://github.com/nguyenlephianh56/englishaiweb/blob/main/server/src/utils/response.ts): `server/src/utils/response.ts`

### Other components

- **Learners and staff**

## Connections

- Learners and staff → Role-based routes: opens (evidence: `client/src/app/router.tsx`)
- Role-based routes → Landing experience: routes to (evidence: `client/src/app/router.tsx`)
- Role-based routes → Login and registration: routes to (evidence: `client/src/app/router.tsx`)
- Role-based routes → Role workspaces: routes by role (evidence: `client/src/app/router.tsx`)
- Session hook → Auth API: calls (evidence: `client/src/hooks/useAuth.ts`)
- Auth API → API client: uses (evidence: `client/src/api/auth.ts`)
- API client → HTTP API: sends API requests
- HTTP API → Auth endpoints: mounts (evidence: `server/src/app.ts`)
- HTTP API → Admin management: mounts admin routes (evidence: `server/src/app.ts`)
- HTTP API → Class management: mounts class routes (evidence: `server/src/app.ts`)
- HTTP API → Exercise library: mounts exercise routes (evidence: `server/src/app.ts`)
- HTTP API → Student attempts: mounts attempt routes (evidence: `server/src/app.ts`)
- HTTP API → Assignments: mounts assignment routes (evidence: `server/src/app.ts`)
- Auth endpoints → Account and session logic: dispatches (evidence: `server/src/modules/auth/auth.routes.ts`)
- Account and session logic → PostgreSQL data: reads and writes (evidence: `server/src/modules/auth/auth.service.ts`)
- Account and session logic → Authentication and roles: issues JWT
- Authentication and roles → PostgreSQL data: looks up user (evidence: `server/src/middlewares/auth.ts`)
- Admin management → PostgreSQL data: manages users
- Class management → PostgreSQL data: manages classes
- Exercise library → PostgreSQL data: stores exercises
- Student attempts → PostgreSQL data: stores attempts
- Assignments → PostgreSQL data: stores assignments
- Student attempts → Exercise grading: grades submissions
- Exercise library → AI generation and analysis: may use AI
- Learning paths → AI generation and analysis: may personalize with AI
- Skill profiles → Analytics and reports: informs insights
- Analytics and reports → PostgreSQL data: reads learning data
- Notifications and reminders → PostgreSQL data: reads notification data
- HTTP API → API response format: uses response helpers
