# kphuyal8979/dineflow architecture

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

- Interactive diagram: https://gitdiagram.com/kphuyal8979/dineflow
- Repository: https://github.com/kphuyal8979/dineflow

## Overview

DineFlow’s server is an Express API whose main workflow handles signup and login: route handlers validate credentials, delegate account operations, and return a user with a cookie token. A protected profile route verifies that token and loads the user; logout clears the cookie. Health checking is a separate API capability. The excerpts show these authentication calls, but not application/server wiring or database connection startup, so those links are omitted or marked unverified.

Main entry points: [`server/src/controllers/auth.controller.js`](https://github.com/kphuyal8979/dineflow/blob/master/server/src/controllers/auth.controller.js) (Auth controller), [`server/src/services/auth.service.js`](https://github.com/kphuyal8979/dineflow/blob/master/server/src/services/auth.service.js) (Auth service), [`server/src/middleware/auth.middleware.js`](https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/auth.middleware.js) (Token protection), [`server/src/config/env.js`](https://github.com/kphuyal8979/dineflow/blob/master/server/src/config/env.js) (Environment config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry points"]
  node_auth_routes["Auth routes<br/>[auth.route.js]"]
  node_health_route["Health route<br/>[health.route.js]"]
end

subgraph group_auth["Authentication"]
  node_auth_controller["Auth controller<br/>[auth.controller.js]"]
  node_auth_validator["Credential validation<br/>[auth.validator.js]"]
  node_auth_service["Auth service<br/>[auth.service.js]"]
  node_auth_middleware["Token protection<br/>[auth.middleware.js]"]
  node_jwt_helper["Token signing<br/>[jwt.js]"]
end

subgraph group_identity["User identity"]
  node_user_model["User model<br/>[User.js]"]
  node_mongo[("MongoDB")]
end

subgraph group_platform["Runtime support"]
  node_async_handler["Async wrapper<br/>[async-handler.js]"]
  node_app_error["Auth errors<br/>[app-error.js]"]
  node_environment["Environment config<br/>[env.js]"]
  node_db_connector["DB connector<br/>[db.js]"]
  node_error_middleware["Error handling"]
  node_not_found["Not-found handling"]
  node_limiter["Rate limiter<br/>[limiter.js]"]
end

node_client(("API client"))

node_client -.->|"requests"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects profile"| node_auth_middleware
node_auth_controller -->|"validates input"| node_auth_validator
node_auth_controller -->|"calls auth"| node_auth_service
node_auth_controller -->|"wraps handlers"| node_async_handler
node_auth_controller -->|"returns responses"| node_client
node_auth_service -->|"reads and writes"| node_user_model
node_auth_service -->|"signs tokens"| node_jwt_helper
node_auth_service -->|"raises errors"| node_app_error
node_auth_middleware -->|"loads user"| node_user_model
node_auth_middleware -->|"reads secret"| node_environment
node_auth_middleware -->|"sets request user"| node_auth_controller
node_user_model -.->|"persists records"| node_mongo
node_jwt_helper -->|"reads secret"| node_environment
node_health_route -->|"reads environment"| node_environment
node_db_connector -->|"reads connection URI"| node_environment

click node_auth_routes "https://github.com/kphuyal8979/dineflow/blob/master/server/src/routes/auth.route.js"
click node_health_route "https://github.com/kphuyal8979/dineflow/blob/master/server/src/routes/health.route.js"
click node_auth_controller "https://github.com/kphuyal8979/dineflow/blob/master/server/src/controllers/auth.controller.js"
click node_auth_validator "https://github.com/kphuyal8979/dineflow/blob/master/server/src/validators/auth.validator.js"
click node_async_handler "https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/async-handler.js"
click node_auth_service "https://github.com/kphuyal8979/dineflow/blob/master/server/src/services/auth.service.js"
click node_auth_middleware "https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/auth.middleware.js"
click node_user_model "https://github.com/kphuyal8979/dineflow/blob/master/server/src/models/User.js"
click node_jwt_helper "https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/jwt.js"
click node_app_error "https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/app-error.js"
click node_environment "https://github.com/kphuyal8979/dineflow/blob/master/server/src/config/env.js"
click node_db_connector "https://github.com/kphuyal8979/dineflow/blob/master/server/src/lib/db.js"
click node_error_middleware "https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/error.middleware.js"
click node_not_found "https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/not-found.middleware.js"
click node_limiter "https://github.com/kphuyal8979/dineflow/blob/master/server/src/lib/limiter.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_health_route,node_client toneBlue
class node_auth_controller,node_auth_validator,node_auth_service,node_auth_middleware,node_jwt_helper toneAmber
class node_user_model,node_mongo toneMint
class node_async_handler,node_app_error,node_environment,node_db_connector,node_error_middleware,node_not_found,node_limiter toneRose
```

## Components

### API entry points

- [Auth routes](https://github.com/kphuyal8979/dineflow/blob/master/server/src/routes/auth.route.js): `server/src/routes/auth.route.js`
- [Health route](https://github.com/kphuyal8979/dineflow/blob/master/server/src/routes/health.route.js): `server/src/routes/health.route.js`

### Authentication

- [Auth controller](https://github.com/kphuyal8979/dineflow/blob/master/server/src/controllers/auth.controller.js): `server/src/controllers/auth.controller.js`
- [Credential validation](https://github.com/kphuyal8979/dineflow/blob/master/server/src/validators/auth.validator.js): `server/src/validators/auth.validator.js`
- [Auth service](https://github.com/kphuyal8979/dineflow/blob/master/server/src/services/auth.service.js): `server/src/services/auth.service.js`
- [Token protection](https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/auth.middleware.js): `server/src/middleware/auth.middleware.js`
- [Token signing](https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/jwt.js): `server/src/utils/jwt.js`

### User identity

- [User model](https://github.com/kphuyal8979/dineflow/blob/master/server/src/models/User.js): `server/src/models/User.js`
- **MongoDB**

### Runtime support

- [Async wrapper](https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/async-handler.js): `server/src/utils/async-handler.js`
- [Auth errors](https://github.com/kphuyal8979/dineflow/blob/master/server/src/utils/app-error.js): `server/src/utils/app-error.js`
- [Environment config](https://github.com/kphuyal8979/dineflow/blob/master/server/src/config/env.js): `server/src/config/env.js`
- [DB connector](https://github.com/kphuyal8979/dineflow/blob/master/server/src/lib/db.js): `server/src/lib/db.js`
- [Error handling](https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/error.middleware.js): `server/src/middleware/error.middleware.js`
- [Not-found handling](https://github.com/kphuyal8979/dineflow/blob/master/server/src/middleware/not-found.middleware.js): `server/src/middleware/not-found.middleware.js`
- [Rate limiter](https://github.com/kphuyal8979/dineflow/blob/master/server/src/lib/limiter.js): `server/src/lib/limiter.js`

### Other components

- **API client**

## Connections

- API client → Auth routes: requests
- Auth routes → Auth controller: dispatches (evidence: `server/src/routes/auth.route.js`)
- Auth routes → Token protection: protects profile (evidence: `server/src/routes/auth.route.js`)
- Auth controller → Credential validation: validates input (evidence: `server/src/controllers/auth.controller.js`)
- Auth controller → Auth service: calls auth (evidence: `server/src/controllers/auth.controller.js`)
- Auth controller → Async wrapper: wraps handlers (evidence: `server/src/controllers/auth.controller.js`)
- Auth controller → API client: returns responses (evidence: `server/src/controllers/auth.controller.js`)
- Auth service → User model: reads and writes (evidence: `server/src/services/auth.service.js`)
- Auth service → Token signing: signs tokens (evidence: `server/src/services/auth.service.js`)
- Auth service → Auth errors: raises errors (evidence: `server/src/services/auth.service.js`)
- Token protection → User model: loads user (evidence: `server/src/middleware/auth.middleware.js`)
- Token protection → Environment config: reads secret (evidence: `server/src/middleware/auth.middleware.js`)
- Token protection → Auth controller: sets request user (evidence: `server/src/routes/auth.route.js`)
- User model → MongoDB: persists records
- Token signing → Environment config: reads secret (evidence: `server/src/utils/jwt.js`)
- Health route → Environment config: reads environment (evidence: `server/src/routes/health.route.js`)
- DB connector → Environment config: reads connection URI (evidence: `server/src/lib/db.js`)
