# shageen376/employee-list-jwt- architecture

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

- Interactive diagram: https://gitdiagram.com/shageen376/employee-list-jwt-
- Repository: https://github.com/shageen376/employee-list-jwt-

## Overview

This repository implements a small Express authentication API. Clients reach registration and login routes, which validate credentials, use the User model for account lookup and creation, and return a response or signed JWT. A separate protected products route verifies JWTs before returning placeholder data. The database connection is configured from MONGO_URI. The README is empty; the sampled routes import middleware/auth.js but do not use it, so it is shown as an unconnected component rather than as part of the protected-route flow.

Main entry points: [`routes/auth.js`](https://github.com/shageen376/employee-list-jwt-/blob/main/routes/auth.js) (Auth routes), [`server.js`](https://github.com/shageen376/employee-list-jwt-/blob/main/server.js) (Express server), [`controllers/authController.js`](https://github.com/shageen376/employee-list-jwt-/blob/main/controllers/authController.js) (Auth controller), [`db.js`](https://github.com/shageen376/employee-list-jwt-/blob/main/db.js) (Mongo connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Auth routes<br/>[auth.js]"]
end

subgraph group_auth["Authentication"]
  node_controller["Auth controller<br/>[authController.js]"]
  node_jwtutils["JWT verification<br/>[jwtUtils.js]"]
  node_authmiddleware["Auth middleware<br/>[auth.js]"]
end

subgraph group_persistence["Persistence"]
  node_user["User model<br/>[User.js]"]
  node_db["Mongo connection<br/>[db.js]"]
end

node_client(("API client"))
node_mongodb[("MongoDB")]

node_client -->|"sends requests"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"handles registration and login"| node_controller
node_routes -->|"verifies protected requests"| node_jwtutils
node_controller -->|"looks up and saves"| node_user
node_db -->|"connects using MONGO_URI"| node_mongodb
node_routes -->|"returns protected data"| node_client

click node_server "https://github.com/shageen376/employee-list-jwt-/blob/main/server.js"
click node_routes "https://github.com/shageen376/employee-list-jwt-/blob/main/routes/auth.js"
click node_controller "https://github.com/shageen376/employee-list-jwt-/blob/main/controllers/authController.js"
click node_jwtutils "https://github.com/shageen376/employee-list-jwt-/blob/main/utils/jwtUtils.js"
click node_authmiddleware "https://github.com/shageen376/employee-list-jwt-/blob/main/middleware/auth.js"
click node_user "https://github.com/shageen376/employee-list-jwt-/blob/main/models/User.js"
click node_db "https://github.com/shageen376/employee-list-jwt-/blob/main/db.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_server,node_routes,node_client toneBlue
class node_controller,node_jwtutils,node_authmiddleware,node_mongodb toneAmber
class node_user,node_db toneMint
```

## Components

### HTTP API

- [Express server](https://github.com/shageen376/employee-list-jwt-/blob/main/server.js): `server.js`
- [Auth routes](https://github.com/shageen376/employee-list-jwt-/blob/main/routes/auth.js): `routes/auth.js`

### Authentication

- [Auth controller](https://github.com/shageen376/employee-list-jwt-/blob/main/controllers/authController.js): `controllers/authController.js`
- [JWT verification](https://github.com/shageen376/employee-list-jwt-/blob/main/utils/jwtUtils.js): `utils/jwtUtils.js`
- [Auth middleware](https://github.com/shageen376/employee-list-jwt-/blob/main/middleware/auth.js): `middleware/auth.js`

### Persistence

- [User model](https://github.com/shageen376/employee-list-jwt-/blob/main/models/User.js): `models/User.js`
- [Mongo connection](https://github.com/shageen376/employee-list-jwt-/blob/main/db.js): `db.js`

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Express server: sends requests (evidence: `server.js`)
- Express server → Auth routes: mounts routes (evidence: `server.js`)
- Auth routes → Auth controller: handles registration and login (evidence: `routes/auth.js`)
- Auth routes → JWT verification: verifies protected requests (evidence: `routes/auth.js`)
- Auth controller → User model: looks up and saves (evidence: `controllers/authController.js`)
- Mongo connection → MongoDB: connects using MONGO_URI (evidence: `db.js`)
- Auth routes → API client: returns protected data (evidence: `routes/auth.js`)
