# reduanahmadswe/assignment016 architecture

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

- Interactive diagram: https://gitdiagram.com/reduanahmadswe/assignment016
- Repository: https://github.com/reduanahmadswe/assignment016

## Overview

1. This is a two-app monorepo: a TypeScript backend under `backend/` and a Next.js frontend under `frontend/`. The frontend is the user-facing presentation layer, while the backend is the API and business-logic layer. They are developed and deployed separately but share the same domain model.

2. The backend is structured as a classic modular HTTP service: `routes -> middleware -> controller -> service -> Prisma/database -> transformer/response`. Each domain area has its own module folder, which keeps the architecture bounded by business capability rather than by technical layer alone.

3. The main backend domains are `auth`, `users`, `events`, `courses`, `blogs`, `newsletters`, `payments`, `reviews`, `opportunities`, `certificates`, `contact`, `hosts`, and `admin`. This indicates the product is a content-and-program platform, not a single-purpose app: it supports public content, event registration, course delivery, newsletter campaigns, and administrative operations.

4. Authentication and authorization are central cross-cutting concerns. The backend has dedicated middleware for auth, roles, licenses, course ownership, rate limiting, and request validation. The auth module includes Google sign-in, email-based flows, JWT utilities, OTP/two-factor support, and email helpers, so access control is role-aware and security-sensitive.

5. The backend persistence layer is Prisma-based, with a substantial migration history and seed data for blogs, courses, events, opportunities, newsletters, and subscribers. That suggests a relational data model with fairly rich entity relationships. There is also legacy or auxiliary SQL/migration support in `src/database`, but Prisma is the primary schema-management path.

6. Several background jobs run on the backend via cron modules: event reminders, event status changes, newsletter distribution, OTP cleanup, payment cleanup, post-event review handling, and license checks. These jobs operate on the same database and email infrastructure as the request/response API, so time-based automation is an important part of the system architecture.

7. External integrations materially shape the backend: Cloudinary for media/assets, Google Drive for token-based file access, Gmail/email utilities for notifications, and PDF generation for certificates. The repo also contains a SingleStore certificate bundle, implying the backend connects to a managed SQL database service with custom TLS requirements.

8. The frontend is a large Next.js App Router application with distinct public, authenticated user, teacher, and admin surfaces. Route groups like `/admin`, `/teacher`, `/dashboard`, `/courses`, `/events`, `/blog`, `/newsletter`, `/certificates`, and `/auth/google/callback` show that the UI is organized around the same business domains as the backend.

9. Frontend data access is centralized through `src/lib/api.ts`, `services/`, and feature-specific helpers such as course-detail, lecture-preview, slug utilities, and rich-text utilities. Global client state is minimal but important: Redux is used for auth/session state, while custom hooks handle auth and course-builder autosave.

10. Content editing is a major subsystem on the frontend. The app includes a custom Lexical-based rich text editor with many custom nodes and plugins, used in admin/teacher forms for blogs, events, newsletters, opportunities, and courses. This means content authoring is not a simple form workflow; it is a first-class application capability.

11. The course and event flows are particularly important to the product. Courses include public browsing, checkout, learning pages, builder pages, student management, payments, and coupons. Events include public listing, registration, attendance, email templates, meeting-link handling, and certificates. The README’s demo event payload matches this workflow: an admin creates an event with speakers, hybrid meeting details, pricing, capacity, and certificate settings.

12. Operationally, the repo is prepared for independent deployment pipelines. There is a GitHub Actions deployment workflow, plus PM2/ecosystem configs and Vercel configuration files. That suggests the frontend and backend can be hosted in different runtimes, with the backend also supporting Node process management and scheduled tasks.

Main entry points: [`backend/src/modules`](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules) (Domain modules), [`backend/src/cron`](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/cron) (Cron jobs), [`frontend/src/app`](https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app) (Next app), [`frontend/src/lib/api.ts`](https://github.com/reduanahmadswe/assignment016/blob/main/frontend/src/lib/api.ts) (API layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monorepo["Monorepo"]
end

subgraph group_backend["Backend"]
  node_backend_app["Server entry<br/>runtime entry<br/>[server.ts]"]
  node_backend_routes["Route map<br/>routing layer<br/>[routes.ts]"]
  node_backend_middleware["Middleware<br/>cross-cutting"]
  node_backend_domain["Domain modules<br/>feature modules"]
  node_backend_auth["Auth<br/>identity module"]
  node_backend_courses["Courses<br/>learning module"]
  node_backend_events["Events<br/>event module"]
  node_backend_content["Content"]
  node_backend_admin["Admin"]
  node_backend_payments["Payments<br/>commerce module"]
  node_backend_certificates["Certificates<br/>credential module"]
  node_backend_persistence[("Prisma DB<br/>persistence")]
  node_backend_cron["Cron jobs<br/>scheduled jobs"]
  node_backend_integrations["Integrations<br/>external services"]
end

subgraph group_frontend["Frontend"]
  node_frontend_app["Next app<br/>runtime entry"]
  node_frontend_public["Public UI<br/>public routes<br/>[page.tsx]"]
  node_frontend_authenticated["User areas<br/>authenticated routes"]
  node_frontend_admin_teacher["Admin/teacher<br/>privileged routes"]
  node_frontend_editor["Rich editor<br/>authoring subsystem"]
  node_frontend_data["API layer<br/>data access<br/>[api.ts]"]
end

node_backend_app -->|"serves"| node_backend_routes
node_backend_app -->|"starts"| node_backend_cron
node_backend_routes -->|"applies"| node_backend_middleware
node_backend_routes -->|"dispatches"| node_backend_domain
node_backend_domain -->|"includes"| node_backend_auth
node_backend_domain -->|"includes"| node_backend_courses
node_backend_domain -->|"includes"| node_backend_events
node_backend_domain -->|"includes"| node_backend_content
node_backend_domain -->|"includes"| node_backend_admin
node_backend_domain -->|"includes"| node_backend_payments
node_backend_domain -->|"includes"| node_backend_certificates
node_backend_domain -->|"persists to"| node_backend_persistence
node_backend_domain -->|"uses"| node_backend_integrations
node_backend_cron -->|"updates"| node_backend_events
node_backend_cron -->|"distributes"| node_backend_content
node_backend_cron -->|"maintains"| node_backend_auth
node_backend_cron -->|"cleans up"| node_backend_payments
node_backend_cron -->|"reads/writes"| node_backend_persistence
node_frontend_app -->|"renders"| node_frontend_public
node_frontend_app -->|"renders"| node_frontend_authenticated
node_frontend_app -->|"renders"| node_frontend_admin_teacher
node_frontend_app -->|"uses"| node_frontend_editor
node_frontend_app -->|"fetches through"| node_frontend_data
node_frontend_data -->|"calls API"| node_backend_routes
node_frontend_editor -->|"supports"| node_frontend_admin_teacher
node_frontend_public -->|"reads data"| node_frontend_data
node_frontend_authenticated -->|"reads data"| node_frontend_data
node_frontend_admin_teacher -->|"reads data"| node_frontend_data
node_backend_auth -->|"emails/signs in"| node_backend_integrations
node_backend_certificates -->|"generates files"| node_backend_integrations

click node_backend_app "https://github.com/reduanahmadswe/assignment016/blob/main/backend/src/server.ts"
click node_backend_routes "https://github.com/reduanahmadswe/assignment016/blob/main/backend/src/routes.ts"
click node_backend_middleware "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/middlewares"
click node_backend_domain "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules"
click node_backend_auth "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/auth"
click node_backend_courses "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/courses"
click node_backend_events "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/events"
click node_backend_content "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/blogs"
click node_backend_admin "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/admin"
click node_backend_payments "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/payments"
click node_backend_certificates "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/certificates"
click node_backend_persistence "https://github.com/reduanahmadswe/assignment016/tree/main/backend/prisma"
click node_backend_cron "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/cron"
click node_backend_integrations "https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/services"
click node_frontend_app "https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app"
click node_frontend_public "https://github.com/reduanahmadswe/assignment016/blob/main/frontend/src/app/page.tsx"
click node_frontend_authenticated "https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app/dashboard"
click node_frontend_admin_teacher "https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app/admin"
click node_frontend_editor "https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/components/ui/LexicalEditor"
click node_frontend_data "https://github.com/reduanahmadswe/assignment016/blob/main/frontend/src/lib/api.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_backend_app,node_backend_routes,node_backend_middleware,node_backend_domain,node_backend_auth,node_backend_courses,node_backend_events,node_backend_content,node_backend_admin,node_backend_payments,node_backend_certificates,node_backend_persistence,node_backend_cron,node_backend_integrations toneAmber
class node_frontend_app,node_frontend_public,node_frontend_authenticated,node_frontend_admin_teacher,node_frontend_editor,node_frontend_data toneMint
```

## Components

### Backend

TypeScript HTTP API, business logic, persistence, jobs, and integrations.

- [Server entry](https://github.com/reduanahmadswe/assignment016/blob/main/backend/src/server.ts): runtime entry · Bootstraps the API server and wires app, routes, and cron jobs. · `backend/src/server.ts`
- [Route map](https://github.com/reduanahmadswe/assignment016/blob/main/backend/src/routes.ts): routing layer · Central route composition and smaller diagnostic/test route sets. · `backend/src/routes.ts`
- [Middleware](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/middlewares): cross-cutting · Auth, role, course, license, validation, rate limiting, and error handling. · `backend/src/middlewares`
- [Domain modules](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules): feature modules · Capability-based backend modules for auth, users, content, commerce, certificates, and admin flows. · `backend/src/modules`
- [Auth](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/auth): identity module · Google sign-in, email flows, JWT, OTP/two-factor, and auth helpers. · `backend/src/modules/auth`
- [Courses](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/courses): learning module · Course catalog, builders, student management, coupons, and course lifecycle logic. · `backend/src/modules/courses`
- [Events](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/events): event module · Event publishing, registration, attendance, email templates, and status workflows. · `backend/src/modules/events`
- [Content](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/blogs): content modules · Blogs, newsletters, opportunities, reviews, and contact intake. · `backend/src/modules/blogs`
- [Admin](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/admin): admin module · Administrative dashboards, stats, exports, and management endpoints. · `backend/src/modules/admin`
- [Payments](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/payments): commerce module · Payment handling, manual methods, and payment notification flows. · `backend/src/modules/payments`
- [Certificates](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/modules/certificates): credential module · Certificate issuance, verification, and PDF generation. · `backend/src/modules/certificates`
- [Prisma DB](https://github.com/reduanahmadswe/assignment016/tree/main/backend/prisma): persistence · Primary relational schema, migrations, seeds, and database access configuration. · `backend/prisma`
- [Cron jobs](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/cron): scheduled jobs · Event reminders, status changes, newsletter distribution, cleanup, and license checks. · `backend/src/cron`
- [Integrations](https://github.com/reduanahmadswe/assignment016/tree/main/backend/src/services): external services · Cloudinary, Gmail/email, Google Drive, PDF generation, and managed SQL TLS assets. · `backend/src/services`

### Frontend

Next.js App Router UI with public, authenticated, teacher, and admin surfaces.

- [Next app](https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app): runtime entry · Next.js App Router application serving public, dashboard, teacher, and admin experiences. · `frontend/src/app`
- [Public UI](https://github.com/reduanahmadswe/assignment016/blob/main/frontend/src/app/page.tsx): public routes · Marketing pages, blogs, courses, events, opportunities, contact, newsletter, and auth entry points. · `frontend/src/app/page.tsx`
- [User areas](https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app/dashboard): authenticated routes · Dashboard, my-courses, my-events, certificates, payments, profile, settings, and security. · `frontend/src/app/dashboard`
- [Admin/teacher](https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/app/admin): privileged routes · Administration and teacher workspaces for content and course management. · `frontend/src/app/admin`
- [Rich editor](https://github.com/reduanahmadswe/assignment016/tree/main/frontend/src/components/ui/LexicalEditor): authoring subsystem · Lexical-based editor with custom nodes and plugins used across content and course forms. · `frontend/src/components/ui/LexicalEditor`
- [API layer](https://github.com/reduanahmadswe/assignment016/blob/main/frontend/src/lib/api.ts): data access · Central API client, services, Redux auth state, and custom hooks. · `frontend/src/lib/api.ts`

## Connections

- Server entry → Route map: serves · The server boots the route graph.
- Server entry → Cron jobs: starts · Background jobs run alongside the API process.
- Route map → Middleware: applies · Routes are protected and validated by shared middleware.
- Route map → Domain modules: dispatches · Endpoint groups are routed into capability modules.
- Domain modules → Auth: includes · Identity and access flows are a core module.
- Domain modules → Courses: includes · Course management is a primary business area.
- Domain modules → Events: includes · Event lifecycle and registration are central.
- Domain modules → Content: includes · Content and communication modules share the same service layer.
- Domain modules → Admin: includes · Administrative operations live in their own module.
- Domain modules → Payments: includes · Payments coordinate commerce and notifications.
- Domain modules → Certificates: includes · Certificates are issued and verified from a dedicated module.
- Domain modules → Prisma DB: persists to · Domain services read and write the Prisma-backed database.
- Domain modules → Integrations: uses · Modules depend on mail, media, file, and PDF services.
- Cron jobs → Events: updates · Event reminders and status changes are scheduled.
- Cron jobs → Content: distributes · Newsletter and cleanup jobs operate on content data.
- Cron jobs → Auth: maintains · OTP cleanup and license checks support auth flows.
- Cron jobs → Payments: cleans up · Payment cleanup runs on a schedule.
- Cron jobs → Prisma DB: reads/writes · Jobs operate directly on the shared relational store.
- Next app → Public UI: renders · Public pages make up the main browsing surface.
- Next app → User areas: renders · Authenticated user dashboard areas are separate routes.
- Next app → Admin/teacher: renders · Privileged admin and teacher workspaces are route groups.
- Next app → Rich editor: uses · Content creation screens embed the custom editor.
- Next app → API layer: fetches through · UI state and data access are centralized.
- API layer → Route map: calls API · Frontend services consume the backend HTTP surface.
- Rich editor → Admin/teacher: supports · Rich authoring powers admin and teacher forms.
- Public UI → API layer: reads data · Public listings and detail pages load from shared services.
- User areas → API layer: reads data · Dashboard views use the same API layer and auth state.
- Admin/teacher → API layer: reads data · Management screens depend on shared API helpers and session state.
- Auth → Integrations: emails/signs in · Auth uses email delivery, Google sign-in, JWTs, and OTP helpers.
- Certificates → Integrations: generates files · Certificate PDFs and verification flows depend on external services.
