# affan-devs/capstone-project architecture

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

- Interactive diagram: https://gitdiagram.com/affan-devs/capstone-project
- Repository: https://github.com/affan-devs/capstone-project

## Overview

This is a NestJS backend for a lesson-booking marketplace, with learner/instructor accounts, bookings, instruction records, communications, administration, and payment processing. The primary evidenced flow is authenticated HTTP requests into feature controllers and services, with services accessing Prisma persistence; authentication also issues tokens and notifications, while refund orchestration resolves payment attempts and invokes refund-state handling. The README is an untouched NestJS starter description, so product capabilities are inferred from the source tree. Edges are limited to relationships shown in supplied excerpts or SOURCE INDEX references; unsampled internals are represented conservatively.

Main entry points: [`src/auth/auth.service.ts`](https://github.com/affan-devs/capstone-project/blob/main/src/auth/auth.service.ts) (User authentication), [`src/prisma/prisma.service.ts`](https://github.com/affan-devs/capstone-project/blob/main/src/prisma/prisma.service.ts) (Relational persistence), [`src/payments/charges/refund-execution-orchestration.service.ts`](https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/refund-execution-orchestration.service.ts) (Refund orchestration), [`src/instructors/upload.controller.ts`](https://github.com/affan-devs/capstone-project/blob/main/src/instructors/upload.controller.ts) (Document uploads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and access"]
  node_auth["User authentication<br/>[auth.service.ts]"]
  node_login_throttle["Login throttling"]
  node_admin_auth["Admin authentication"]
  node_access_guards["JWT and role guards"]
  node_current_user["Current-user decorator"]
  node_roles_metadata["Role metadata<br/>[roles.decorator.ts]"]
end

subgraph group_marketplace["Lesson marketplace"]
  node_users["Learners and profiles<br/>[users.service.ts]"]
  node_instructors["Instructor profiles"]
  node_document_upload["Document uploads"]
  node_bookings["Lesson bookings"]
  node_cancellations["Cancellation slots"]
  node_chat["Learner-instructor chat<br/>[chat.service.ts]"]
  node_learning_records["Learning records"]
  node_lesson_summaries["Lesson summaries"]
  node_progress["Learner progress"]
  node_reviews["Reviews<br/>[reviews.service.ts]"]
  node_admin["Admin operations<br/>[admin.service.ts]"]
end

subgraph group_payments["Payments and finance"]
  node_refunds["Refund orchestration"]
  node_refund_state["Refund attempt state"]
  node_payment_attempts["Payment attempt resolution"]
  node_student_payments["Student payments"]
  node_payment_webhooks["Stripe webhooks"]
  node_disputes["Payment disputes"]
  node_instructor_payouts["Instructor payment accounts"]
end

subgraph group_platform["Shared platform"]
  node_notifications["Notifications"]
  node_email["Email delivery<br/>[email.service.ts]"]
  node_redaction["Document redaction<br/>[redaction.utils.ts]"]
  node_logging["Logging utilities<br/>[logging.utils.ts]"]
  node_database[("Relational persistence<br/>[prisma.service.ts]")]
  node_supabase["Supabase storage"]
end

node_actor(("API client"))
node_stripe["Stripe"]

node_actor -->|"authenticates via"| node_auth
node_auth -->|"reads and writes"| node_database
node_auth -->|"checks throttling"| node_login_throttle
node_auth -->|"sends email"| node_email
node_auth -->|"publishes events"| node_notifications
node_actor -->|"authenticates via"| node_admin_auth
node_admin_auth -->|"reads and writes"| node_database
node_admin_auth -->|"checks throttling"| node_login_throttle
node_actor -->|"requests lessons"| node_bookings
node_actor -->|"sends messages"| node_chat
node_actor -->|"manages profile"| node_instructors
node_document_upload -->|"reads and writes"| node_database
node_document_upload -->|"stores documents"| node_supabase
node_document_upload -->|"sanitizes names"| node_redaction
node_actor -->|"manages marketplace"| node_admin
node_admin -->|"redacts documents"| node_redaction
node_actor -->|"manages payment setup"| node_student_payments
node_refunds -->|"resolves payment"| node_payment_attempts
node_refunds -->|"updates attempt state"| node_refund_state
node_refunds -->|"reads booking"| node_database
node_refunds -->|"publishes refund events"| node_notifications
node_reviews -->|"reads and writes"| node_database
node_reviews -->|"redacts content"| node_redaction
node_access_guards -->|"checks role metadata"| node_roles_metadata
node_actor -.->|"uses learning features"| node_learning_records
node_actor -.->|"uses learning features"| node_lesson_summaries
node_actor -.->|"tracks progress"| node_progress
node_actor -.->|"manages availability"| node_cancellations
node_actor -.->|"pays for lessons"| node_student_payments
node_payment_webhooks -.->|"receives events"| node_stripe
node_disputes -.->|"handles disputes"| node_stripe
node_instructor_payouts -.->|"connects accounts"| node_stripe

click node_users "https://github.com/affan-devs/capstone-project/blob/main/src/users/users.service.ts"
click node_instructors "https://github.com/affan-devs/capstone-project/blob/main/src/instructors/instructors.service.ts"
click node_document_upload "https://github.com/affan-devs/capstone-project/blob/main/src/instructors/upload.controller.ts"
click node_bookings "https://github.com/affan-devs/capstone-project/blob/main/src/bookings/bookings.service.ts"
click node_cancellations "https://github.com/affan-devs/capstone-project/tree/main/src/cancellation-slots"
click node_chat "https://github.com/affan-devs/capstone-project/blob/main/src/chat/chat.service.ts"
click node_learning_records "https://github.com/affan-devs/capstone-project/tree/main/src/learner-records"
click node_lesson_summaries "https://github.com/affan-devs/capstone-project/tree/main/src/lesson-summaries"
click node_progress "https://github.com/affan-devs/capstone-project/tree/main/src/progress"
click node_reviews "https://github.com/affan-devs/capstone-project/blob/main/src/reviews/reviews.service.ts"
click node_auth "https://github.com/affan-devs/capstone-project/blob/main/src/auth/auth.service.ts"
click node_login_throttle "https://github.com/affan-devs/capstone-project/blob/main/src/auth/account-login-throttle.service.ts"
click node_admin_auth "https://github.com/affan-devs/capstone-project/blob/main/src/admin-auth/admin-auth.service.ts"
click node_access_guards "https://github.com/affan-devs/capstone-project/tree/main/src/common/guards"
click node_current_user "https://github.com/affan-devs/capstone-project/blob/main/src/common/decorators/current-user.decorator.ts"
click node_roles_metadata "https://github.com/affan-devs/capstone-project/blob/main/src/common/decorators/roles.decorator.ts"
click node_admin "https://github.com/affan-devs/capstone-project/blob/main/src/admin/admin.service.ts"
click node_refunds "https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/refund-execution-orchestration.service.ts"
click node_refund_state "https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/refund-attempt-state.service.ts"
click node_payment_attempts "https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/booking-charge-payment-attempt-resolver.service.ts"
click node_student_payments "https://github.com/affan-devs/capstone-project/tree/main/src/payments/student"
click node_payment_webhooks "https://github.com/affan-devs/capstone-project/tree/main/src/payments/webhooks"
click node_disputes "https://github.com/affan-devs/capstone-project/tree/main/src/payments/disputes"
click node_instructor_payouts "https://github.com/affan-devs/capstone-project/tree/main/src/payments/connect"
click node_notifications "https://github.com/affan-devs/capstone-project/blob/main/src/notifications/notification-publisher.ts"
click node_email "https://github.com/affan-devs/capstone-project/blob/main/src/common/email.service.ts"
click node_redaction "https://github.com/affan-devs/capstone-project/blob/main/src/instructors/redaction.utils.ts"
click node_logging "https://github.com/affan-devs/capstone-project/blob/main/src/common/utils/logging.utils.ts"
click node_database "https://github.com/affan-devs/capstone-project/blob/main/src/prisma/prisma.service.ts"
click node_supabase "https://github.com/affan-devs/capstone-project/blob/main/src/common/supabase/supabase.service.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_auth,node_login_throttle,node_admin_auth,node_access_guards,node_current_user,node_roles_metadata,node_actor toneBlue
class node_users,node_instructors,node_document_upload,node_bookings,node_cancellations,node_chat,node_learning_records,node_lesson_summaries,node_progress,node_reviews,node_admin toneAmber
class node_refunds,node_refund_state,node_payment_attempts,node_student_payments,node_payment_webhooks,node_disputes,node_instructor_payouts toneMint
class node_notifications,node_email,node_redaction,node_logging,node_database,node_supabase toneRose
class node_stripe toneIndigo
```

## Components

### Identity and access

- [User authentication](https://github.com/affan-devs/capstone-project/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Login throttling](https://github.com/affan-devs/capstone-project/blob/main/src/auth/account-login-throttle.service.ts): `src/auth/account-login-throttle.service.ts`
- [Admin authentication](https://github.com/affan-devs/capstone-project/blob/main/src/admin-auth/admin-auth.service.ts): `src/admin-auth/admin-auth.service.ts`
- [JWT and role guards](https://github.com/affan-devs/capstone-project/tree/main/src/common/guards): `src/common/guards`
- [Current-user decorator](https://github.com/affan-devs/capstone-project/blob/main/src/common/decorators/current-user.decorator.ts): `src/common/decorators/current-user.decorator.ts`
- [Role metadata](https://github.com/affan-devs/capstone-project/blob/main/src/common/decorators/roles.decorator.ts): `src/common/decorators/roles.decorator.ts`

### Lesson marketplace

- [Learners and profiles](https://github.com/affan-devs/capstone-project/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [Instructor profiles](https://github.com/affan-devs/capstone-project/blob/main/src/instructors/instructors.service.ts): `src/instructors/instructors.service.ts`
- [Document uploads](https://github.com/affan-devs/capstone-project/blob/main/src/instructors/upload.controller.ts): `src/instructors/upload.controller.ts`
- [Lesson bookings](https://github.com/affan-devs/capstone-project/blob/main/src/bookings/bookings.service.ts): `src/bookings/bookings.service.ts`
- [Cancellation slots](https://github.com/affan-devs/capstone-project/tree/main/src/cancellation-slots): `src/cancellation-slots`
- [Learner-instructor chat](https://github.com/affan-devs/capstone-project/blob/main/src/chat/chat.service.ts): `src/chat/chat.service.ts`
- [Learning records](https://github.com/affan-devs/capstone-project/tree/main/src/learner-records): `src/learner-records`
- [Lesson summaries](https://github.com/affan-devs/capstone-project/tree/main/src/lesson-summaries): `src/lesson-summaries`
- [Learner progress](https://github.com/affan-devs/capstone-project/tree/main/src/progress): `src/progress`
- [Reviews](https://github.com/affan-devs/capstone-project/blob/main/src/reviews/reviews.service.ts): `src/reviews/reviews.service.ts`
- [Admin operations](https://github.com/affan-devs/capstone-project/blob/main/src/admin/admin.service.ts): `src/admin/admin.service.ts`

### Payments and finance

- [Refund orchestration](https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/refund-execution-orchestration.service.ts): `src/payments/charges/refund-execution-orchestration.service.ts`
- [Refund attempt state](https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/refund-attempt-state.service.ts): `src/payments/charges/refund-attempt-state.service.ts`
- [Payment attempt resolution](https://github.com/affan-devs/capstone-project/blob/main/src/payments/charges/booking-charge-payment-attempt-resolver.service.ts): `src/payments/charges/booking-charge-payment-attempt-resolver.service.ts`
- [Student payments](https://github.com/affan-devs/capstone-project/tree/main/src/payments/student): `src/payments/student`
- [Stripe webhooks](https://github.com/affan-devs/capstone-project/tree/main/src/payments/webhooks): `src/payments/webhooks`
- [Payment disputes](https://github.com/affan-devs/capstone-project/tree/main/src/payments/disputes): `src/payments/disputes`
- [Instructor payment accounts](https://github.com/affan-devs/capstone-project/tree/main/src/payments/connect): `src/payments/connect`

### Shared platform

- [Notifications](https://github.com/affan-devs/capstone-project/blob/main/src/notifications/notification-publisher.ts): `src/notifications/notification-publisher.ts`
- [Email delivery](https://github.com/affan-devs/capstone-project/blob/main/src/common/email.service.ts): `src/common/email.service.ts`
- [Document redaction](https://github.com/affan-devs/capstone-project/blob/main/src/instructors/redaction.utils.ts): `src/instructors/redaction.utils.ts`
- [Logging utilities](https://github.com/affan-devs/capstone-project/blob/main/src/common/utils/logging.utils.ts): `src/common/utils/logging.utils.ts`
- [Relational persistence](https://github.com/affan-devs/capstone-project/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`
- [Supabase storage](https://github.com/affan-devs/capstone-project/blob/main/src/common/supabase/supabase.service.ts): `src/common/supabase/supabase.service.ts`

### Other components

- **API client**
- **Stripe**

## Connections

- API client → User authentication: authenticates via
- User authentication → Relational persistence: reads and writes (evidence: `src/auth/auth.service.ts`)
- User authentication → Login throttling: checks throttling (evidence: `src/auth/auth.service.ts`)
- User authentication → Email delivery: sends email (evidence: `src/auth/auth.service.ts`)
- User authentication → Notifications: publishes events (evidence: `src/auth/auth.service.ts`)
- API client → Admin authentication: authenticates via
- Admin authentication → Relational persistence: reads and writes (evidence: `src/admin-auth/admin-auth.service.ts`)
- Admin authentication → Login throttling: checks throttling (evidence: `src/admin-auth/admin-auth.service.ts`)
- API client → Lesson bookings: requests lessons
- API client → Learner-instructor chat: sends messages
- API client → Instructor profiles: manages profile
- Document uploads → Relational persistence: reads and writes (evidence: `src/instructors/upload.controller.ts`)
- Document uploads → Supabase storage: stores documents (evidence: `src/instructors/upload.controller.ts`)
- Document uploads → Document redaction: sanitizes names (evidence: `src/instructors/upload.controller.ts`)
- API client → Admin operations: manages marketplace
- Admin operations → Document redaction: redacts documents (evidence: `src/admin/admin.controller.ts`)
- API client → Student payments: manages payment setup (evidence: `src/payments/student/student-payments.controller.ts`)
- Refund orchestration → Payment attempt resolution: resolves payment (evidence: `src/payments/charges/refund-execution-orchestration.service.ts`)
- Refund orchestration → Refund attempt state: updates attempt state (evidence: `src/payments/charges/refund-execution-orchestration.service.ts`)
- Refund orchestration → Relational persistence: reads booking (evidence: `src/payments/charges/refund-execution-orchestration.service.ts`)
- Refund orchestration → Notifications: publishes refund events (evidence: `src/payments/charges/refund-execution-orchestration.service.ts`)
- Reviews → Relational persistence: reads and writes (evidence: `src/reviews/reviews.service.ts`)
- Reviews → Document redaction: redacts content (evidence: `src/reviews/reviews.service.ts`)
- JWT and role guards → Role metadata: checks role metadata (evidence: `src/common/guards/roles.guard.ts`)
- API client → Learning records: uses learning features
- API client → Lesson summaries: uses learning features
- API client → Learner progress: tracks progress
- API client → Cancellation slots: manages availability
- API client → Student payments: pays for lessons
- Stripe webhooks → Stripe: receives events
- Payment disputes → Stripe: handles disputes
- Instructor payment accounts → Stripe: connects accounts
