# sameer021000/jafar architecture

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

- Interactive diagram: https://gitdiagram.com/sameer021000/jafar
- Repository: https://github.com/sameer021000/jafar

## Overview

The repository contains an admin authentication portal backed by an Express/Mongoose API, plus two shop frontend directories with little or no evidenced runtime functionality. The main workflow is an admin submitting credentials, receiving a JWT, and having the session revalidated on reload; logout clears the client token. The graph also shows backend request validation and error handling. Shop capabilities are not described in the supplied README or source excerpts, so they are not expanded. Relationships are limited to calls and routes shown in excerpts or the source index.

Main entry points: [`frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx) (Login form), [`backend/Routes/AdminAuthRoutes.js`](https://github.com/sameer021000/jafar/blob/main/backend/Routes/AdminAuthRoutes.js) (Auth routes), [`frontend/JafarAdmin/src/Services/AdminAuthService.js`](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Services/AdminAuthService.js) (Auth client), [`frontend/JafarAdmin/src/App.js`](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/App.js) (Portal session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_admin_ui["Admin portal"]
  node_app["Portal session<br/>[App.js]"]
  node_login_screen["Login form<br/>[LoginScreen.jsx]"]
  node_form_input["Form input<br/>[FormInput.jsx]"]
  node_brand_header["Brand header<br/>[BrandHeader.jsx]"]
  node_primary_button["Submit button<br/>[PrimaryButton.jsx]"]
  node_auth_client["Auth client"]
  node_api_client["HTTP client<br/>[ApiService.js]"]
  node_token_manager["Token storage<br/>[TokenManager.js]"]
  node_validation_ui["Form validation<br/>[Validation.js]"]
end

subgraph group_api["Authentication API"]
  node_auth_routes["Auth routes<br/>[AdminAuthRoutes.js]"]
  node_request_validation["Request validation<br/>[ValidateRequest.js]"]
  node_credential_rules["Credential rules"]
  node_auth_controller["Auth controller"]
  node_error_handler["Error handler<br/>[ErrorHandler.js]"]
  node_token_verification["JWT verification"]
  node_server["API server<br/>[MainFile.js]"]
end

subgraph group_auth_core["Authentication core"]
  node_auth_service["Auth service"]
end

subgraph group_persistence["Persistence"]
  node_admin_model["Admin model<br/>[AdminModel.js]"]
  node_database[("MongoDB connection<br/>[Database.js]")]
end

node_admin(("Admin user"))

node_admin -->|"submits credentials"| node_login_screen
node_app -->|"renders"| node_login_screen
node_login_screen -->|"renders"| node_form_input
node_login_screen -->|"renders"| node_brand_header
node_login_screen -->|"renders"| node_primary_button
node_login_screen -->|"validates fields"| node_validation_ui
node_login_screen -->|"requests login"| node_auth_client
node_login_screen -->|"saves token"| node_token_manager
node_app -->|"verifies and logs out"| node_auth_client
node_app -->|"reads and clears"| node_token_manager
node_auth_client -->|"calls"| node_api_client
node_auth_client -->|"calls auth endpoints"| node_auth_routes
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"connects"| node_database
node_server -->|"registers middleware"| node_error_handler
node_auth_routes -->|"validates requests"| node_request_validation
node_auth_routes -->|"uses rules"| node_credential_rules
node_auth_routes -->|"protects verification"| node_token_verification
node_auth_routes -->|"dispatches requests"| node_auth_controller
node_auth_controller -->|"handles auth"| node_auth_service
node_auth_service -->|"reads and writes admins"| node_admin_model
node_admin_model -.->|"uses MongoDB connection"| node_database

click node_app "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/App.js"
click node_login_screen "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx"
click node_form_input "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/FormInput/FormInput.jsx"
click node_brand_header "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/BrandHeader/BrandHeader.jsx"
click node_primary_button "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/PrimaryButton/PrimaryButton.jsx"
click node_auth_client "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Services/AdminAuthService.js"
click node_api_client "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Api/ApiService.js"
click node_token_manager "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Utils/TokenManager.js"
click node_validation_ui "https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Utils/Validation.js"
click node_auth_routes "https://github.com/sameer021000/jafar/blob/main/backend/Routes/AdminAuthRoutes.js"
click node_request_validation "https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/ValidateRequest.js"
click node_credential_rules "https://github.com/sameer021000/jafar/blob/main/backend/Validations/AdminAuthValidation.js"
click node_auth_controller "https://github.com/sameer021000/jafar/blob/main/backend/Controllers/AdminAuthController.js"
click node_error_handler "https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/ErrorHandler.js"
click node_token_verification "https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/VerifyAdminToken.js"
click node_auth_service "https://github.com/sameer021000/jafar/blob/main/backend/Services/AdminAuthService.js"
click node_admin_model "https://github.com/sameer021000/jafar/blob/main/backend/Models/AdminModel.js"
click node_database "https://github.com/sameer021000/jafar/blob/main/backend/Config/Database.js"
click node_server "https://github.com/sameer021000/jafar/blob/main/backend/MainFile.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_login_screen,node_form_input,node_brand_header,node_primary_button,node_auth_client,node_api_client,node_token_manager,node_validation_ui,node_admin toneBlue
class node_auth_routes,node_request_validation,node_credential_rules,node_auth_controller,node_error_handler,node_token_verification,node_server toneAmber
class node_auth_service toneMint
class node_admin_model,node_database toneRose
```

## Components

### Admin portal

- [Portal session](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/App.js): `frontend/JafarAdmin/src/App.js`
- [Login form](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx): `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`
- [Form input](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/FormInput/FormInput.jsx): `frontend/JafarAdmin/src/Components/Common/FormInput/FormInput.jsx`
- [Brand header](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/BrandHeader/BrandHeader.jsx): `frontend/JafarAdmin/src/Components/Common/BrandHeader/BrandHeader.jsx`
- [Submit button](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Components/Common/PrimaryButton/PrimaryButton.jsx): `frontend/JafarAdmin/src/Components/Common/PrimaryButton/PrimaryButton.jsx`
- [Auth client](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Services/AdminAuthService.js): `frontend/JafarAdmin/src/Services/AdminAuthService.js`
- [HTTP client](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Api/ApiService.js): `frontend/JafarAdmin/src/Api/ApiService.js`
- [Token storage](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Utils/TokenManager.js): `frontend/JafarAdmin/src/Utils/TokenManager.js`
- [Form validation](https://github.com/sameer021000/jafar/blob/main/frontend/JafarAdmin/src/Utils/Validation.js): `frontend/JafarAdmin/src/Utils/Validation.js`

### Authentication API

- [Auth routes](https://github.com/sameer021000/jafar/blob/main/backend/Routes/AdminAuthRoutes.js): `backend/Routes/AdminAuthRoutes.js`
- [Request validation](https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/ValidateRequest.js): `backend/Middlewares/ValidateRequest.js`
- [Credential rules](https://github.com/sameer021000/jafar/blob/main/backend/Validations/AdminAuthValidation.js): `backend/Validations/AdminAuthValidation.js`
- [Auth controller](https://github.com/sameer021000/jafar/blob/main/backend/Controllers/AdminAuthController.js): `backend/Controllers/AdminAuthController.js`
- [Error handler](https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/ErrorHandler.js): `backend/Middlewares/ErrorHandler.js`
- [JWT verification](https://github.com/sameer021000/jafar/blob/main/backend/Middlewares/VerifyAdminToken.js): `backend/Middlewares/VerifyAdminToken.js`
- [API server](https://github.com/sameer021000/jafar/blob/main/backend/MainFile.js): `backend/MainFile.js`

### Authentication core

- [Auth service](https://github.com/sameer021000/jafar/blob/main/backend/Services/AdminAuthService.js): `backend/Services/AdminAuthService.js`

### Persistence

- [Admin model](https://github.com/sameer021000/jafar/blob/main/backend/Models/AdminModel.js): `backend/Models/AdminModel.js`
- [MongoDB connection](https://github.com/sameer021000/jafar/blob/main/backend/Config/Database.js): `backend/Config/Database.js`

### Other components

- **Admin user**

## Connections

- Admin user → Login form: submits credentials (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Portal session → Login form: renders (evidence: `frontend/JafarAdmin/src/App.js`)
- Login form → Form input: renders (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Login form → Brand header: renders (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Login form → Submit button: renders (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Login form → Form validation: validates fields (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Login form → Auth client: requests login (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Login form → Token storage: saves token (evidence: `frontend/JafarAdmin/src/Components/LoginScreen/LoginScreen.jsx`)
- Portal session → Auth client: verifies and logs out (evidence: `frontend/JafarAdmin/src/App.js`)
- Portal session → Token storage: reads and clears (evidence: `frontend/JafarAdmin/src/App.js`)
- Auth client → HTTP client: calls (evidence: `frontend/JafarAdmin/src/Services/AdminAuthService.js`)
- Auth client → Auth routes: calls auth endpoints (evidence: `frontend/JafarAdmin/src/Services/AdminAuthService.js`)
- API server → Auth routes: mounts routes (evidence: `backend/MainFile.js`)
- API server → MongoDB connection: connects (evidence: `backend/MainFile.js`)
- API server → Error handler: registers middleware (evidence: `backend/MainFile.js`)
- Auth routes → Request validation: validates requests (evidence: `backend/Routes/AdminAuthRoutes.js`)
- Auth routes → Credential rules: uses rules (evidence: `backend/Routes/AdminAuthRoutes.js`)
- Auth routes → JWT verification: protects verification (evidence: `backend/Routes/AdminAuthRoutes.js`)
- Auth routes → Auth controller: dispatches requests (evidence: `backend/Routes/AdminAuthRoutes.js`)
- Auth controller → Auth service: handles auth (evidence: `backend/Controllers/AdminAuthController.js`)
- Auth service → Admin model: reads and writes admins (evidence: `backend/Services/AdminAuthService.js`)
- Admin model → MongoDB connection: uses MongoDB connection
