# siddusanmukh/authentication_authorization architecture

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

- Interactive diagram: https://gitdiagram.com/siddusanmukh/authentication_authorization
- Repository: https://github.com/siddusanmukh/authentication_authorization

## Overview

This Express demo takes browser requests through signup, login, logout, and user-list routes. Signup hashes a password, stores a user, and issues a JWT cookie; login looks up the user, verifies the password, and issues the cookie on success. The app renders EJS pages for the forms and user view, while a Mongoose model connects to MongoDB. The graph reflects the sampled app and model code plus README-documented behavior; it does not imply JWT verification or protected-route middleware, which this example does not implement.

Main entry points: [`app.js`](https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js) (Express routes), [`models/user.js`](https://github.com/siddusanmukh/authentication_authorization/blob/main/models/user.js) (User model), [`views/home.ejs`](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/home.ejs) (Home page), [`views/signup.ejs`](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/signup.ejs) (Signup form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_home["Home page<br/>[home.ejs]"]
  node_signup_form["Signup form<br/>[signup.ejs]"]
  node_login_form["Login form<br/>[login.ejs]"]
  node_user_page["User page<br/>[userPage.ejs]"]
end

subgraph group_auth["Authentication routes"]
  node_app["Express routes<br/>[app.js]"]
  node_password_hash["Password hashing<br/>[app.js]"]
  node_jwt["JWT issuance<br/>[app.js]"]
  node_cookie["Token cookie<br/>[app.js]"]
end

subgraph group_data["User persistence"]
  node_user_model["User model<br/>[user.js]"]
  node_mongo[("MongoDB")]
end

node_visitor(("Browser visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"renders"| node_home
node_app -->|"renders"| node_signup_form
node_app -->|"renders"| node_login_form
node_app -->|"hashes passwords"| node_password_hash
node_app -->|"creates users"| node_user_model
node_app -->|"signs tokens"| node_jwt
node_app -->|"sets token"| node_cookie
node_app -->|"renders"| node_user_page
node_app -->|"finds user"| node_user_model
node_app -->|"compares password"| node_password_hash
node_app -->|"clears token"| node_cookie
node_app -->|"lists users"| node_user_model
node_user_model -->|"connects"| node_mongo
node_visitor -->|"receives cookie"| node_cookie

click node_app "https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js"
click node_home "https://github.com/siddusanmukh/authentication_authorization/blob/main/views/home.ejs"
click node_signup_form "https://github.com/siddusanmukh/authentication_authorization/blob/main/views/signup.ejs"
click node_login_form "https://github.com/siddusanmukh/authentication_authorization/blob/main/views/login.ejs"
click node_user_page "https://github.com/siddusanmukh/authentication_authorization/blob/main/views/userPage.ejs"
click node_password_hash "https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js"
click node_jwt "https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js"
click node_cookie "https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js"
click node_user_model "https://github.com/siddusanmukh/authentication_authorization/blob/main/models/user.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_home,node_signup_form,node_login_form,node_user_page,node_visitor toneBlue
class node_app,node_password_hash,node_jwt,node_cookie toneAmber
class node_user_model,node_mongo toneMint
```

## Components

### Web interface

- [Home page](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/home.ejs): `views/home.ejs`
- [Signup form](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/signup.ejs): `views/signup.ejs`
- [Login form](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/login.ejs): `views/login.ejs`
- [User page](https://github.com/siddusanmukh/authentication_authorization/blob/main/views/userPage.ejs): `views/userPage.ejs`

### Authentication routes

- [Express routes](https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js): `app.js`
- [Password hashing](https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js): `app.js`
- [JWT issuance](https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js): `app.js`
- [Token cookie](https://github.com/siddusanmukh/authentication_authorization/blob/main/app.js): `app.js`

### User persistence

- [User model](https://github.com/siddusanmukh/authentication_authorization/blob/main/models/user.js): `models/user.js`
- **MongoDB**

### Other components

- **Browser visitor**

## Connections

- Browser visitor → Express routes: sends requests (evidence: `README.md`)
- Express routes → Home page: renders (evidence: `app.js`)
- Express routes → Signup form: renders (evidence: `app.js`)
- Express routes → Login form: renders (evidence: `app.js`)
- Express routes → Password hashing: hashes passwords (evidence: `app.js`)
- Express routes → User model: creates users (evidence: `app.js`)
- Express routes → JWT issuance: signs tokens (evidence: `app.js`)
- Express routes → Token cookie: sets token (evidence: `app.js`)
- Express routes → User page: renders (evidence: `app.js`)
- Express routes → User model: finds user (evidence: `app.js`)
- Express routes → Password hashing: compares password (evidence: `app.js`)
- Express routes → Token cookie: clears token (evidence: `app.js`)
- Express routes → User model: lists users (evidence: `app.js`)
- User model → MongoDB: connects (evidence: `models/user.js`)
- Browser visitor → Token cookie: receives cookie (evidence: `README.md`)
