# rawathimanshu05/authsystem architecture

> Architecture diagram of the GitHub repository rawathimanshu05/authsystem, 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/rawathimanshu05/authsystem
- Repository: https://github.com/rawathimanshu05/authsystem

## Overview

AuthSystem is a MERN authentication app whose visible workflow is registration, login, and a locally displayed profile. The frontend submits credentials to the Express API; registration stores a user, while login verifies credentials and returns a JWT that the browser stores. The app uses that stored token to restore its client-side authenticated state and gate the profile route. The sampled routes do not show protected profile API access, and the imported authorization middleware is not visibly invoked, so no such flow is inferred.

Main entry points: [`AuthSystem/frontend/login/src/App.js`](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/App.js) (App routing), [`AuthSystem/backend/Routes/Userroutes.js`](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Routes/Userroutes.js) (User API routes), [`AuthSystem/frontend/login/src/Components/Login.jsx`](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Login.jsx) (Login form), [`AuthSystem/frontend/login/src/Components/Register.jsx`](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Register.jsx) (Registration form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["App routing<br/>[App.js]"]
  node_refresh["Session restore<br/>[Refreshhandler.js]"]
  node_register["Registration form<br/>[Register.jsx]"]
  node_login["Login form<br/>[Login.jsx]"]
  node_profile["Profile and logout<br/>[Profile.jsx]"]
  node_notifications["Toast messages<br/>[Util.js]"]
end

subgraph group_backend["Backend API"]
  node_server["HTTP server<br/>[index.js]"]
  node_user_routes["User API routes<br/>[Userroutes.js]"]
  node_auth_middleware["JWT authorization<br/>[Auth.js]"]
end

subgraph group_persistence["Persistence"]
  node_user_model["User model<br/>[UserModel.js]"]
  node_db_connection["Mongo connection<br/>[db.js]"]
end

node_user(("User"))
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_register
node_app -->|"renders"| node_login
node_app -->|"gates route"| node_profile
node_app -->|"mounts"| node_refresh
node_refresh -->|"sets auth state"| node_app
node_register -->|"posts registration"| node_user_routes
node_login -->|"posts login"| node_user_routes
node_login -->|"navigates after login"| node_profile
node_register -->|"shows feedback"| node_notifications
node_login -->|"shows feedback"| node_notifications
node_profile -->|"shows feedback"| node_notifications
node_server -->|"mounts API"| node_user_routes
node_user_routes -->|"queries and saves"| node_user_model
node_db_connection -->|"connects"| node_mongodb
node_user_routes -.->|"imports only"| node_auth_middleware
node_user_model -.->|"persists user records"| node_mongodb

click node_app "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/App.js"
click node_refresh "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Refreshhandler.js"
click node_register "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Register.jsx"
click node_login "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Login.jsx"
click node_profile "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Profile.jsx"
click node_notifications "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Util.js"
click node_server "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/index.js"
click node_user_routes "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Routes/Userroutes.js"
click node_auth_middleware "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Middleware/Auth.js"
click node_user_model "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Models/UserModel.js"
click node_db_connection "https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Models/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_app,node_refresh,node_register,node_login,node_profile,node_notifications,node_user toneBlue
class node_server,node_user_routes,node_auth_middleware,node_mongodb toneAmber
class node_user_model,node_db_connection toneMint
```

## Components

### Frontend

- [App routing](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/App.js): `AuthSystem/frontend/login/src/App.js`
- [Session restore](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Refreshhandler.js): `AuthSystem/frontend/login/src/Refreshhandler.js`
- [Registration form](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Register.jsx): `AuthSystem/frontend/login/src/Components/Register.jsx`
- [Login form](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Login.jsx): `AuthSystem/frontend/login/src/Components/Login.jsx`
- [Profile and logout](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Components/Profile.jsx): `AuthSystem/frontend/login/src/Components/Profile.jsx`
- [Toast messages](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/frontend/login/src/Util.js): `AuthSystem/frontend/login/src/Util.js`

### Backend API

- [HTTP server](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/index.js): `AuthSystem/backend/index.js`
- [User API routes](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Routes/Userroutes.js): `AuthSystem/backend/Routes/Userroutes.js`
- [JWT authorization](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Middleware/Auth.js): `AuthSystem/backend/Middleware/Auth.js`

### Persistence

- [User model](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Models/UserModel.js): `AuthSystem/backend/Models/UserModel.js`
- [Mongo connection](https://github.com/rawathimanshu05/authsystem/blob/main/AuthSystem/backend/Models/db.js): `AuthSystem/backend/Models/db.js`

### Other components

- **User**
- **MongoDB**

## Connections

- User → App routing: uses
- App routing → Registration form: renders (evidence: `AuthSystem/frontend/login/src/App.js`)
- App routing → Login form: renders (evidence: `AuthSystem/frontend/login/src/App.js`)
- App routing → Profile and logout: gates route (evidence: `AuthSystem/frontend/login/src/App.js`)
- App routing → Session restore: mounts (evidence: `AuthSystem/frontend/login/src/App.js`)
- Session restore → App routing: sets auth state (evidence: `AuthSystem/frontend/login/src/App.js`)
- Registration form → User API routes: posts registration (evidence: `AuthSystem/frontend/login/src/Components/Register.jsx`)
- Login form → User API routes: posts login (evidence: `AuthSystem/frontend/login/src/Components/Login.jsx`)
- Login form → Profile and logout: navigates after login (evidence: `AuthSystem/frontend/login/src/Components/Login.jsx`)
- Registration form → Toast messages: shows feedback (evidence: `AuthSystem/frontend/login/src/Components/Register.jsx`)
- Login form → Toast messages: shows feedback (evidence: `AuthSystem/frontend/login/src/Components/Login.jsx`)
- Profile and logout → Toast messages: shows feedback (evidence: `AuthSystem/frontend/login/src/Components/Profile.jsx`)
- HTTP server → User API routes: mounts API (evidence: `AuthSystem/backend/index.js`)
- User API routes → User model: queries and saves (evidence: `AuthSystem/backend/Routes/Userroutes.js`)
- Mongo connection → MongoDB: connects (evidence: `AuthSystem/backend/Models/db.js`)
- User API routes → JWT authorization: imports only (evidence: `AuthSystem/backend/Routes/Userroutes.js`)
- User model → MongoDB: persists user records
