# udarisathsarani1001/visionroot-software-engineering-assignment architecture

> Architecture diagram of the GitHub repository udarisathsarani1001/visionroot-software-engineering-assignment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/udarisathsarani1001/visionroot-software-engineering-assignment
- Repository: https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment

## Overview

This is a web-based service-request management system: users register, authenticate, and create or manage their own requests; administrators review all requests, change statuses, and view users. The frontend’s dedicated service modules call a REST API, whose routes dispatch through middleware and controllers into business services and MongoDB models. Authentication uses access and refresh tokens, and request status transitions and role-based restrictions are core domain behavior. Some frontend page-to-service links and unsampled administrative implementation details are shown only where documented or left unasserted.

Main entry points: [`backend/src/app.ts`](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/app.ts) (API application), [`backend/src/routes/request.routes.ts`](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/request.routes.ts) (Request routes), [`frontend/services/api.ts`](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/api.ts) (HTTP client), [`backend/src/models/User.model.ts`](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/User.model.ts) (User records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_authpages["Sign-in and registration<br/>[page.tsx]"]
  node_userrequests["User request screens<br/>[page.tsx]"]
  node_adminscreens["Admin screens<br/>[page.tsx]"]
  node_authstate["Session state<br/>[AuthProvider.tsx]"]
end

subgraph group_clientapi["Frontend API client"]
  node_authclient["Auth client<br/>[auth.service.ts]"]
  node_requestclient["Request client<br/>[request.service.ts]"]
  node_userclient["User client<br/>[user.service.ts]"]
  node_httpclient["HTTP client<br/>[api.ts]"]
end

subgraph group_backend["Backend request handling"]
  node_expressapp["API application<br/>[app.ts]"]
  node_authroutes["Auth routes<br/>[auth.routes.ts]"]
  node_requestroutes["Request routes<br/>[request.routes.ts]"]
  node_userroutes["User routes<br/>[user.routes.ts]"]
  node_authcontroller["Auth controller<br/>[auth.controller.ts]"]
  node_requestcontroller["Request controller"]
  node_authmiddleware["Authentication guard<br/>[auth.middleware.ts]"]
  node_rolemiddleware["Role guard<br/>[role.middleware.ts]"]
end

subgraph group_domain["Domain services and data"]
  node_authservice["Identity service<br/>[auth.service.ts]"]
  node_requestservice["Request service<br/>[request.service.ts]"]
  node_statusrules["Status transitions"]
  node_userservice["User service<br/>[user.service.ts]"]
  node_userstore[("User records<br/>[User.model.ts]")]
  node_tokenstore[("Refresh tokens")]
  node_requeststore[("Service requests")]
end

node_user(("Registered user"))
node_admin(("Administrator"))
node_mongodb[("MongoDB")]

node_user -->|"registers or logs in"| node_authpages
node_user -->|"manages requests"| node_userrequests
node_admin -->|"manages service data"| node_adminscreens
node_authpages -.->|"uses auth operations"| node_authclient
node_userrequests -.->|"uses request operations"| node_requestclient
node_adminscreens -.->|"uses request operations"| node_requestclient
node_authstate -.->|"restores session"| node_authclient
node_authclient -->|"sends API requests"| node_httpclient
node_requestclient -->|"sends API requests"| node_httpclient
node_userclient -->|"sends API requests"| node_httpclient
node_httpclient -->|"calls REST API"| node_expressapp
node_expressapp -->|"mounts routes"| node_authroutes
node_expressapp -->|"mounts routes"| node_requestroutes
node_expressapp -->|"mounts routes"| node_userroutes
node_authroutes -->|"dispatches handlers"| node_authcontroller
node_requestroutes -->|"dispatches handlers"| node_requestcontroller
node_authroutes -->|"guards current user"| node_authmiddleware
node_requestroutes -->|"authenticates requests"| node_authmiddleware
node_requestroutes -->|"guards status changes"| node_rolemiddleware
node_authcontroller -->|"invokes identity logic"| node_authservice
node_requestcontroller -->|"invokes request logic"| node_requestservice
node_authmiddleware -->|"loads account"| node_userstore
node_authservice -->|"reads and creates users"| node_userstore
node_authservice -->|"stores token hashes"| node_tokenstore
node_requestservice -->|"manages requests"| node_requeststore
node_requestservice -->|"checks transitions"| node_statusrules
node_userservice -.->|"manages user records"| node_userstore
node_userstore -->|"persists records"| node_mongodb
node_tokenstore -->|"persists tokens"| node_mongodb
node_requeststore -->|"persists requests"| node_mongodb

click node_authpages "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/login/page.tsx"
click node_userrequests "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/requests/page.tsx"
click node_adminscreens "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/admin/requests/page.tsx"
click node_authstate "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/providers/AuthProvider.tsx"
click node_authclient "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/auth.service.ts"
click node_requestclient "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/request.service.ts"
click node_userclient "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/user.service.ts"
click node_httpclient "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/api.ts"
click node_expressapp "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/app.ts"
click node_authroutes "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/auth.routes.ts"
click node_requestroutes "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/request.routes.ts"
click node_userroutes "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/user.routes.ts"
click node_authcontroller "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/controllers/auth.controller.ts"
click node_requestcontroller "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/controllers/request.controller.ts"
click node_authmiddleware "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/middleware/auth.middleware.ts"
click node_rolemiddleware "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/middleware/role.middleware.ts"
click node_authservice "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/auth.service.ts"
click node_requestservice "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/request.service.ts"
click node_statusrules "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/request-status.service.ts"
click node_userservice "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/user.service.ts"
click node_userstore "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/User.model.ts"
click node_tokenstore "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/RefreshToken.model.ts"
click node_requeststore "https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/ServiceRequest.model.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_authpages,node_userrequests,node_adminscreens,node_authstate,node_user toneBlue
class node_authclient,node_requestclient,node_userclient,node_httpclient,node_mongodb toneAmber
class node_expressapp,node_authroutes,node_requestroutes,node_userroutes,node_authcontroller,node_requestcontroller,node_authmiddleware,node_rolemiddleware toneMint
class node_authservice,node_requestservice,node_statusrules,node_userservice,node_userstore,node_tokenstore,node_requeststore toneRose
class node_admin toneIndigo
```

## Components

### Frontend experience

- [Sign-in and registration](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/login/page.tsx): `frontend/app/login/page.tsx`
- [User request screens](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/requests/page.tsx): `frontend/app/requests/page.tsx`
- [Admin screens](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/app/admin/requests/page.tsx): `frontend/app/admin/requests/page.tsx`
- [Session state](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/providers/AuthProvider.tsx): `frontend/providers/AuthProvider.tsx`

### Frontend API client

- [Auth client](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/auth.service.ts): `frontend/services/auth.service.ts`
- [Request client](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/request.service.ts): `frontend/services/request.service.ts`
- [User client](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/user.service.ts): `frontend/services/user.service.ts`
- [HTTP client](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/frontend/services/api.ts): `frontend/services/api.ts`

### Backend request handling

- [API application](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Auth routes](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [Request routes](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/request.routes.ts): `backend/src/routes/request.routes.ts`
- [User routes](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/routes/user.routes.ts): `backend/src/routes/user.routes.ts`
- [Auth controller](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/controllers/auth.controller.ts): `backend/src/controllers/auth.controller.ts`
- [Request controller](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/controllers/request.controller.ts): `backend/src/controllers/request.controller.ts`
- [Authentication guard](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/middleware/auth.middleware.ts): `backend/src/middleware/auth.middleware.ts`
- [Role guard](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/middleware/role.middleware.ts): `backend/src/middleware/role.middleware.ts`

### Domain services and data

- [Identity service](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Request service](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/request.service.ts): `backend/src/services/request.service.ts`
- [Status transitions](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/request-status.service.ts): `backend/src/services/request-status.service.ts`
- [User service](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/services/user.service.ts): `backend/src/services/user.service.ts`
- [User records](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/User.model.ts): `backend/src/models/User.model.ts`
- [Refresh tokens](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/RefreshToken.model.ts): `backend/src/models/RefreshToken.model.ts`
- [Service requests](https://github.com/udarisathsarani1001/visionroot-software-engineering-assignment/blob/main/backend/src/models/ServiceRequest.model.ts): `backend/src/models/ServiceRequest.model.ts`

### Other components

- **Registered user**
- **Administrator**
- **MongoDB**

## Connections

- Registered user → Sign-in and registration: registers or logs in (evidence: `README.md`)
- Registered user → User request screens: manages requests (evidence: `README.md`)
- Administrator → Admin screens: manages service data (evidence: `README.md`)
- Sign-in and registration → Auth client: uses auth operations
- User request screens → Request client: uses request operations
- Admin screens → Request client: uses request operations
- Session state → Auth client: restores session
- Auth client → HTTP client: sends API requests (evidence: `frontend/services/auth.service.ts`)
- Request client → HTTP client: sends API requests (evidence: `frontend/services/request.service.ts`)
- User client → HTTP client: sends API requests (evidence: `frontend/services/user.service.ts`)
- HTTP client → API application: calls REST API (evidence: `README.md`)
- API application → Auth routes: mounts routes (evidence: `backend/src/app.ts`)
- API application → Request routes: mounts routes (evidence: `backend/src/app.ts`)
- API application → User routes: mounts routes (evidence: `backend/src/app.ts`)
- Auth routes → Auth controller: dispatches handlers (evidence: `backend/src/routes/auth.routes.ts`)
- Request routes → Request controller: dispatches handlers (evidence: `backend/src/routes/request.routes.ts`)
- Auth routes → Authentication guard: guards current user (evidence: `backend/src/routes/auth.routes.ts`)
- Request routes → Authentication guard: authenticates requests (evidence: `backend/src/routes/request.routes.ts`)
- Request routes → Role guard: guards status changes (evidence: `backend/src/routes/request.routes.ts`)
- Auth controller → Identity service: invokes identity logic (evidence: `backend/src/controllers/auth.controller.ts`)
- Request controller → Request service: invokes request logic (evidence: `backend/src/controllers/request.controller.ts`)
- Authentication guard → User records: loads account (evidence: `backend/src/middleware/auth.middleware.ts`)
- Identity service → User records: reads and creates users (evidence: `backend/src/services/auth.service.ts`)
- Identity service → Refresh tokens: stores token hashes (evidence: `backend/src/services/auth.service.ts`)
- Request service → Service requests: manages requests (evidence: `backend/src/services/request.service.ts`)
- Request service → Status transitions: checks transitions (evidence: `backend/src/services/request.service.ts`)
- User service → User records: manages user records
- User records → MongoDB: persists records (evidence: `README.md`)
- Refresh tokens → MongoDB: persists tokens (evidence: `README.md`)
- Service requests → MongoDB: persists requests (evidence: `README.md`)
