# muthugopi/authentication architecture

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

- Interactive diagram: https://gitdiagram.com/muthugopi/authentication
- Repository: https://github.com/muthugopi/authentication

## Overview

Authenticate is a React/Express authentication and user-management application. Users navigate the frontend to register, log in, view profiles, and access public messaging or administration features; frontend pages communicate with the backend, whose routes dispatch to controllers and persistence models. The backend also includes role authorization, account promotion, contact/message handling, and activity analytics. The README documents cookie-based sessions and Passport local authentication, while the sampled login flow also issues JWTs; unsampled page/API details are represented only where the README or source index supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/muthugopi/authentication/blob/main/frontend/src/App.jsx) (Router shell), [`frontend/src/config/api.js`](https://github.com/muthugopi/authentication/blob/main/frontend/src/config/api.js) (API endpoint config), [`backend/src/models/user.model.mjs`](https://github.com/muthugopi/authentication/blob/main/backend/src/models/user.model.mjs) (User records), [`backend/src/index.mjs`](https://github.com/muthugopi/authentication/blob/main/backend/src/index.mjs) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["Router shell<br/>[App.jsx]"]
  node_landing["Landing<br/>[Landing.jsx]"]
  node_register["Registration<br/>[Register.jsx]"]
  node_login["Login<br/>[Login.jsx]"]
  node_profile["Profile<br/>[Profile.jsx]"]
  node_adminui["Admin panel<br/>[AdminPanel.jsx]"]
  node_promoteui["Admin verification<br/>[MakeMeAdmin.jsx]"]
  node_messageui["Public messages<br/>[PublicMessage.jsx]"]
  node_api["API endpoint config<br/>[api.js]"]
end

subgraph group_server["HTTP backend"]
  node_backend["Express application<br/>[index.mjs]"]
  node_authroutes["Auth routes<br/>[auth.routes.mjs]"]
  node_userroutes["User routes<br/>[user.routes.mjs]"]
  node_publicroutes["Public routes<br/>[public.routes.mjs]"]
  node_messageroutes["Message routes<br/>[message.routes.mjs]"]
  node_contactroutes["Contact routes<br/>[contact.routes.mjs]"]
  node_userctrl["User operations"]
  node_msgctrl["Message operations"]
  node_contactctrl["Contact operations"]
end

subgraph group_identity["Identity and roles"]
  node_authctrl["Authentication controller"]
  node_promotion["Role promotion"]
  node_authmw["Token authentication"]
  node_authorize["Role authorization"]
  node_passport["Local strategy<br/>[passport.mjs]"]
  node_hash["Password hashing<br/>[hash.mjs]"]
end

subgraph group_data["Persistence and activity"]
  node_logsctrl["Activity analytics"]
  node_users[("User records<br/>[user.model.mjs]")]
  node_messages[("Message records<br/>[message.model.mjs]")]
  node_contacts[("Contact records<br/>[contact.model.mjs]")]
  node_activity[("Activity log")]
  node_database[("MySQL connection<br/>[db.mjs]")]
end

node_visitor(("User"))

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_adminui
node_app -->|"routes to"| node_promoteui
node_app -->|"routes to"| node_messageui
node_landing -->|"reads config"| node_api
node_register -->|"reads config"| node_api
node_login -->|"reads config"| node_api
node_profile -->|"reads config"| node_api
node_adminui -->|"reads config"| node_api
node_promoteui -->|"reads config"| node_api
node_messageui -->|"reads config"| node_api
node_api -.->|"communicates with"| node_backend
node_backend -->|"mounts"| node_authroutes
node_backend -->|"mounts"| node_publicroutes
node_backend -->|"mounts"| node_messageroutes
node_backend -->|"mounts"| node_userroutes
node_backend -->|"mounts"| node_contactroutes
node_authroutes -->|"dispatches"| node_authctrl
node_authroutes -->|"dispatches"| node_promotion
node_authroutes -->|"guards route"| node_authorize
node_userroutes -->|"dispatches"| node_userctrl
node_userroutes -->|"guards route"| node_authmw
node_userroutes -->|"guards route"| node_authorize
node_publicroutes -->|"dispatches"| node_logsctrl
node_publicroutes -->|"guards analytics"| node_authorize
node_publicroutes -->|"counts records"| node_users
node_messageroutes -->|"dispatches"| node_msgctrl
node_contactroutes -->|"dispatches"| node_contactctrl
node_contactroutes -->|"guards route"| node_authorize
node_authctrl -->|"authenticates with"| node_passport
node_authctrl -->|"hashes password"| node_hash
node_authctrl -->|"reads and writes"| node_users
node_authctrl -->|"records events"| node_activity
node_promotion -->|"updates roles"| node_users
node_passport -->|"looks up account"| node_users
node_passport -->|"checks password"| node_hash
node_userctrl -->|"manages records"| node_users
node_msgctrl -->|"manages records"| node_messages
node_contactctrl -->|"manages records"| node_contacts
node_logsctrl -->|"reads and writes"| node_activity
node_logsctrl -->|"reads accounts"| node_users
node_users -->|"uses connection"| node_database
node_messages -->|"uses connection"| node_database
node_contacts -->|"uses connection"| node_database

click node_app "https://github.com/muthugopi/authentication/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Landing.jsx"
click node_register "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Register.jsx"
click node_login "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Login.jsx"
click node_profile "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Profile.jsx"
click node_adminui "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/AdminPanel.jsx"
click node_promoteui "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/MakeMeAdmin.jsx"
click node_messageui "https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/PublicMessage.jsx"
click node_api "https://github.com/muthugopi/authentication/blob/main/frontend/src/config/api.js"
click node_backend "https://github.com/muthugopi/authentication/blob/main/backend/src/index.mjs"
click node_authroutes "https://github.com/muthugopi/authentication/blob/main/backend/src/routes/auth.routes.mjs"
click node_userroutes "https://github.com/muthugopi/authentication/blob/main/backend/src/routes/user.routes.mjs"
click node_publicroutes "https://github.com/muthugopi/authentication/blob/main/backend/src/routes/public.routes.mjs"
click node_messageroutes "https://github.com/muthugopi/authentication/blob/main/backend/src/routes/message.routes.mjs"
click node_contactroutes "https://github.com/muthugopi/authentication/blob/main/backend/src/routes/contact.routes.mjs"
click node_authctrl "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/auth.controller.mjs"
click node_promotion "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/makeMeAdmin.controller.mjs"
click node_authmw "https://github.com/muthugopi/authentication/blob/main/backend/src/middlewares/auth.middleware.mjs"
click node_authorize "https://github.com/muthugopi/authentication/blob/main/backend/src/middlewares/authorize.middleware.mjs"
click node_passport "https://github.com/muthugopi/authentication/blob/main/backend/src/utils/passport.mjs"
click node_hash "https://github.com/muthugopi/authentication/blob/main/backend/src/utils/hash.mjs"
click node_userctrl "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/user.controller.mjs"
click node_msgctrl "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/message.controller.mjs"
click node_contactctrl "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/contact.controller.mjs"
click node_logsctrl "https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/logs.controller.mjs"
click node_users "https://github.com/muthugopi/authentication/blob/main/backend/src/models/user.model.mjs"
click node_messages "https://github.com/muthugopi/authentication/blob/main/backend/src/models/message.model.mjs"
click node_contacts "https://github.com/muthugopi/authentication/blob/main/backend/src/models/contact.model.mjs"
click node_activity "https://github.com/muthugopi/authentication/blob/main/backend/src/models/activityLog.model.mjs"
click node_database "https://github.com/muthugopi/authentication/blob/main/backend/src/config/db.mjs"

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_landing,node_register,node_login,node_profile,node_adminui,node_promoteui,node_messageui,node_api,node_visitor toneBlue
class node_backend,node_authroutes,node_userroutes,node_publicroutes,node_messageroutes,node_contactroutes,node_userctrl,node_msgctrl,node_contactctrl toneAmber
class node_authctrl,node_promotion,node_authmw,node_authorize,node_passport,node_hash toneMint
class node_logsctrl,node_users,node_messages,node_contacts,node_activity,node_database toneRose
```

## Components

### Frontend experience

- [Router shell](https://github.com/muthugopi/authentication/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Landing.jsx): `frontend/src/pages/Landing.jsx`
- [Registration](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [Login](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Profile](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/Profile.jsx): `frontend/src/pages/Profile.jsx`
- [Admin panel](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/AdminPanel.jsx): `frontend/src/pages/AdminPanel.jsx`
- [Admin verification](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/MakeMeAdmin.jsx): `frontend/src/pages/MakeMeAdmin.jsx`
- [Public messages](https://github.com/muthugopi/authentication/blob/main/frontend/src/pages/PublicMessage.jsx): `frontend/src/pages/PublicMessage.jsx`
- [API endpoint config](https://github.com/muthugopi/authentication/blob/main/frontend/src/config/api.js): `frontend/src/config/api.js`

### HTTP backend

- [Express application](https://github.com/muthugopi/authentication/blob/main/backend/src/index.mjs): `backend/src/index.mjs`
- [Auth routes](https://github.com/muthugopi/authentication/blob/main/backend/src/routes/auth.routes.mjs): `backend/src/routes/auth.routes.mjs`
- [User routes](https://github.com/muthugopi/authentication/blob/main/backend/src/routes/user.routes.mjs): `backend/src/routes/user.routes.mjs`
- [Public routes](https://github.com/muthugopi/authentication/blob/main/backend/src/routes/public.routes.mjs): `backend/src/routes/public.routes.mjs`
- [Message routes](https://github.com/muthugopi/authentication/blob/main/backend/src/routes/message.routes.mjs): `backend/src/routes/message.routes.mjs`
- [Contact routes](https://github.com/muthugopi/authentication/blob/main/backend/src/routes/contact.routes.mjs): `backend/src/routes/contact.routes.mjs`
- [User operations](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/user.controller.mjs): `backend/src/controllers/user.controller.mjs`
- [Message operations](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/message.controller.mjs): `backend/src/controllers/message.controller.mjs`
- [Contact operations](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/contact.controller.mjs): `backend/src/controllers/contact.controller.mjs`

### Identity and roles

- [Authentication controller](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/auth.controller.mjs): `backend/src/controllers/auth.controller.mjs`
- [Role promotion](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/makeMeAdmin.controller.mjs): `backend/src/controllers/makeMeAdmin.controller.mjs`
- [Token authentication](https://github.com/muthugopi/authentication/blob/main/backend/src/middlewares/auth.middleware.mjs): `backend/src/middlewares/auth.middleware.mjs`
- [Role authorization](https://github.com/muthugopi/authentication/blob/main/backend/src/middlewares/authorize.middleware.mjs): `backend/src/middlewares/authorize.middleware.mjs`
- [Local strategy](https://github.com/muthugopi/authentication/blob/main/backend/src/utils/passport.mjs): `backend/src/utils/passport.mjs`
- [Password hashing](https://github.com/muthugopi/authentication/blob/main/backend/src/utils/hash.mjs): `backend/src/utils/hash.mjs`

### Persistence and activity

- [Activity analytics](https://github.com/muthugopi/authentication/blob/main/backend/src/controllers/logs.controller.mjs): `backend/src/controllers/logs.controller.mjs`
- [User records](https://github.com/muthugopi/authentication/blob/main/backend/src/models/user.model.mjs): `backend/src/models/user.model.mjs`
- [Message records](https://github.com/muthugopi/authentication/blob/main/backend/src/models/message.model.mjs): `backend/src/models/message.model.mjs`
- [Contact records](https://github.com/muthugopi/authentication/blob/main/backend/src/models/contact.model.mjs): `backend/src/models/contact.model.mjs`
- [Activity log](https://github.com/muthugopi/authentication/blob/main/backend/src/models/activityLog.model.mjs): `backend/src/models/activityLog.model.mjs`
- [MySQL connection](https://github.com/muthugopi/authentication/blob/main/backend/src/config/db.mjs): `backend/src/config/db.mjs`

### Other components

- **User**

## Connections

- User → Router shell: uses (evidence: `frontend/src/App.jsx`)
- Router shell → Landing: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Registration: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Login: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Profile: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Admin panel: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Admin verification: routes to (evidence: `frontend/src/App.jsx`)
- Router shell → Public messages: routes to (evidence: `frontend/src/App.jsx`)
- Landing → API endpoint config: reads config (evidence: `frontend/src/pages/Landing.jsx`)
- Registration → API endpoint config: reads config (evidence: `frontend/src/pages/Register.jsx`)
- Login → API endpoint config: reads config (evidence: `frontend/src/pages/Login.jsx`)
- Profile → API endpoint config: reads config (evidence: `frontend/src/pages/Profile.jsx`)
- Admin panel → API endpoint config: reads config (evidence: `frontend/src/pages/AdminPanel.jsx`)
- Admin verification → API endpoint config: reads config (evidence: `frontend/src/pages/MakeMeAdmin.jsx`)
- Public messages → API endpoint config: reads config (evidence: `frontend/src/pages/PublicMessage.jsx`)
- API endpoint config → Express application: communicates with
- Express application → Auth routes: mounts (evidence: `backend/src/index.mjs`)
- Express application → Public routes: mounts (evidence: `backend/src/index.mjs`)
- Express application → Message routes: mounts (evidence: `backend/src/index.mjs`)
- Express application → User routes: mounts (evidence: `backend/src/index.mjs`)
- Express application → Contact routes: mounts (evidence: `backend/src/index.mjs`)
- Auth routes → Authentication controller: dispatches (evidence: `backend/src/routes/auth.routes.mjs`)
- Auth routes → Role promotion: dispatches (evidence: `backend/src/routes/auth.routes.mjs`)
- Auth routes → Role authorization: guards route (evidence: `backend/src/routes/auth.routes.mjs`)
- User routes → User operations: dispatches (evidence: `backend/src/routes/user.routes.mjs`)
- User routes → Token authentication: guards route (evidence: `backend/src/routes/user.routes.mjs`)
- User routes → Role authorization: guards route (evidence: `backend/src/routes/user.routes.mjs`)
- Public routes → Activity analytics: dispatches (evidence: `backend/src/routes/public.routes.mjs`)
- Public routes → Role authorization: guards analytics (evidence: `backend/src/routes/public.routes.mjs`)
- Public routes → User records: counts records (evidence: `backend/src/routes/public.routes.mjs`)
- Message routes → Message operations: dispatches (evidence: `backend/src/routes/message.routes.mjs`)
- Contact routes → Contact operations: dispatches (evidence: `backend/src/routes/contact.routes.mjs`)
- Contact routes → Role authorization: guards route (evidence: `backend/src/routes/contact.routes.mjs`)
- Authentication controller → Local strategy: authenticates with (evidence: `backend/src/controllers/auth.controller.mjs`)
- Authentication controller → Password hashing: hashes password (evidence: `backend/src/controllers/auth.controller.mjs`)
- Authentication controller → User records: reads and writes (evidence: `backend/src/controllers/auth.controller.mjs`)
- Authentication controller → Activity log: records events (evidence: `backend/src/controllers/auth.controller.mjs`)
- Role promotion → User records: updates roles (evidence: `backend/src/controllers/makeMeAdmin.controller.mjs`)
- Local strategy → User records: looks up account (evidence: `backend/src/utils/passport.mjs`)
- Local strategy → Password hashing: checks password (evidence: `backend/src/utils/passport.mjs`)
- User operations → User records: manages records (evidence: `backend/src/controllers/user.controller.mjs`)
- Message operations → Message records: manages records (evidence: `backend/src/controllers/message.controller.mjs`)
- Contact operations → Contact records: manages records (evidence: `backend/src/controllers/contact.controller.mjs`)
- Activity analytics → Activity log: reads and writes (evidence: `backend/src/controllers/logs.controller.mjs`)
- Activity analytics → User records: reads accounts (evidence: `backend/src/controllers/logs.controller.mjs`)
- User records → MySQL connection: uses connection (evidence: `backend/src/models/user.model.mjs`)
- Message records → MySQL connection: uses connection (evidence: `backend/src/models/message.model.mjs`)
- Contact records → MySQL connection: uses connection (evidence: `backend/src/models/contact.model.mjs`)
