# ravibaskey/crm-system architecture

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

- Interactive diagram: https://gitdiagram.com/ravibaskey/crm-system
- Repository: https://github.com/ravibaskey/crm-system

## Overview

This repository is a small Express CRM backend centered on authentication, user administration, and support tickets. Clients enter through route modules, which apply request validation and authentication/authorization middleware before invoking controllers; controllers read and update user or ticket records and shape responses where needed. Ticket handling includes role-based visibility and automatic assignment to an approved engineer. The README provides no additional capability detail, and the sampled sources do not establish database connection setup or comment workflows, so those are not mapped.

Main entry points: [`utils/constants.js`](https://github.com/ravibaskey/crm-system/blob/main/utils/constants.js) (Domain Constants), [`models/user.model.js`](https://github.com/ravibaskey/crm-system/blob/main/models/user.model.js) (User Records), [`middlewares/authjwt.js`](https://github.com/ravibaskey/crm-system/blob/main/middlewares/authjwt.js) (JWT and Admin Checks), [`routes/user.routes.js`](https://github.com/ravibaskey/crm-system/blob/main/routes/user.routes.js) (User Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Routing"]
  node_auth_routes["Auth Routes<br/>[auth.routes.js]"]
  node_user_routes["User Routes<br/>[user.routes.js]"]
  node_ticket_routes["Ticket Routes<br/>[ticket.routes.js]"]
end

subgraph group_identity["Identity and Access"]
  node_auth_controller["Signup and Signin<br/>[auth.controller.js]"]
  node_auth_validation["Signup Validation"]
  node_jwt_middleware["JWT and Admin Checks<br/>[authjwt.js]"]
  node_auth_config["JWT Configuration<br/>[auth.config]"]
end

subgraph group_users["User Administration"]
  node_user_controller["User Operations<br/>[user.controller.js]"]
  node_user_validation["User Update Validation"]
  node_user_model[("User Records<br/>[user.model.js]")]
  node_response_converter["User Response Mapping<br/>[objectConverter.js]"]
end

subgraph group_tickets["Ticket Management"]
  node_ticket_controller["Ticket Operations"]
  node_ticket_validation["Ticket Request Validation"]
  node_ticket_model[("Ticket Records<br/>[ticket.model.js]")]
  node_comment_model[("Comment Model<br/>[comment.model.js]")]
end

subgraph group_shared["Shared Domain"]
  node_domain_constants["Domain Constants<br/>[constants.js]"]
end

node_client(("API Client"))

node_client -->|"calls auth endpoints"| node_auth_routes
node_client -->|"calls user endpoints"| node_user_routes
node_client -->|"calls ticket endpoints"| node_ticket_routes
node_auth_routes -->|"validates signup"| node_auth_validation
node_auth_routes -->|"dispatches auth"| node_auth_controller
node_user_routes -->|"checks access"| node_jwt_middleware
node_user_routes -->|"validates updates"| node_user_validation
node_user_routes -->|"dispatches users"| node_user_controller
node_ticket_routes -->|"checks token"| node_jwt_middleware
node_ticket_routes -->|"validates requests"| node_ticket_validation
node_ticket_routes -->|"dispatches tickets"| node_ticket_controller
node_auth_validation -->|"checks duplicates"| node_user_model
node_auth_validation -->|"checks user types"| node_domain_constants
node_user_validation -->|"checks allowed values"| node_domain_constants
node_jwt_middleware -->|"verifies with secret"| node_auth_config
node_jwt_middleware -->|"looks up role"| node_user_model
node_jwt_middleware -->|"checks admin role"| node_domain_constants
node_auth_controller -->|"creates and reads"| node_user_model
node_auth_controller -->|"signs token"| node_auth_config
node_auth_controller -->|"sets account status"| node_domain_constants
node_user_controller -->|"reads and updates"| node_user_model
node_user_controller -->|"formats user results"| node_response_converter
node_ticket_controller -->|"checks requester and assignee"| node_user_model
node_ticket_controller -->|"creates and queries"| node_ticket_model
node_ticket_controller -->|"checks roles and status"| node_domain_constants
node_ticket_validation -->|"checks ticket values"| node_domain_constants
node_user_model -->|"defines role enums"| node_domain_constants
node_ticket_model -->|"defines default status"| node_domain_constants

click node_auth_routes "https://github.com/ravibaskey/crm-system/blob/main/routes/auth.routes.js"
click node_user_routes "https://github.com/ravibaskey/crm-system/blob/main/routes/user.routes.js"
click node_ticket_routes "https://github.com/ravibaskey/crm-system/blob/main/routes/ticket.routes.js"
click node_auth_controller "https://github.com/ravibaskey/crm-system/blob/main/controllers/auth.controller.js"
click node_auth_validation "https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyUserreqBody.js"
click node_jwt_middleware "https://github.com/ravibaskey/crm-system/blob/main/middlewares/authjwt.js"
click node_auth_config "https://github.com/ravibaskey/crm-system/blob/main/configs/auth.config"
click node_user_controller "https://github.com/ravibaskey/crm-system/blob/main/controllers/user.controller.js"
click node_user_validation "https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyUserreqBody.js"
click node_user_model "https://github.com/ravibaskey/crm-system/blob/main/models/user.model.js"
click node_response_converter "https://github.com/ravibaskey/crm-system/blob/main/utils/objectConverter.js"
click node_ticket_controller "https://github.com/ravibaskey/crm-system/blob/main/controllers/ticket.controller.js"
click node_ticket_validation "https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyTicketRequestBody.js"
click node_ticket_model "https://github.com/ravibaskey/crm-system/blob/main/models/ticket.model.js"
click node_comment_model "https://github.com/ravibaskey/crm-system/blob/main/models/comment.model.js"
click node_domain_constants "https://github.com/ravibaskey/crm-system/blob/main/utils/constants.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_auth_routes,node_user_routes,node_ticket_routes,node_client toneBlue
class node_auth_controller,node_auth_validation,node_jwt_middleware,node_auth_config toneAmber
class node_user_controller,node_user_validation,node_user_model,node_response_converter toneMint
class node_ticket_controller,node_ticket_validation,node_ticket_model,node_comment_model toneRose
class node_domain_constants toneIndigo
```

## Components

### API Routing

- [Auth Routes](https://github.com/ravibaskey/crm-system/blob/main/routes/auth.routes.js): `routes/auth.routes.js`
- [User Routes](https://github.com/ravibaskey/crm-system/blob/main/routes/user.routes.js): `routes/user.routes.js`
- [Ticket Routes](https://github.com/ravibaskey/crm-system/blob/main/routes/ticket.routes.js): `routes/ticket.routes.js`

### Identity and Access

- [Signup and Signin](https://github.com/ravibaskey/crm-system/blob/main/controllers/auth.controller.js): `controllers/auth.controller.js`
- [Signup Validation](https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyUserreqBody.js): `middlewares/verifyUserreqBody.js`
- [JWT and Admin Checks](https://github.com/ravibaskey/crm-system/blob/main/middlewares/authjwt.js): `middlewares/authjwt.js`
- [JWT Configuration](https://github.com/ravibaskey/crm-system/blob/main/configs/auth.config): `configs/auth.config`

### User Administration

- [User Operations](https://github.com/ravibaskey/crm-system/blob/main/controllers/user.controller.js): `controllers/user.controller.js`
- [User Update Validation](https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyUserreqBody.js): `middlewares/verifyUserreqBody.js`
- [User Records](https://github.com/ravibaskey/crm-system/blob/main/models/user.model.js): `models/user.model.js`
- [User Response Mapping](https://github.com/ravibaskey/crm-system/blob/main/utils/objectConverter.js): `utils/objectConverter.js`

### Ticket Management

- [Ticket Operations](https://github.com/ravibaskey/crm-system/blob/main/controllers/ticket.controller.js): `controllers/ticket.controller.js`
- [Ticket Request Validation](https://github.com/ravibaskey/crm-system/blob/main/middlewares/verifyTicketRequestBody.js): `middlewares/verifyTicketRequestBody.js`
- [Ticket Records](https://github.com/ravibaskey/crm-system/blob/main/models/ticket.model.js): `models/ticket.model.js`
- [Comment Model](https://github.com/ravibaskey/crm-system/blob/main/models/comment.model.js): `models/comment.model.js`

### Shared Domain

- [Domain Constants](https://github.com/ravibaskey/crm-system/blob/main/utils/constants.js): `utils/constants.js`

### Other components

- **API Client**

## Connections

- API Client → Auth Routes: calls auth endpoints (evidence: `routes/auth.routes.js`)
- API Client → User Routes: calls user endpoints (evidence: `routes/user.routes.js`)
- API Client → Ticket Routes: calls ticket endpoints (evidence: `routes/ticket.routes.js`)
- Auth Routes → Signup Validation: validates signup (evidence: `routes/auth.routes.js`)
- Auth Routes → Signup and Signin: dispatches auth (evidence: `routes/auth.routes.js`)
- User Routes → JWT and Admin Checks: checks access (evidence: `routes/user.routes.js`)
- User Routes → User Update Validation: validates updates (evidence: `routes/user.routes.js`)
- User Routes → User Operations: dispatches users (evidence: `routes/user.routes.js`)
- Ticket Routes → JWT and Admin Checks: checks token (evidence: `routes/ticket.routes.js`)
- Ticket Routes → Ticket Request Validation: validates requests (evidence: `routes/ticket.routes.js`)
- Ticket Routes → Ticket Operations: dispatches tickets (evidence: `routes/ticket.routes.js`)
- Signup Validation → User Records: checks duplicates (evidence: `middlewares/verifyUserreqBody.js`)
- Signup Validation → Domain Constants: checks user types (evidence: `middlewares/verifyUserreqBody.js`)
- User Update Validation → Domain Constants: checks allowed values (evidence: `middlewares/verifyUserreqBody.js`)
- JWT and Admin Checks → JWT Configuration: verifies with secret (evidence: `middlewares/authjwt.js`)
- JWT and Admin Checks → User Records: looks up role (evidence: `middlewares/authjwt.js`)
- JWT and Admin Checks → Domain Constants: checks admin role (evidence: `middlewares/authjwt.js`)
- Signup and Signin → User Records: creates and reads (evidence: `controllers/auth.controller.js`)
- Signup and Signin → JWT Configuration: signs token (evidence: `controllers/auth.controller.js`)
- Signup and Signin → Domain Constants: sets account status (evidence: `controllers/auth.controller.js`)
- User Operations → User Records: reads and updates (evidence: `controllers/user.controller.js`)
- User Operations → User Response Mapping: formats user results (evidence: `controllers/user.controller.js`)
- Ticket Operations → User Records: checks requester and assignee (evidence: `controllers/ticket.controller.js`)
- Ticket Operations → Ticket Records: creates and queries (evidence: `controllers/ticket.controller.js`)
- Ticket Operations → Domain Constants: checks roles and status (evidence: `controllers/ticket.controller.js`)
- Ticket Request Validation → Domain Constants: checks ticket values (evidence: `middlewares/verifyTicketRequestBody.js`)
- User Records → Domain Constants: defines role enums (evidence: `models/user.model.js`)
- Ticket Records → Domain Constants: defines default status (evidence: `models/ticket.model.js`)
