# aaryankacha/helpdesk-system architecture

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

- Interactive diagram: https://gitdiagram.com/aaryankacha/helpdesk-system
- Repository: https://github.com/aaryankacha/helpdesk-system

## Overview

#### Purpose and Topology
This is a monorepo foundation for a multi-tenant helpdesk platform. It currently provides user authentication, organization membership-aware access, and a protected organization API; ticketing is intentionally future work. The React client and Express API run independently against a shared PostgreSQL database.

- Root orchestration: `package.json`, `docker-compose.yml`
- Frontend application: `client/src/main.jsx`, `client/src/App.jsx`
- Backend process: `server/src/server.js`, `server/src/app.js`

#### Client Application
The browser client is a Vite React SPA styled with Tailwind. `App.jsx` is the application composition and route boundary, with separate login, registration, and dashboard screens. The dashboard is the authenticated product surface.

- Bootstrap and root rendering: `client/src/main.jsx`, `client/src/App.jsx`
- Auth-facing pages: `client/src/pages/LoginPage.jsx`, `client/src/pages/RegisterPage.jsx`
- Authenticated UI: `client/src/pages/DashboardPage.jsx`

#### Client Auth and API Boundary
`AuthContext` owns client-side authentication state and exposes it to pages/components. The API service centralizes requests to the backend using the configurable `VITE_API_URL`; it is the browser-to-server trust boundary where JWT-bearing requests are assembled.

- Auth state provider: `client/src/context/AuthContext.jsx`
- HTTP client/service layer: `client/src/services/api.js`
- Frontend environment contract: `client/.env.example`

#### Express API Composition
The server process builds an Express application with security and cross-origin concerns configured around API routes. Route aggregation establishes the `/api` surface, then domain route modules map HTTP endpoints to controllers. Central middleware handles authentication, request validation, and error translation.

- Application and listener: `server/src/app.js`, `server/src/server.js`
- Route root and modules: `server/src/routes/index.js`, `server/src/routes/authRoutes.js`, `server/src/routes/organizationRoutes.js`
- Cross-cutting middleware: `server/src/middleware/authMiddleware.js`, `server/src/middleware/errorMiddleware.js`, `server/src/middleware/validateMiddleware.js`

#### Authentication Flow
Registration and login requests enter auth routes, are checked against Zod-oriented validation definitions, then reach the auth controller/service layer. The service persists or verifies users through Prisma and issues JWTs. Protected requests, including `/api/auth/me`, pass through JWT middleware before controllers receive the authenticated principal.

- HTTP orchestration: `server/src/controllers/authController.js`, `server/src/routes/authRoutes.js`
- Credential/JWT domain logic: `server/src/services/authService.js`
- Validation and token enforcement: `server/src/validation/authValidation.js`, `server/src/middleware/authMiddleware.js`

#### Multi-Tenant Organization Access
Organizations are the current tenant boundary. Organization controllers delegate retrieval to a service, with protected routing ensuring callers are authenticated; membership and role-aware behavior are modeled in the database schema rather than in the UI alone. This is the natural attachment point for future tickets, permissions, and tenant-scoped dashboards.

- Organization API layer: `server/src/routes/organizationRoutes.js`, `server/src/controllers/organizationController.js`
- Tenant retrieval logic: `server/src/services/organizationService.js`
- Persistence model: `server/prisma/schema.prisma`

#### Persistence and Runtime Infrastructure
PostgreSQL is the sole durable store, accessed by the Node server through Prisma. Docker Compose provides local PostgreSQL, while Prisma schema and seed scripts define and initialize the development data model. Runtime configuration supplies database connectivity, JWT signing, API port, and permitted client origin.

- Database container: `docker-compose.yml`
- Prisma schema and development fixtures: `server/prisma/schema.prisma`, `server/prisma/seed.js`
- Server configuration boundary: `server/src/config/index.js`, `server/.env.example`

Main entry points: [`client/src/App.jsx`](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/App.jsx) (App route boundary), [`client/src/context/AuthContext.jsx`](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/context/AuthContext.jsx) (Auth state), [`server/src/app.js`](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/app.js) (Express application), [`server/prisma/schema.prisma`](https://github.com/aaryankacha/helpdesk-system/blob/main/server/prisma/schema.prisma) (Prisma tenant model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React Client"]
  node_client_bootstrap["SPA bootstrap<br/>Vite React entry<br/>[main.jsx]"]
  node_client_app["App route boundary<br/>React composition<br/>[App.jsx]"]
  node_auth_pages["Auth pages<br/>React screens<br/>[LoginPage.jsx]"]
  node_dashboard["Dashboard<br/>authenticated screen<br/>[DashboardPage.jsx]"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.jsx]"]
  node_api_client["API service<br/>browser HTTP boundary<br/>[api.js]"]
end

subgraph group_server["Express API"]
  node_server_listener["API process<br/>Node listener<br/>[server.js]"]
  node_express_app["Express application<br/>HTTP composition<br/>[app.js]"]
  node_route_root["/api routes<br/>route aggregator<br/>[index.js]"]
  node_auth_api["Auth API<br/>route/controller layer<br/>[authRoutes.js]"]
  node_organization_api["Organization API<br/>protected route/controller layer"]
  node_request_guards["Request guards<br/>auth, validation &amp; errors<br/>[authMiddleware.js]"]
  node_auth_service["Auth service<br/>[authService.js]"]
  node_organization_service["Organization service<br/>tenant retrieval logic"]
  node_server_config["Server runtime config<br/>environment boundary<br/>[index.js]"]
end

subgraph group_data["Data &amp; Local Runtime"]
  node_prisma_model["Prisma tenant model<br/>schema &amp; membership model<br/>[schema.prisma]"]
  node_postgres[("PostgreSQL<br/>durable datastore<br/>[docker-compose.yml]")]
  node_seed_data["Development seed<br/>Prisma fixtures<br/>[seed.js]"]
end

node_client_bootstrap -->|"renders"| node_client_app
node_client_app -->|"routes to"| node_auth_pages
node_client_app -->|"routes to"| node_dashboard
node_client_app -->|"provides auth state"| node_auth_context
node_auth_pages -->|"signs in or registers"| node_auth_context
node_dashboard -->|"reads session"| node_auth_context
node_auth_context -->|"uses"| node_api_client
node_api_client -->|"HTTP requests with JWT"| node_express_app
node_server_listener -->|"starts"| node_express_app
node_express_app -->|"mounts"| node_route_root
node_route_root -->|"auth endpoints"| node_auth_api
node_route_root -->|"organization endpoints"| node_organization_api
node_auth_api -->|"validates and authenticates"| node_request_guards
node_organization_api -->|"requires JWT"| node_request_guards
node_auth_api -->|"delegates"| node_auth_service
node_organization_api -->|"delegates"| node_organization_service
node_auth_service -->|"persists and verifies users"| node_prisma_model
node_organization_service -->|"queries memberships"| node_prisma_model
node_prisma_model -->|"maps to"| node_postgres
node_seed_data -->|"initializes"| node_prisma_model
node_server_config -.->|"configures"| node_express_app
node_server_config -.->|"database connection"| node_postgres

click node_client_bootstrap "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/App.jsx"
click node_auth_pages "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/pages/LoginPage.jsx"
click node_dashboard "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/pages/DashboardPage.jsx"
click node_auth_context "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/context/AuthContext.jsx"
click node_api_client "https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/services/api.js"
click node_server_listener "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/server.js"
click node_express_app "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/app.js"
click node_route_root "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/index.js"
click node_auth_api "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/authRoutes.js"
click node_organization_api "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/organizationRoutes.js"
click node_request_guards "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/middleware/authMiddleware.js"
click node_auth_service "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/services/authService.js"
click node_organization_service "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/services/organizationService.js"
click node_prisma_model "https://github.com/aaryankacha/helpdesk-system/blob/main/server/prisma/schema.prisma"
click node_postgres "https://github.com/aaryankacha/helpdesk-system/blob/main/docker-compose.yml"
click node_server_config "https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/config/index.js"
click node_seed_data "https://github.com/aaryankacha/helpdesk-system/blob/main/server/prisma/seed.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_client_bootstrap,node_client_app,node_auth_pages,node_dashboard,node_auth_context,node_api_client toneBlue
class node_server_listener,node_express_app,node_route_root,node_auth_api,node_organization_api,node_request_guards,node_auth_service,node_organization_service,node_server_config toneAmber
class node_prisma_model,node_postgres,node_seed_data toneMint
```

## Components

### React Client

- [SPA bootstrap](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/main.jsx): Vite React entry · `client/src/main.jsx`
- [App route boundary](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/App.jsx): React composition · Composes login, registration, and dashboard surfaces. · `client/src/App.jsx`
- [Auth pages](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/pages/LoginPage.jsx): React screens · `client/src/pages/LoginPage.jsx`
- [Dashboard](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/pages/DashboardPage.jsx): authenticated screen · `client/src/pages/DashboardPage.jsx`
- [Auth state](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/context/AuthContext.jsx): React context · Owns client authentication state. · `client/src/context/AuthContext.jsx`
- [API service](https://github.com/aaryankacha/helpdesk-system/blob/main/client/src/services/api.js): browser HTTP boundary · Builds JWT-bearing requests using the configured API URL. · `client/src/services/api.js`

### Express API

- [API process](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/server.js): Node listener · `server/src/server.js`
- [Express application](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/app.js): HTTP composition · Configures security, CORS, and API handling. · `server/src/app.js`
- [/api routes](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/index.js): route aggregator · `server/src/routes/index.js`
- [Auth API](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/authRoutes.js): route/controller layer · Handles registration, login, and current-user requests. · `server/src/routes/authRoutes.js`
- [Organization API](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/routes/organizationRoutes.js): protected route/controller layer · Exposes tenant-scoped organization retrieval. · `server/src/routes/organizationRoutes.js`
- [Request guards](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/middleware/authMiddleware.js): auth, validation & errors · Authenticates JWTs, validates input, and translates failures. · `server/src/middleware/authMiddleware.js`
- [Auth service](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/services/authService.js): credential & JWT domain logic · `server/src/services/authService.js`
- [Organization service](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/services/organizationService.js): tenant retrieval logic · `server/src/services/organizationService.js`
- [Server runtime config](https://github.com/aaryankacha/helpdesk-system/blob/main/server/src/config/index.js): environment boundary · Supplies database, JWT, port, and allowed-origin settings. · `server/src/config/index.js`

### Data & Local Runtime

- [Prisma tenant model](https://github.com/aaryankacha/helpdesk-system/blob/main/server/prisma/schema.prisma): schema & membership model · Defines users, organizations, memberships, and roles. · `server/prisma/schema.prisma`
- [PostgreSQL](https://github.com/aaryankacha/helpdesk-system/blob/main/docker-compose.yml): durable datastore · Local database is supplied through Compose. · `docker-compose.yml`
- [Development seed](https://github.com/aaryankacha/helpdesk-system/blob/main/server/prisma/seed.js): Prisma fixtures · `server/prisma/seed.js`

## Connections

- SPA bootstrap → App route boundary: renders
- App route boundary → Auth pages: routes to
- App route boundary → Dashboard: routes to
- App route boundary → Auth state: provides auth state
- Auth pages → Auth state: signs in or registers
- Dashboard → Auth state: reads session
- Auth state → API service: uses
- API service → Express application: HTTP requests with JWT
- API process → Express application: starts
- Express application → /api routes: mounts
- /api routes → Auth API: auth endpoints
- /api routes → Organization API: organization endpoints
- Auth API → Request guards: validates and authenticates
- Organization API → Request guards: requires JWT
- Auth API → Auth service: delegates
- Organization API → Organization service: delegates
- Auth service → Prisma tenant model: persists and verifies users
- Organization service → Prisma tenant model: queries memberships
- Prisma tenant model → PostgreSQL: maps to
- Development seed → Prisma tenant model: initializes
- Server runtime config → Express application: configures
- Server runtime config → PostgreSQL: database connection
