# arpon-dev-stack/auth-server architecture

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

- Interactive diagram: https://gitdiagram.com/arpon-dev-stack/auth-server
- Repository: https://github.com/arpon-dev-stack/auth-server

## Overview

Auth Server is an Express API for account registration, email verification, sign-in, profile access, password recovery, refresh, and sign-out. Requests enter through the server and auth router, which dispatch to controllers; controllers validate inputs and coordinate persistence, OTP/email delivery, and JWT operations. Protected profile requests additionally pass through token middleware. The README documents these capabilities, while the shown route file confirms dispatch wiring. Some controller dependencies are supported by the source index rather than full excerpts; the graph avoids inferring unshown controller-to-controller flows.

Main entry points: [`src/routes/auth.route.ts`](https://github.com/arpon-dev-stack/auth-server/blob/master/src/routes/auth.route.ts) (Auth routes), [`src/prisma/db.ts`](https://github.com/arpon-dev-stack/auth-server/blob/master/src/prisma/db.ts) (Prisma database client), [`src/controllers/signUp.controller.ts`](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signUp.controller.ts) (Signup and verification), [`src/controllers/forget.controller.ts`](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/forget.controller.ts) (Password recovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API routing"]
  node_server["Express server<br/>[index.ts]"]
  node_auth_routes["Auth routes<br/>[auth.route.ts]"]
end

subgraph group_flows["Account workflows"]
  node_signup_verify["Signup and verification"]
  node_signin["Sign in"]
  node_password_recovery["Password recovery"]
  node_refresh["Token refresh"]
  node_signout["Sign out"]
  node_profile["Profile retrieval"]
end

subgraph group_security["Tokens and validation"]
  node_auth_middleware["Token middleware<br/>[auth.ts]"]
  node_jwt["JWT operations<br/>[jwt.ts]"]
  node_validation["Input validation<br/>[validations.ts]"]
  node_otp["OTP generation<br/>[tokens.ts]"]
end

subgraph group_infrastructure["Persistence and email"]
  node_configuration["Environment config<br/>[env.ts]"]
  node_database_client["Prisma database client<br/>[db.ts]"]
  node_schema["Database contract<br/>[contract.prisma]"]
  node_postgres[("PostgreSQL")]
  node_mailer["OTP mailer<br/>[mailer.ts]"]
end

node_client(("API client"))
node_smtp["SMTP service"]

node_client -->|"sends requests"| node_server
node_server -->|"mounts router"| node_auth_routes
node_auth_routes -->|"dispatches"| node_signup_verify
node_auth_routes -->|"dispatches"| node_signin
node_auth_routes -->|"dispatches"| node_password_recovery
node_auth_routes -->|"dispatches"| node_refresh
node_auth_routes -->|"dispatches"| node_signout
node_auth_routes -->|"protects profile"| node_auth_middleware
node_auth_routes -->|"dispatches profile"| node_profile
node_signup_verify -->|"validates input"| node_validation
node_signup_verify -->|"reads and writes"| node_database_client
node_signup_verify -->|"generates OTP"| node_otp
node_signup_verify -->|"sends OTP"| node_mailer
node_signin -->|"validates input"| node_validation
node_signin -->|"reads user"| node_database_client
node_signin -->|"issues tokens"| node_jwt
node_password_recovery -->|"validates input"| node_validation
node_password_recovery -->|"reads and writes"| node_database_client
node_password_recovery -->|"generates OTP"| node_otp
node_password_recovery -->|"sends OTP"| node_mailer
node_refresh -->|"verifies and issues"| node_jwt
node_auth_middleware -->|"verifies access token"| node_jwt
node_profile -->|"reads user"| node_database_client
node_database_client -->|"gets database URL"| node_configuration
node_database_client -->|"loads contract"| node_schema
node_database_client -->|"connects to"| node_postgres
node_jwt -->|"uses secrets"| node_configuration
node_mailer -->|"uses SMTP settings"| node_configuration
node_mailer -->|"delivers email"| node_smtp

click node_server "https://github.com/arpon-dev-stack/auth-server/blob/master/index.ts"
click node_auth_routes "https://github.com/arpon-dev-stack/auth-server/blob/master/src/routes/auth.route.ts"
click node_signup_verify "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signUp.controller.ts"
click node_signin "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signIn.controller.ts"
click node_password_recovery "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/forget.controller.ts"
click node_refresh "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/refresh.controller.ts"
click node_signout "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signOut.controller.ts"
click node_profile "https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/verifyMe.controller.ts"
click node_auth_middleware "https://github.com/arpon-dev-stack/auth-server/blob/master/src/middleware/auth.ts"
click node_jwt "https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/jwt.ts"
click node_validation "https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/validations.ts"
click node_otp "https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/tokens.ts"
click node_configuration "https://github.com/arpon-dev-stack/auth-server/blob/master/src/config/env.ts"
click node_database_client "https://github.com/arpon-dev-stack/auth-server/blob/master/src/prisma/db.ts"
click node_schema "https://github.com/arpon-dev-stack/auth-server/blob/master/src/prisma/contract.prisma"
click node_mailer "https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/mailer.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_client toneBlue
class node_signup_verify,node_signin,node_password_recovery,node_refresh,node_signout,node_profile toneAmber
class node_auth_middleware,node_jwt,node_validation,node_otp toneMint
class node_configuration,node_database_client,node_schema,node_postgres,node_mailer toneRose
class node_smtp toneIndigo
```

## Components

### API routing

- [Express server](https://github.com/arpon-dev-stack/auth-server/blob/master/index.ts): `index.ts`
- [Auth routes](https://github.com/arpon-dev-stack/auth-server/blob/master/src/routes/auth.route.ts): `src/routes/auth.route.ts`

### Account workflows

- [Signup and verification](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signUp.controller.ts): `src/controllers/signUp.controller.ts`
- [Sign in](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signIn.controller.ts): `src/controllers/signIn.controller.ts`
- [Password recovery](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/forget.controller.ts): `src/controllers/forget.controller.ts`
- [Token refresh](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/refresh.controller.ts): `src/controllers/refresh.controller.ts`
- [Sign out](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/signOut.controller.ts): `src/controllers/signOut.controller.ts`
- [Profile retrieval](https://github.com/arpon-dev-stack/auth-server/blob/master/src/controllers/verifyMe.controller.ts): `src/controllers/verifyMe.controller.ts`

### Tokens and validation

- [Token middleware](https://github.com/arpon-dev-stack/auth-server/blob/master/src/middleware/auth.ts): `src/middleware/auth.ts`
- [JWT operations](https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/jwt.ts): `src/lib/jwt.ts`
- [Input validation](https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/validations.ts): `src/lib/validations.ts`
- [OTP generation](https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/tokens.ts): `src/lib/tokens.ts`

### Persistence and email

- [Environment config](https://github.com/arpon-dev-stack/auth-server/blob/master/src/config/env.ts): `src/config/env.ts`
- [Prisma database client](https://github.com/arpon-dev-stack/auth-server/blob/master/src/prisma/db.ts): `src/prisma/db.ts`
- [Database contract](https://github.com/arpon-dev-stack/auth-server/blob/master/src/prisma/contract.prisma): `src/prisma/contract.prisma`
- **PostgreSQL**
- [OTP mailer](https://github.com/arpon-dev-stack/auth-server/blob/master/src/lib/mailer.ts): `src/lib/mailer.ts`

### Other components

- **API client**
- **SMTP service**

## Connections

- API client → Express server: sends requests (evidence: `README.md`)
- Express server → Auth routes: mounts router (evidence: `index.ts`)
- Auth routes → Signup and verification: dispatches (evidence: `src/routes/auth.route.ts`)
- Auth routes → Sign in: dispatches (evidence: `src/routes/auth.route.ts`)
- Auth routes → Password recovery: dispatches (evidence: `src/routes/auth.route.ts`)
- Auth routes → Token refresh: dispatches (evidence: `src/routes/auth.route.ts`)
- Auth routes → Sign out: dispatches (evidence: `src/routes/auth.route.ts`)
- Auth routes → Token middleware: protects profile (evidence: `src/routes/auth.route.ts`)
- Auth routes → Profile retrieval: dispatches profile (evidence: `src/routes/auth.route.ts`)
- Signup and verification → Input validation: validates input (evidence: `src/controllers/signUp.controller.ts`)
- Signup and verification → Prisma database client: reads and writes (evidence: `src/controllers/signUp.controller.ts`)
- Signup and verification → OTP generation: generates OTP (evidence: `src/controllers/signUp.controller.ts`)
- Signup and verification → OTP mailer: sends OTP (evidence: `src/controllers/signUp.controller.ts`)
- Sign in → Input validation: validates input (evidence: `src/controllers/signIn.controller.ts`)
- Sign in → Prisma database client: reads user (evidence: `src/controllers/signIn.controller.ts`)
- Sign in → JWT operations: issues tokens (evidence: `src/controllers/signIn.controller.ts`)
- Password recovery → Input validation: validates input (evidence: `src/controllers/forget.controller.ts`)
- Password recovery → Prisma database client: reads and writes (evidence: `src/controllers/forget.controller.ts`)
- Password recovery → OTP generation: generates OTP (evidence: `src/controllers/forget.controller.ts`)
- Password recovery → OTP mailer: sends OTP (evidence: `src/controllers/forget.controller.ts`)
- Token refresh → JWT operations: verifies and issues (evidence: `src/controllers/refresh.controller.ts`)
- Token middleware → JWT operations: verifies access token (evidence: `src/middleware/auth.ts`)
- Profile retrieval → Prisma database client: reads user (evidence: `src/controllers/verifyMe.controller.ts`)
- Prisma database client → Environment config: gets database URL (evidence: `src/prisma/db.ts`)
- Prisma database client → Database contract: loads contract (evidence: `src/prisma/db.ts`)
- Prisma database client → PostgreSQL: connects to (evidence: `README.md`)
- JWT operations → Environment config: uses secrets (evidence: `src/lib/jwt.ts`)
- OTP mailer → Environment config: uses SMTP settings (evidence: `src/lib/mailer.ts`)
- OTP mailer → SMTP service: delivers email (evidence: `README.md`)
