# naveensai123/jwt-authentication-service architecture

> Architecture diagram of the GitHub repository naveensai123/jwt-authentication-service, 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/naveensai123/jwt-authentication-service
- Repository: https://github.com/naveensai123/jwt-authentication-service

## Overview

This repository is a small Express API for account authentication and basic person records. Clients enter through the server and route modules; request schemas validate selected inputs before controllers handle registration, login, password changes, profiles, or person operations. Controllers delegate persistence and password work to services, which use Drizzle with PostgreSQL schemas. Authentication additionally signs and verifies JWTs. The graph follows shown route wiring and imports; the README provides no further capability details, and unsampled modules are not assumed to add behavior.

Main entry points: [`src/db/index.ts`](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/index.ts) (Drizzle client), [`src/routes/auth.routes.ts`](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/auth.routes.ts) (Auth routes), [`src/server.ts`](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/server.ts) (Express server), [`src/routes/person.routes.ts`](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/person.routes.ts) (Person routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["Express server<br/>[server.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_person_routes["Person routes<br/>[person.routes.ts]"]
end

subgraph group_auth["Authentication"]
  node_auth_validator["Auth validation<br/>[auth.validator.ts]"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_auth_middleware["JWT middleware<br/>[auth.middleware.ts]"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
end

subgraph group_persons["Person Records"]
  node_person_validator["Person validation"]
  node_person_controller["Person controller"]
  node_person_service["Person service<br/>[person.service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_db_client["Drizzle client<br/>[index.ts]"]
  node_users_schema["Users schema<br/>[schema.ts]"]
  node_persons_schema["Persons schema<br/>[schema2.ts]"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]
node_jwt["JWT library"]

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_person_routes
node_auth_routes -->|"validates input"| node_auth_validator
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_auth_routes -->|"guards profile"| node_auth_middleware
node_auth_controller -->|"calls auth operations"| node_auth_service
node_auth_controller -->|"signs tokens"| node_jwt
node_auth_middleware -->|"verifies tokens"| node_jwt
node_person_routes -->|"validates input"| node_person_validator
node_person_routes -->|"dispatches requests"| node_person_controller
node_person_controller -->|"calls person operations"| node_person_service
node_auth_service -->|"queries database"| node_db_client
node_auth_service -->|"uses table"| node_users_schema
node_person_service -->|"queries database"| node_db_client
node_person_service -->|"uses table"| node_persons_schema
node_db_client -->|"loads schema"| node_users_schema
node_db_client -->|"loads schema"| node_persons_schema
node_db_client -->|"connects to"| node_postgres

click node_server "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/server.ts"
click node_auth_routes "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/auth.routes.ts"
click node_person_routes "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/person.routes.ts"
click node_auth_validator "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/validators/auth.validator.ts"
click node_auth_controller "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/controllers/auth.controller.ts"
click node_auth_middleware "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/middlewares/auth.middleware.ts"
click node_auth_service "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/services/auth.service.ts"
click node_person_validator "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/validators/person.validator.ts"
click node_person_controller "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/controllers/person.controller.ts"
click node_person_service "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/services/person.service.ts"
click node_db_client "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/index.ts"
click node_users_schema "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/schema.ts"
click node_persons_schema "https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/schema2.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_server,node_auth_routes,node_person_routes,node_client toneBlue
class node_auth_validator,node_auth_controller,node_auth_middleware,node_auth_service,node_postgres toneAmber
class node_person_validator,node_person_controller,node_person_service toneMint
class node_db_client,node_users_schema,node_persons_schema toneRose
class node_jwt toneIndigo
```

## Components

### HTTP API

- [Express server](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/server.ts): `src/server.ts`
- [Auth routes](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/auth.routes.ts): `src/routes/auth.routes.ts`
- [Person routes](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/routes/person.routes.ts): `src/routes/person.routes.ts`

### Authentication

- [Auth validation](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/validators/auth.validator.ts): `src/validators/auth.validator.ts`
- [Auth controller](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/controllers/auth.controller.ts): `src/controllers/auth.controller.ts`
- [JWT middleware](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/middlewares/auth.middleware.ts): `src/middlewares/auth.middleware.ts`
- [Auth service](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/services/auth.service.ts): `src/services/auth.service.ts`

### Person Records

- [Person validation](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/validators/person.validator.ts): `src/validators/person.validator.ts`
- [Person controller](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/controllers/person.controller.ts): `src/controllers/person.controller.ts`
- [Person service](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/services/person.service.ts): `src/services/person.service.ts`

### Persistence

- [Drizzle client](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/index.ts): `src/db/index.ts`
- [Users schema](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/schema.ts): `src/db/schema.ts`
- [Persons schema](https://github.com/naveensai123/jwt-authentication-service/blob/main/src/db/schema2.ts): `src/db/schema2.ts`

### Other components

- **API client**
- **PostgreSQL**
- **JWT library**

## Connections

- API client → Express server: sends requests (evidence: `src/server.ts`)
- Express server → Auth routes: mounts routes (evidence: `src/server.ts`)
- Express server → Person routes: mounts routes (evidence: `src/server.ts`)
- Auth routes → Auth validation: validates input (evidence: `src/routes/auth.routes.ts`)
- Auth routes → Auth controller: dispatches requests (evidence: `src/routes/auth.routes.ts`)
- Auth routes → JWT middleware: guards profile (evidence: `src/routes/auth.routes.ts`)
- Auth controller → Auth service: calls auth operations (evidence: `src/controllers/auth.controller.ts`)
- Auth controller → JWT library: signs tokens (evidence: `src/controllers/auth.controller.ts`)
- JWT middleware → JWT library: verifies tokens (evidence: `src/middlewares/auth.middleware.ts`)
- Person routes → Person validation: validates input (evidence: `src/routes/person.routes.ts`)
- Person routes → Person controller: dispatches requests (evidence: `src/routes/person.routes.ts`)
- Person controller → Person service: calls person operations (evidence: `src/controllers/person.controller.ts`)
- Auth service → Drizzle client: queries database (evidence: `src/services/auth.service.ts`)
- Auth service → Users schema: uses table (evidence: `src/services/auth.service.ts`)
- Person service → Drizzle client: queries database (evidence: `src/services/person.service.ts`)
- Person service → Persons schema: uses table (evidence: `src/services/person.service.ts`)
- Drizzle client → Users schema: loads schema (evidence: `src/db/index.ts`)
- Drizzle client → Persons schema: loads schema (evidence: `src/db/index.ts`)
- Drizzle client → PostgreSQL: connects to (evidence: `src/db/index.ts`)
