How rishabhprasad-12/dhansetu works
1. Repository shape
- This is a small monorepo with three distinct applications: a backend API in backend/, a public-facing React site in frontend/, and an authenticated trading dashboard in dashboard/.
- The readme describes the product as a full-stack trading app with authentication, holdings, positions, and portfolio management.
2. Backend as the central service boundary
- backend/index.js is the server entry point.
- The backend exposes routes under three route groups: AuthRoute, GetRoute, and PostRoute, which suggests a REST-style API split by authentication and read/write operations.
- This backend is the integration point used by both frontends.
3. Backend layering
- The backend follows a controller/service/model structure:
- Controllers handle request/response logic: AuthController, GetController, PostController, OtpController.
- Services contain business logic: HoldingsService, PositionService.
- Models represent persisted domain entities: UserModel, OtpModel, OrdersModel, HoldingsModel, PositionsModel.
- This separation suggests the API is not a thin proxy; it owns validation, business rules, and state changes.
4. Authentication and account verification flow
- Authentication is handled through AuthController and protected by AuthMiddleware.
- OTP-based verification is explicit via OtpController and OtpModel, with SendEmail used to deliver the one-time code.
- SecretToken indicates token generation/signing for authenticated sessions or API access.
5. Trading-domain data flow
- OrdersModel, HoldingsModel, and PositionsModel show the core portfolio entities.
- HoldingsService and PositionService likely derive or update dashboard-visible portfolio state from order activity and market data.
- PriceEngine is a backend utility, so price calculation or valuation is centralized server-side rather than duplicated in the UI.
6. Dashboard application: authenticated user workspace
- dashboard/ is the trading interface for logged-in users.
- Major UI areas include Holdings, Positions, Orders, WatchList, Funds, Summary, TopBar, and Dashboard.
- Graph components (DoughnutGraph, VerticalGraph) indicate portfolio analytics and allocation visualization.
7. Dashboard data access
- dashboard/src/api/api.js is the dashboard’s backend integration layer.
- GeneralContext.js suggests shared client state across dashboard components, likely for user/session and portfolio data.
- The dashboard is organized as a client-side application with reusable components rather than page-level server rendering.
8. Public frontend: marketing and login entry point
- frontend/ is a separate React app focused on the external website experience and onboarding.
- It includes landing-page sections for home, about, products, pricing, signup, support, and account opening.
- Login.js and frontend/src/api/api.js indicate this app also talks to the backend, but it is not the trading workspace itself.
9. Functional split between frontend and dashboard
- The frontend app handles acquisition and onboarding: marketing content, signup flow, support, and login.
- The dashboard app handles authenticated trading activity and portfolio management.
- This is an important architectural boundary: one app for pre-login/public flows, another for post-login product usage.
10. Backend utilities and supporting infrastructure
- SendEmail adds outbound email capability.
- PriceEngine encapsulates valuation/pricing logic.
- public/ under the backend suggests static asset support, but the main architecture is still API-centric.
11. Likely request lifecycle
- A user interacts first with the public frontend site, signs up or logs in, receives OTP/email verification if needed, then obtains authenticated access via token-based flow.
- Authenticated requests from the dashboard go through AuthMiddleware and then into controllers/services/models for holdings, positions, and orders.
- The UI consumes backend data through the client API wrappers in each React app.
12. What to draw in an architecture diagram
- Show three top-level systems: public React frontend, authenticated React dashboard, and Node backend API.
- Inside the backend, show route/controller/service/model layers plus OTP/email/token utilities and price engine.
- Inside the dashboard, show the portfolio UI components and shared client state/API layer.
- Treat data entities such as users, OTPs, orders, holdings, and positions as backend-owned domain objects.
Main entry points: Dashboard.js Dashboard Shell · routes Routes · src/index.js Frontend App · src/index.js Dashboard App
Components 22
Public Frontend
Marketing and onboarding React app.
- Frontend App · Public-facing acquisition and onboarding app.
frontend/src/index.js - Landing Pages · Home, about, products, pricing, signup, and support flows.
frontend/src/landing-page - Login · Login and sign-in entry point for public users.
frontend/src/Login.js - API Client · Frontend wrapper for backend requests.
frontend/src/api/api.js
Trading Dashboard
Authenticated React workspace for portfolio management.
- Dashboard App · Authenticated trading interface for logged-in users.
dashboard/src/index.js - Dashboard Shell · Top-level dashboard composition and navigation.
dashboard/src/components/Dashboard.js - Shared State · Shared dashboard context for user and portfolio data.
dashboard/src/components/GeneralContext.js - API Client · Dashboard wrapper for backend requests.
dashboard/src/api/api.js - Holdings · Displays owned instruments and allocation details.
dashboard/src/components/Holdings.js - Positions · Shows active positions and exposure.
dashboard/src/components/Positions.js - Orders · Order activity and trading history view.
dashboard/src/components/Orders.js - WatchList · Tracked symbols and market watch area.
dashboard/src/components/WatchList.js - Analytics · Portfolio charts and allocation graphs.
dashboard/src/components/Graphs
Backend API
Node service boundary for auth, trading data, and persistence.
- Server Entry · Backend process bootstrap and app wiring.
backend/index.js - Routes · REST-style route groups for auth, reads, and writes.
backend/routes - Auth Controller · Authentication request handling and session setup.
backend/controllers/AuthController.js - OTP Controller · One-time password verification flow.
backend/controllers/OtpController.js - Data Controllers · Read and write request handlers for portfolio APIs.
backend/controllers - Auth Middleware · Protects authenticated backend routes.
backend/middleware/AuthMiddleware.js - Trading Services · Business logic for holdings and positions.
backend/services - Domain Models · Persisted user, OTP, order, holding, and position entities.
backend/models - Utilities · Token, email, and price calculation helpers.
backend/util
Connections 24
- Frontend App → Landing Pages: renders · Public site is organized into landing-page sections.
- Frontend App → Login: entry · Login is part of the public onboarding flow.
- Frontend App → API Client: calls · Public app uses the backend client wrapper.
- Dashboard App → Dashboard Shell: composes · Dashboard entry mounts the main workspace shell.
- Dashboard App → Shared State: shares state · Context provides common client state across components.
- Dashboard App → API Client: calls · Dashboard data access goes through its API layer.
- Dashboard Shell → Holdings: shows · Shell includes holdings view.
- Dashboard Shell → Positions: shows · Shell includes positions view.
- Dashboard Shell → Orders: shows · Shell includes orders view.
- Dashboard Shell → WatchList: shows · Shell includes watchlist view.
- Dashboard Shell → Analytics: shows · Shell includes analytics charts.
- Server Entry → Routes: mounts · Server entry wires route groups into the app.
- Routes → Auth Controller: dispatches · Auth route group forwards to auth controller.
- Routes → OTP Controller: dispatches · OTP-related routes forward to OTP controller.
- Routes → Data Controllers: dispatches · Read/write route groups forward to data controllers.
- Data Controllers → Auth Middleware: protects · Authenticated endpoints are guarded by middleware.
- Auth Controller → Utilities: uses · Authentication uses token and email helpers.
- OTP Controller → Domain Models: reads/writes · OTP verification persists to domain storage.
- Data Controllers → Trading Services: delegates · Controllers hand business logic to services.
- Trading Services → Domain Models: updates · Services derive and persist trading state.
- Trading Services → Utilities: uses · Pricing and valuation helpers support portfolio logic.
- API Client → Routes: requests · Public frontend sends auth and onboarding requests to backend APIs.
- API Client → Routes: requests · Dashboard fetches portfolio and trading data from backend APIs.
- Shared State → API Client: orchestrates · Shared state coordinates API-driven dashboard data.