# asha0ahmed/study-squad-duchbag architecture

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

- Interactive diagram: https://gitdiagram.com/asha0ahmed/study-squad-duchbag
- Repository: https://github.com/asha0ahmed/study-squad-duchbag

## Overview

Study Squad is a student-and-mentor squad learning platform: students register and profile their subjects, join matched or invited squads, then use squad learning tools; mentors manage tasks and students submit work. The frontend centralizes HTTP calls in `frontend/lib/api.ts`; the Express backend owns domain routes and PostgreSQL access. The README and sampled source establish the API, matching, chat, payments/subscriptions, complaints, admin, uploads, and password-reset capabilities. The 120 KB backend server excerpt is partial, so unsampled route-level relationships are not expanded.

Main entry points: [`frontend/lib/api.ts`](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/lib/api.ts) (API client), [`backend/server.js`](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/server.js) (Express API), [`backend/db.js`](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/db.js) (PostgreSQL pool), [`backend/middleware/auth.js`](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/middleware/auth.js) (Request authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Student and mentor experience"]
  node_students["Student screens<br/>[page.tsx]"]
  node_mentor_auth["Mentor screens<br/>[page.tsx]"]
  node_profiler["Student profiler<br/>[page.tsx]"]
  node_mentor_desk["Mentor desk<br/>[MentorDesk.tsx]"]
  node_complaint_screens["Complaints<br/>[page.tsx]"]
end

subgraph group_squad["Squad learning"]
  node_squad_screens["Squad screens<br/>[page.tsx]"]
  node_chat_screens["Squad chat<br/>[page.tsx]"]
  node_tasks_screens["Task workflows<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_admin_screens["Admin console<br/>[page.tsx]"]
end

subgraph group_backend["Backend services"]
  node_api["API client<br/>[api.ts]"]
  node_server["Express API<br/>[server.js]"]
  node_auth["Request authentication<br/>[auth.js]"]
  node_matching["Squad matching<br/>[matching.js]"]
  node_uploads["Upload validation<br/>[upload.js]"]
  node_mailer["Password reset mail<br/>[mailer.js]"]
end

subgraph group_storage["Persistence and integrations"]
  node_db[("PostgreSQL pool<br/>[db.js]")]
  node_cloudinary["File storage<br/>[cloudinary.js]"]
end

node_smtp{{"SMTP provider"}}
node_postgres[("PostgreSQL")]

node_students -->|"uses"| node_api
node_mentor_auth -->|"uses"| node_api
node_profiler -->|"uses"| node_api
node_squad_screens -->|"uses"| node_api
node_chat_screens -->|"uses"| node_api
node_tasks_screens -->|"uses"| node_api
node_mentor_desk -->|"uses"| node_api
node_complaint_screens -->|"uses"| node_api
node_admin_screens -->|"uses"| node_api
node_api -->|"sends requests"| node_server
node_server -->|"queries"| node_db
node_auth -->|"checks accounts"| node_db
node_server -->|"guards routes"| node_auth
node_server -->|"runs matching"| node_matching
node_server -->|"validates uploads"| node_uploads
node_server -->|"stores files"| node_cloudinary
node_server -->|"sends reset mail"| node_mailer
node_mailer -->|"sends email"| node_smtp
node_db -->|"connects"| node_postgres

click node_students "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/auth/student/signup/page.tsx"
click node_mentor_auth "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/auth/mentor/signup/page.tsx"
click node_profiler "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/profiler/page.tsx"
click node_api "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/lib/api.ts"
click node_squad_screens "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/squad/page.tsx"
click node_chat_screens "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/admin/squads/chat/page.tsx"
click node_tasks_screens "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/tasks/page.tsx"
click node_mentor_desk "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/components/desk/MentorDesk.tsx"
click node_complaint_screens "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/complaints/page.tsx"
click node_admin_screens "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/admin/page.tsx"
click node_server "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/server.js"
click node_auth "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/middleware/auth.js"
click node_matching "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/matching.js"
click node_uploads "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/middleware/upload.js"
click node_mailer "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/mailer.js"
click node_db "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/db.js"
click node_cloudinary "https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/cloudinary.js"

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_students,node_mentor_auth,node_profiler,node_mentor_desk,node_complaint_screens toneBlue
class node_squad_screens,node_chat_screens,node_tasks_screens,node_postgres toneAmber
class node_admin_screens toneMint
class node_api,node_server,node_auth,node_matching,node_uploads,node_mailer toneRose
class node_db,node_cloudinary,node_smtp toneIndigo
```

## Components

### Student and mentor experience

- [Student screens](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/auth/student/signup/page.tsx): `frontend/app/auth/student/signup/page.tsx`
- [Mentor screens](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/auth/mentor/signup/page.tsx): `frontend/app/auth/mentor/signup/page.tsx`
- [Student profiler](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/profiler/page.tsx): `frontend/app/profiler/page.tsx`
- [Mentor desk](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/components/desk/MentorDesk.tsx): `frontend/components/desk/MentorDesk.tsx`
- [Complaints](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/complaints/page.tsx): `frontend/app/complaints/page.tsx`

### Squad learning

- [Squad screens](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/squad/page.tsx): `frontend/app/squad/page.tsx`
- [Squad chat](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/admin/squads/chat/page.tsx): `frontend/app/admin/squads/chat/page.tsx`
- [Task workflows](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/tasks/page.tsx): `frontend/app/tasks/page.tsx`

### Administration

- [Admin console](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/app/admin/page.tsx): `frontend/app/admin/page.tsx`

### Backend services

- [API client](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Express API](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/server.js): `backend/server.js`
- [Request authentication](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Squad matching](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/matching.js): `backend/utils/matching.js`
- [Upload validation](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/middleware/upload.js): `backend/middleware/upload.js`
- [Password reset mail](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/mailer.js): `backend/utils/mailer.js`

### Persistence and integrations

- [PostgreSQL pool](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/db.js): `backend/db.js`
- [File storage](https://github.com/asha0ahmed/study-squad-duchbag/blob/main/backend/utils/cloudinary.js): `backend/utils/cloudinary.js`

### Other components

- **SMTP provider**
- **PostgreSQL**

## Connections

- Student screens → API client: uses (evidence: `frontend/lib/api.ts`)
- Mentor screens → API client: uses (evidence: `frontend/lib/api.ts`)
- Student profiler → API client: uses (evidence: `frontend/lib/api.ts`)
- Squad screens → API client: uses (evidence: `frontend/lib/api.ts`)
- Squad chat → API client: uses (evidence: `frontend/lib/api.ts`)
- Task workflows → API client: uses (evidence: `frontend/lib/api.ts`)
- Mentor desk → API client: uses (evidence: `frontend/lib/api.ts`)
- Complaints → API client: uses (evidence: `frontend/lib/api.ts`)
- Admin console → API client: uses (evidence: `frontend/lib/api.ts`)
- API client → Express API: sends requests (evidence: `frontend/lib/api.ts`)
- Express API → PostgreSQL pool: queries (evidence: `backend/server.js`)
- Request authentication → PostgreSQL pool: checks accounts (evidence: `backend/middleware/auth.js`)
- Express API → Request authentication: guards routes (evidence: `backend/server.js`)
- Express API → Squad matching: runs matching (evidence: `backend/server.js`)
- Express API → Upload validation: validates uploads (evidence: `backend/server.js`)
- Express API → File storage: stores files (evidence: `backend/server.js`)
- Express API → Password reset mail: sends reset mail (evidence: `backend/server.js`)
- Password reset mail → SMTP provider: sends email (evidence: `backend/utils/mailer.js`)
- PostgreSQL pool → PostgreSQL: connects (evidence: `backend/db.js`)
