How vishnuweb-a/aggregator-software works
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: app.js Express App · db.connect.js DB Connect · auth.controller.js Auth Controller · courier.route.js Courier Routes
Components 26
Frontend
React/Vite client with auth-gated pages and API access.
- UI Shell · Vite entry, app composition, and shared client-side behavior.
frontend/src/main.jsx - Pages · Login, register, and dashboard screens.
frontend/src/pages - Auth State · Client-side authentication state and session handling.
frontend/src/context/AuthContext.jsx - Route Guard · Protects authenticated views from unauthenticated access.
frontend/src/components/ProtectedRoute.jsx - API Client · Centralized Axios setup for backend requests.
frontend/src/api/axios.js
Backend
Express API, middleware, controllers, and startup wiring.
- Server Entry · Process entrypoint that starts the backend.
server.js - Express App · Main Express application wiring routes, middleware, and config.
src/app.js - Config · Environment and application configuration.
src/config/config.js - Swagger · API documentation and schema exposure.
src/config/swagger.js - Auth Routes · Authentication endpoints for login and registration.
src/routes/user.auth.js - Wallet Routes · Wallet and accounting endpoints.
src/routes/wallet.route.js - Courier Routes · Courier operations endpoints.
src/routes/courier.route.js - Auth Controller · Handles authentication and account verification flows.
src/controller/auth.controller.js - Wallet Controller · Coordinates wallet balance and transition operations.
src/controller/wallet.controller.js - Parcel Controller · Handles parcel lifecycle requests.
src/controller/parcel.controller.js - Receipt Controller · Handles receipt-related requests.
src/controller/reciept.controller.js - Auth Check · 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 · Primary database connection initialization.
src/db/db.connect.js - Redis · Auxiliary fast store for short-lived workflow state.
src/redis/redis.js - Users · User accounts and identity records.
src/model/user.model.js - Wallets · Wallet, frozen wallet, and wallet transition records.
src/model/wallet.model.js - Parcels · Parcel records and shipment handoff state.
src/model/parcel.model.js - Shipments · Shipment records and delivery progression.
src/model/shipment.model.js - Couriers · Courier entities and assignment data.
src/model/courier.model.js
Services
Supporting side-effect services for identity and messaging.
- OTP Service · Generates and validates one-time verification codes.
src/services/otp.service.js - Mail Service · Sends verification and notification emails.
src/services/mail.service.js
Connections 31
- 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.