# rushikeshghodke/authsys-local-minikube architecture

> Architecture diagram of the GitHub repository rushikeshghodke/authsys-local-minikube, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rushikeshghodke/authsys-local-minikube
- Repository: https://github.com/rushikeshghodke/authsys-local-minikube

## Overview

#### 1. Purpose and system boundary
Auth-Sys is a container-ready full-stack authentication system: a React client manages registration, login, profile, password, and avatar workflows; an Express API owns authentication and persistence; MySQL stores user identity/session state; Cloudinary is the optional avatar object store. Main application entry points are `frontend/src/main.jsx` and `backend/index.js`.

#### 2. Client application and session state
The Vite/React SPA renders the application shell and page-level auth/profile experiences. `AuthContext` is the client-side identity/session boundary; pages and navigation consume it to control authenticated UI and invoke API operations.
- `frontend/src/App.jsx`
- `frontend/src/context/AuthContext.jsx`
- `frontend/src/utils/api.js`

Control flow: browser loads the Vite-built SPA, routes through landing/login/register/home/profile views, and sends requests to the configured `/api/v1` backend. Authentication material is expected to be handled through JWTs and HTTP-only cookies, rather than exposing token management broadly in page components.

#### 3. API server and route boundary
The Node.js/Express server exposes health and versioned REST endpoints, with auth routes mounted beneath `/api/v1/auth`. It is the trust boundary between browser input and protected user data.
- `backend/index.js`
- `backend/routes/auth.routes.js`
- `backend/controllers/auth.controller.js`

Route handlers implement registration, login/logout, refresh, current-user retrieval, password change, profile update, and avatar update. Async/error response conventions centralize controller failures and API result shapes.

#### 4. Authentication and upload pipeline
Protected operations pass through JWT verification before reaching controllers. Registration/login validate identity, hash/check passwords with bcrypt, create/sign JWT access and refresh state, and persist refresh-token/session data. Avatar mutation crosses a multipart boundary before external upload.
- `backend/middlewares/auth.middleware.js`
- `backend/middlewares/multer.middleware.js`
- `backend/utils/cloudinary.js`

Control flow: request → route middleware (JWT or Multer as applicable) → controller → MySQL and, for avatars, Cloudinary → standardized API/cookie response. Cloudinary credentials are an external-service boundary and should remain server-side.

#### 5. Persistence model
MySQL is the authoritative state store for users, password hashes, avatar URLs, and refresh tokens. The backend database adapter is the sole application-facing database integration point; schema initialization is separate from runtime server startup.
- `backend/db/index.js`
- `backend/db/schema.sql`

This creates a material consistency boundary: auth-token issuance, password changes, profile updates, and logout/refresh behavior depend on durable user-row updates.

#### 6. Runtime packaging and deployment
Frontend and backend have independent Docker images; production frontend is served through Nginx according to the stated runtime model. Kubernetes manifests deploy frontend, backend, and MySQL as separately addressable workloads, exposing them through Services and ingress.
- `frontend/Dockerfile`
- `backend/Dockerfile`
- `k8s/ingress.yaml`

The MySQL deployment is stateful through persistent-volume and claim resources; backend configuration/secrets inject database, JWT, CORS, and Cloudinary settings.
- `k8s/mysql-pv.yaml`
- `k8s/mysql-pvc.yaml`
- `k8s/backend-secret.yaml`

#### 7. Helm distribution
The repository also packages the three deployable tiers as Helm charts, allowing independently parameterized releases with Deployment, Service, Ingress, and HPA templates.
- `helm-repo/authsys-frontend-chart/Chart.yaml`
- `helm-repo/authsys-backend-chart/Chart.yaml`
- `helm-repo/authsys-db-chart/Chart.yaml`

Main entry points: [`backend/controllers/auth.controller.js`](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/controllers/auth.controller.js) (Auth controller), [`k8s/ingress.yaml`](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/ingress.yaml) (Kubernetes workloads), [`backend/routes/auth.routes.js`](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/routes/auth.routes.js) (Auth routes), [`backend/db/schema.sql`](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/db/schema.sql) (MySQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client SPA"]
  node_browser(("Browser<br/>user runtime"))
  node_react_app["React application shell<br/>Vite React SPA<br/>[App.jsx]"]
  node_auth_context["Auth context<br/>client session boundary<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>HTTP client<br/>[api.js]"]
end

subgraph group_api["Auth API"]
  node_express_server["Express server<br/>API entry point<br/>[index.js]"]
  node_auth_routes["Auth routes<br/>REST route boundary<br/>[auth.routes.js]"]
  node_auth_guard["JWT verification<br/>auth middleware<br/>[auth.middleware.js]"]
  node_upload_middleware["Multipart upload<br/>Multer middleware"]
  node_auth_controller["Auth controller<br/>auth workflow layer<br/>[auth.controller.js]"]
end

subgraph group_data["State &amp; storage"]
  node_db_adapter["Database adapter<br/>persistence gateway<br/>[index.js]"]
  node_mysql[("MySQL<br/>authoritative identity store<br/>[schema.sql]")]
  node_cloudinary[("Cloudinary<br/>external avatar store<br/>[cloudinary.js]")]
end

subgraph group_delivery["Deployment"]
  node_frontend_image["Frontend image<br/>Docker build"]
  node_backend_image["Backend image<br/>Docker build"]
  node_kubernetes{{"Kubernetes workloads<br/>deployment topology<br/>[ingress.yaml]"}}
  node_mysql_storage[("MySQL persistent storage<br/>persistent volume claim<br/>[mysql-pvc.yaml]")]
  node_backend_secrets["Backend secrets<br/>runtime configuration"]
  node_helm_charts["Helm tier charts<br/>release packaging<br/>[Chart.yaml]"]
end

node_browser -->|"loads SPA"| node_react_app
node_react_app -->|"uses"| node_auth_context
node_auth_context -->|"invokes"| node_api_client
node_api_client -->|"/api/v1 requests"| node_express_server
node_express_server -->|"mounts"| node_auth_routes
node_auth_routes -->|"protected requests"| node_auth_guard
node_auth_routes -->|"avatar uploads"| node_upload_middleware
node_auth_guard -->|"verified requests"| node_auth_controller
node_upload_middleware -->|"multipart files"| node_auth_controller
node_auth_routes -->|"public auth requests"| node_auth_controller
node_auth_controller -->|"users and refresh state"| node_db_adapter
node_db_adapter -->|"durable reads/writes"| node_mysql
node_auth_controller -->|"avatar upload"| node_cloudinary
node_frontend_image -->|"frontend workload"| node_kubernetes
node_backend_image -->|"backend workload"| node_kubernetes
node_kubernetes -->|"database workload"| node_mysql
node_mysql_storage -->|"persistent data"| node_mysql
node_backend_secrets -.->|"injects backend config"| node_kubernetes
node_helm_charts -.->|"packages releases"| node_kubernetes

click node_react_app "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/App.jsx"
click node_auth_context "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/context/AuthContext.jsx"
click node_api_client "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/utils/api.js"
click node_express_server "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/index.js"
click node_auth_routes "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/routes/auth.routes.js"
click node_auth_guard "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/middlewares/auth.middleware.js"
click node_upload_middleware "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/middlewares/multer.middleware.js"
click node_auth_controller "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/controllers/auth.controller.js"
click node_db_adapter "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/db/index.js"
click node_mysql "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/db/schema.sql"
click node_cloudinary "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/utils/cloudinary.js"
click node_frontend_image "https://github.com/rushikeshghodke/authsys-local-minikube/tree/main/frontend/Dockerfile"
click node_backend_image "https://github.com/rushikeshghodke/authsys-local-minikube/tree/main/backend/Dockerfile"
click node_kubernetes "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/ingress.yaml"
click node_mysql_storage "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/mysql-pvc.yaml"
click node_backend_secrets "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/backend-secret.yaml"
click node_helm_charts "https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/helm-repo/authsys-backend-chart/Chart.yaml"

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_browser,node_react_app,node_auth_context,node_api_client toneBlue
class node_express_server,node_auth_routes,node_auth_guard,node_upload_middleware,node_auth_controller toneAmber
class node_db_adapter,node_mysql,node_cloudinary toneMint
class node_frontend_image,node_backend_image,node_kubernetes,node_mysql_storage,node_backend_secrets,node_helm_charts toneRose
```

## Components

### Client SPA

- **Browser**: user runtime
- [React application shell](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/App.jsx): Vite React SPA · `frontend/src/App.jsx`
- [Auth context](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/context/AuthContext.jsx): client session boundary · Provides identity state and auth operations to pages. · `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/frontend/src/utils/api.js): HTTP client · Targets the versioned backend API. · `frontend/src/utils/api.js`

### Auth API

- [Express server](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/index.js): API entry point · Owns health and versioned REST endpoints. · `backend/index.js`
- [Auth routes](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/routes/auth.routes.js): REST route boundary · Mounted under /api/v1/auth. · `backend/routes/auth.routes.js`
- [JWT verification](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/middlewares/auth.middleware.js): auth middleware · `backend/middlewares/auth.middleware.js`
- [Multipart upload](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/middlewares/multer.middleware.js): Multer middleware · `backend/middlewares/multer.middleware.js`
- [Auth controller](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/controllers/auth.controller.js): auth workflow layer · Handles registration, sessions, profiles, passwords, and avatars. · `backend/controllers/auth.controller.js`

### State & storage

- [Database adapter](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/db/index.js): persistence gateway · Sole application-facing database integration point. · `backend/db/index.js`
- [MySQL](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/db/schema.sql): authoritative identity store · Stores users, password hashes, avatars, and refresh tokens. · `backend/db/schema.sql`
- [Cloudinary](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/backend/utils/cloudinary.js): external avatar store · Optional server-side object storage boundary. · `backend/utils/cloudinary.js`

### Deployment

- [Frontend image](https://github.com/rushikeshghodke/authsys-local-minikube/tree/main/frontend/Dockerfile): Docker build · Production SPA is served by Nginx. · `frontend/Dockerfile`
- [Backend image](https://github.com/rushikeshghodke/authsys-local-minikube/tree/main/backend/Dockerfile): Docker build · `backend/Dockerfile`
- [Kubernetes workloads](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/ingress.yaml): deployment topology · Separately deploys frontend, backend, and MySQL behind Services and ingress. · `k8s/ingress.yaml`
- [MySQL persistent storage](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/mysql-pvc.yaml): persistent volume claim · Makes the database workload stateful. · `k8s/mysql-pvc.yaml`
- [Backend secrets](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/k8s/backend-secret.yaml): runtime configuration · Injects database, JWT, CORS, and Cloudinary settings. · `k8s/backend-secret.yaml`
- [Helm tier charts](https://github.com/rushikeshghodke/authsys-local-minikube/blob/main/helm-repo/authsys-backend-chart/Chart.yaml): release packaging · Separately parameterizes frontend, backend, and database releases. · `helm-repo/authsys-backend-chart/Chart.yaml`

## Connections

- Browser → React application shell: loads SPA
- React application shell → Auth context: uses
- Auth context → API client: invokes
- API client → Express server: /api/v1 requests · JWTs are carried in HTTP-only cookies.
- Express server → Auth routes: mounts
- Auth routes → JWT verification: protected requests
- Auth routes → Multipart upload: avatar uploads
- JWT verification → Auth controller: verified requests
- Multipart upload → Auth controller: multipart files
- Auth routes → Auth controller: public auth requests
- Auth controller → Database adapter: users and refresh state
- Database adapter → MySQL: durable reads/writes
- Auth controller → Cloudinary: avatar upload
- Frontend image → Kubernetes workloads: frontend workload
- Backend image → Kubernetes workloads: backend workload
- Kubernetes workloads → MySQL: database workload
- MySQL persistent storage → MySQL: persistent data
- Backend secrets → Kubernetes workloads: injects backend config
- Helm tier charts → Kubernetes workloads: packages releases
