# vishnuweb-a/aggregator-software architecture

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

- Interactive diagram: https://gitdiagram.com/vishnuweb-a/aggregator-software
- Repository: https://github.com/vishnuweb-a/aggregator-software

## Overview

1. **Top-level shape**
   This repository is a two-part system: a **React frontend** in `frontend/` and a **Node.js/Express backend** in the root `src/` tree. The README frames it as an “order → payment verification → shipment” workflow, but the code tree shows the implemented backend is centered on **authentication, wallet/accounting, parcels, shipments, and courier operations**.

2. **Frontend boundary**
   The frontend is a small Vite app (`frontend/src/main.jsx`, `App.jsx`) with pages for **Login**, **Register**, and **Dashboard**. `AuthContext.jsx` holds client-side auth state, `ProtectedRoute.jsx` guards authenticated views, and `api/axios.js` centralizes API calls to the backend. This suggests the UI is mostly a session-aware shell around backend workflows rather than a large standalone client.

3. **Backend bootstrap**
   The backend starts from `server.js`, which likely boots the Express app defined in `src/app.js`. Cross-cutting config lives in `src/config/config.js`, and `src/config/swagger.js` indicates the API is documented/exposed with Swagger. That makes the backend the primary system boundary for business logic and data mutation.

4. **HTTP API layer**
   Request handling is organized by domain controllers and routes:
   - `src/routes/user.auth.js` → `auth.controller.js`
   - `src/routes/wallet.route.js` → `wallet.controller.js`
   - `src/routes/courier.route.js` → courier-related logic
   - `parcel.controller.js` and `reciept.controller.js` are present even though their route files are not visible in the tree
   The pattern is classic Express: routes define endpoints, controllers own request/response logic, and the controllers likely orchestrate model/service calls.

5. **Domain model layer**
   Persistence models are separated by business area under `src/model/`:
   - `user.model.js`
   - `wallet.model.js`
   - `freezedWallet.model.js`
   - `walletTransition.model.js`
   - `parcel.model.js`
   - `shipment.model.js`
   - `courier.model.js`
   This points to a workflow where **users own wallets**, balances can be **frozen/unfrozen**, money movements are tracked as **wallet transitions**, and parcels progress into shipment and courier assignment.

6. **State and money movement**
   The presence of `wallet.model.js`, `freezedWallet.model.js`, and `walletTransition.model.js` is important architecturally: this is not just a balance field, it is an **accounting subsystem**. “Frozen” funds and transition records imply the backend protects against premature release/duplication of money-related state during order and shipment processing.

7. **Security and session control**
   `src/middleware/authCheck.middleware.js` is the main server-side trust boundary. Combined with JWT mention in the README and the auth route/controller pair, the architecture is: frontend stores/uses a token, Express middleware verifies it, and protected controllers only run after auth passes. On the client, `ProtectedRoute.jsx` mirrors this by preventing unauthenticated navigation.

8. **OTP and email services**
   `src/services/otp.service.js` and `src/services/mail.service.js` indicate registration/login or verification flows are backed by **server-generated OTPs** and **email delivery**. These are supporting services rather than primary request handlers, so they likely sit behind the auth controller and are used during identity verification or account activation.

9. **Infrastructure dependencies**
   `src/db/db.connect.js` is the database bootstrap, while `src/redis/redis.js` shows Redis is part of the runtime. That usually means the app uses Redis for short-lived state such as OTPs, tokens, rate-limiting, or workflow locks. Mongo-style model files suggest the primary datastore is document-oriented, with Redis as a fast auxiliary store.

10. **Workflow implied by the repository**
   The clearest runtime flow is:
   frontend login/register/dashboard → authenticated API call via Axios → Express route/controller → auth/money/shipment model updates → database/Redis side effects → response back to UI.
   In the product narrative, that maps to a trust-gated commerce flow where payment verification unlocks shipment, but in the current tree the tangible implementation is the backend domain structure that would support such a flow.

11. **What matters for an architecture diagram**
   Draw this repo as:
   - a **React client** with auth-gated pages
   - an **Express API** with domain controllers and middleware
   - a **persistence layer** split between primary DB models and Redis
   - a **services layer** for OTP/email side effects
   - a **workflow domain** around users, wallets, parcels, shipments, and couriers
   The key boundary is between the frontend’s session/UI concerns and the backend’s trusted business logic.

12. **Notable mismatch to keep in mind**
   The README emphasizes Razorpay/payment verification, but there are no payment gateway integration files in the tree. So the repository currently reads more like a **commerce operations backend with auth/wallet/shipment foundations** than a fully wired payment integration system. If you diagram it, keep payment gateway support as a product goal unless additional code exists outside the provided tree.

Main entry points: [`src/app.js`](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/app.js) (Express App), [`src/db/db.connect.js`](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/db/db.connect.js) (DB Connect), [`src/controller/auth.controller.js`](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/auth.controller.js) (Auth Controller), [`src/routes/courier.route.js`](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/courier.route.js) (Courier Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["UI Shell<br/>React app<br/>[main.jsx]"]
  node_frontend_pages["Pages<br/>views"]
  node_frontend_auth(("Auth State<br/>context<br/>[AuthContext.jsx]"))
  node_frontend_guard{{"Route Guard<br/>router guard<br/>[ProtectedRoute.jsx]"}}
  node_frontend_api["API Client<br/>HTTP client<br/>[axios.js]"]
end

subgraph group_backend["Backend"]
  node_server_entry["Server Entry<br/>bootstrap<br/>[server.js]"]
  node_express_app["Express App<br/>api host<br/>[app.js]"]
  node_api_config["Config<br/>[config.js]"]
  node_api_docs["Swagger<br/>api docs<br/>[swagger.js]"]
  node_auth_routes["Auth Routes<br/>[user.auth.js]"]
  node_wallet_routes["Wallet Routes<br/>[wallet.route.js]"]
  node_courier_routes["Courier Routes<br/>[courier.route.js]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.js]"]
  node_wallet_controller["Wallet Controller"]
  node_parcel_controller["Parcel Controller"]
  node_receipt_controller["Receipt Controller"]
  node_auth_middleware{{"Auth Check<br/>middleware"}}
end

subgraph group_data["Data"]
  node_db_connect[("DB Connect<br/>database bootstrap<br/>[db.connect.js]")]
  node_redis_store[("Redis<br/>cache/store<br/>[redis.js]")]
  node_user_model["Users<br/>model<br/>[user.model.js]"]
  node_wallet_models["Wallets<br/>model set<br/>[wallet.model.js]"]
  node_parcel_model["Parcels<br/>model<br/>[parcel.model.js]"]
  node_shipment_model["Shipments<br/>model<br/>[shipment.model.js]"]
  node_courier_model["Couriers<br/>model<br/>[courier.model.js]"]
end

subgraph group_services["Services"]
  node_otp_service["OTP Service<br/>[otp.service.js]"]
  node_mail_service["Mail Service<br/>[mail.service.js]"]
end

node_frontend_shell -->|"renders"| node_frontend_pages
node_frontend_auth -->|"drives"| node_frontend_guard
node_frontend_guard -->|"allows"| node_frontend_pages
node_frontend_pages -->|"calls"| node_frontend_api
node_frontend_api -->|"requests"| node_express_app
node_server_entry -->|"starts"| node_express_app
node_express_app -->|"uses"| node_api_config
node_express_app -->|"exposes"| node_api_docs
node_express_app -->|"mounts"| node_auth_routes
node_express_app -->|"mounts"| node_wallet_routes
node_express_app -->|"mounts"| node_courier_routes
node_auth_routes -->|"delegates"| node_auth_controller
node_wallet_routes -->|"delegates"| node_wallet_controller
node_courier_routes -->|"uses"| node_parcel_controller
node_courier_routes -->|"uses"| node_receipt_controller
node_auth_controller -->|"protected by"| node_auth_middleware
node_auth_controller -->|"reads/writes"| node_user_model
node_auth_controller -->|"uses"| node_otp_service
node_auth_controller -->|"uses"| node_mail_service
node_wallet_controller -->|"reads/writes"| node_wallet_models
node_parcel_controller -->|"reads/writes"| node_parcel_model
node_receipt_controller -->|"reads/writes"| node_shipment_model
node_express_app -->|"connects"| node_db_connect
node_express_app -->|"uses"| node_redis_store
node_user_model -->|"persists via"| node_db_connect
node_wallet_models -->|"persists via"| node_db_connect
node_parcel_model -->|"persists via"| node_db_connect
node_shipment_model -->|"persists via"| node_db_connect
node_courier_model -->|"persists via"| node_db_connect
node_otp_service -->|"stores"| node_redis_store
node_mail_service -.->|"supports"| node_redis_store

click node_frontend_shell "https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/main.jsx"
click node_frontend_pages "https://github.com/vishnuweb-a/aggregator-software/tree/main/frontend/src/pages"
click node_frontend_auth "https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/context/AuthContext.jsx"
click node_frontend_guard "https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/components/ProtectedRoute.jsx"
click node_frontend_api "https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/api/axios.js"
click node_server_entry "https://github.com/vishnuweb-a/aggregator-software/blob/main/server.js"
click node_express_app "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/app.js"
click node_api_config "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/config/config.js"
click node_api_docs "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/config/swagger.js"
click node_auth_routes "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/user.auth.js"
click node_wallet_routes "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/wallet.route.js"
click node_courier_routes "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/courier.route.js"
click node_auth_controller "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/auth.controller.js"
click node_wallet_controller "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/wallet.controller.js"
click node_parcel_controller "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/parcel.controller.js"
click node_receipt_controller "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/reciept.controller.js"
click node_auth_middleware "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/middleware/authCheck.middleware.js"
click node_db_connect "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/db/db.connect.js"
click node_redis_store "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/redis/redis.js"
click node_user_model "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/user.model.js"
click node_wallet_models "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/wallet.model.js"
click node_parcel_model "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/parcel.model.js"
click node_shipment_model "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/shipment.model.js"
click node_courier_model "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/courier.model.js"
click node_otp_service "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/services/otp.service.js"
click node_mail_service "https://github.com/vishnuweb-a/aggregator-software/blob/main/src/services/mail.service.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_frontend_shell,node_frontend_pages,node_frontend_auth,node_frontend_guard,node_frontend_api toneBlue
class node_server_entry,node_express_app,node_api_config,node_api_docs,node_auth_routes,node_wallet_routes,node_courier_routes,node_auth_controller,node_wallet_controller,node_parcel_controller,node_receipt_controller,node_auth_middleware toneAmber
class node_db_connect,node_redis_store,node_user_model,node_wallet_models,node_parcel_model,node_shipment_model,node_courier_model toneMint
class node_otp_service,node_mail_service toneRose
```

## Components

### Frontend

React/Vite client with auth-gated pages and API access.

- [UI Shell](https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/main.jsx): React app · Vite entry, app composition, and shared client-side behavior. · `frontend/src/main.jsx`
- [Pages](https://github.com/vishnuweb-a/aggregator-software/tree/main/frontend/src/pages): views · Login, register, and dashboard screens. · `frontend/src/pages`
- [Auth State](https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/context/AuthContext.jsx): context · Client-side authentication state and session handling. · `frontend/src/context/AuthContext.jsx`
- [Route Guard](https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/components/ProtectedRoute.jsx): router guard · Protects authenticated views from unauthenticated access. · `frontend/src/components/ProtectedRoute.jsx`
- [API Client](https://github.com/vishnuweb-a/aggregator-software/blob/main/frontend/src/api/axios.js): HTTP client · Centralized Axios setup for backend requests. · `frontend/src/api/axios.js`

### Backend

Express API, middleware, controllers, and startup wiring.

- [Server Entry](https://github.com/vishnuweb-a/aggregator-software/blob/main/server.js): bootstrap · Process entrypoint that starts the backend. · `server.js`
- [Express App](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/app.js): api host · Main Express application wiring routes, middleware, and config. · `src/app.js`
- [Config](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/config/config.js): runtime config · Environment and application configuration. · `src/config/config.js`
- [Swagger](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/config/swagger.js): api docs · API documentation and schema exposure. · `src/config/swagger.js`
- [Auth Routes](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/user.auth.js): route · Authentication endpoints for login and registration. · `src/routes/user.auth.js`
- [Wallet Routes](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/wallet.route.js): route · Wallet and accounting endpoints. · `src/routes/wallet.route.js`
- [Courier Routes](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/routes/courier.route.js): route · Courier operations endpoints. · `src/routes/courier.route.js`
- [Auth Controller](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/auth.controller.js): controller · Handles authentication and account verification flows. · `src/controller/auth.controller.js`
- [Wallet Controller](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/wallet.controller.js): controller · Coordinates wallet balance and transition operations. · `src/controller/wallet.controller.js`
- [Parcel Controller](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/parcel.controller.js): controller · Handles parcel lifecycle requests. · `src/controller/parcel.controller.js`
- [Receipt Controller](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/controller/reciept.controller.js): controller · Handles receipt-related requests. · `src/controller/reciept.controller.js`
- [Auth Check](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/middleware/authCheck.middleware.js): middleware · Verifies JWT/session access before protected handlers run. · `src/middleware/authCheck.middleware.js`

### Data

Primary models and runtime stores used by the backend.

- [DB Connect](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/db/db.connect.js): database bootstrap · Primary database connection initialization. · `src/db/db.connect.js`
- [Redis](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/redis/redis.js): cache/store · Auxiliary fast store for short-lived workflow state. · `src/redis/redis.js`
- [Users](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/user.model.js): model · User accounts and identity records. · `src/model/user.model.js`
- [Wallets](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/wallet.model.js): model set · Wallet, frozen wallet, and wallet transition records. · `src/model/wallet.model.js`
- [Parcels](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/parcel.model.js): model · Parcel records and shipment handoff state. · `src/model/parcel.model.js`
- [Shipments](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/shipment.model.js): model · Shipment records and delivery progression. · `src/model/shipment.model.js`
- [Couriers](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/model/courier.model.js): model · Courier entities and assignment data. · `src/model/courier.model.js`

### Services

Supporting side-effect services for identity and messaging.

- [OTP Service](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/services/otp.service.js): service · Generates and validates one-time verification codes. · `src/services/otp.service.js`
- [Mail Service](https://github.com/vishnuweb-a/aggregator-software/blob/main/src/services/mail.service.js): service · Sends verification and notification emails. · `src/services/mail.service.js`

## Connections

- UI Shell → Pages: renders · The app assembles the visible screens.
- Auth State → Route Guard: drives · Client auth state determines route access.
- Route Guard → Pages: allows · Protected navigation reaches the dashboard and other authenticated pages.
- Pages → API Client: calls · Pages send requests through the shared API client.
- API Client → Express App: requests · Browser API calls target the backend host.
- Server Entry → Express App: starts · Server bootstrap launches the Express app.
- Express App → Config: uses · Runtime wiring reads application configuration.
- Express App → Swagger: exposes · Backend also serves API documentation metadata.
- Express App → Auth Routes: mounts · Auth endpoints are mounted on the app.
- Express App → Wallet Routes: mounts · Wallet endpoints are mounted on the app.
- Express App → Courier Routes: mounts · Courier endpoints are mounted on the app.
- Auth Routes → Auth Controller: delegates · Route handlers hand off to controller logic.
- Wallet Routes → Wallet Controller: delegates · Route handlers hand off to controller logic.
- Courier Routes → Parcel Controller: uses · Courier operations connect to parcel handling.
- Courier Routes → Receipt Controller: uses · Courier operations connect to receipt handling.
- Auth Controller → Auth Check: protected by · Sensitive API paths depend on request authentication.
- Auth Controller → Users: reads/writes · Account operations persist user data.
- Auth Controller → OTP Service: uses · Verification flows generate or validate OTPs.
- Auth Controller → Mail Service: uses · Verification flows send email messages.
- Wallet Controller → Wallets: reads/writes · Wallet accounting updates balance and transition records.
- Parcel Controller → Parcels: reads/writes · Parcel lifecycle updates are stored in the parcel model.
- Receipt Controller → Shipments: reads/writes · Receipt handling ties into shipment state.
- Express App → DB Connect: connects · The app initializes the primary database connection.
- Express App → Redis: uses · The app can use Redis for short-lived state.
- Users → DB Connect: persists via · User data is stored in the primary database.
- Wallets → DB Connect: persists via · Wallet accounting data is stored in the primary database.
- Parcels → DB Connect: persists via · Parcel data is stored in the primary database.
- Shipments → DB Connect: persists via · Shipment data is stored in the primary database.
- Couriers → DB Connect: persists via · Courier records are stored in the primary database.
- OTP Service → Redis: stores · OTP lifecycle state can be kept in Redis.
- Mail Service → Redis: supports · Short-lived verification workflows may coordinate through Redis.
