How chintan616/arthayukti works
1. Overall shape
- ArthaYukti is a three-tier distributed app: a React frontend, a Node.js/Express backend, and a separate Python AI service.
- The main architectural boundary is between the high-throughput trading/API server and the CPU/LLM-heavy AI microservice.
2. Frontend client
- The client folder is a Vite + React single-page app.
- It uses Redux Toolkit for application state, React Context for auth, Socket.IO client hooks for live updates, and page-level routing for the major product areas.
- Key UI surfaces map to business domains: dashboard, stocks/market, portfolio, wallet, watchlist, alerts, login/signup, and the AI analyst view.
3. Client-to-backend interaction
- The frontend talks to the Node API through a dedicated Axios layer and to the realtime socket layer through a separate socket client.
- Authentication is enforced on the client with protected routes and shared auth state, so the SPA acts as a thin presentation layer over server-owned business logic.
4. Node.js application server
- The server folder is the core transactional backend, built with Express and MongoDB/Mongoose.
- Its API is organized by domain controllers and routes: auth, stocks, portfolio, wallet, watchlist, alerts, and chat.
- This server owns request validation, auth/session handling, trading actions, wallet mutations, and persistence of user-facing application state.
5. Data model and domain boundaries
- MongoDB models separate the main business aggregates: User, Portfolio, Transaction, WalletTransaction, Watchlist, Alert, and ChatThread.
- This separation suggests a domain-oriented design where trading, wallet operations, and conversational AI history are tracked independently but linked through user identity.
6. Realtime market and event delivery
- Socket.IO is used on the Node side to push live market-related updates to connected clients.
- The server also contains a stockService, a cacheService, and a proto/MarketDataFeed.proto, indicating a dedicated market-data ingestion or normalization path separate from standard REST requests.
7. External integrations in the Node backend
- The Node backend is the integration point for live market data and payment simulation.
- It connects to Upstox for market prices/feeds, Razorpay test mode for virtual wallet top-ups, Google OAuth for login, and Redis for rate limiting and API-call reduction.
- Redis is an operational dependency rather than a business datastore; it supports throughput and external API protection.
8. AI microservice
- The ai-service directory is a separate Python service, likely FastAPI-based as described in the README, dedicated to AI and forecasting workloads.
- Its files (agent.py, predict.py, report.py, main.py) imply three AI capabilities: conversational analysis, stock-price forecasting, and generated reports/insights.
- This service is intentionally isolated from the Node server to keep LLM and time-series work off the transactional path.
9. AI service inputs and outputs
- The AI service appears to pull portfolio/context data from MongoDB and combine it with external intelligence sources such as Groq and NewsData.
- The frontend’s AI analyst page likely calls this service directly for streaming or report generation, rather than going through the Node API for every AI request.
- The result is a separate request path for AI queries, distinct from trading and account management.
10. Chat and AI history
- The Node backend includes a chat controller and ChatThread model, which suggests the conversational layer is persisted server-side.
- That gives the system a durable AI interaction history while allowing the Python service to stay stateless or lightly stateful.
11. Operational packaging
- docker-compose.yml coordinates local execution of the Node API, Python AI service, and Redis.
- Both backend services also have their own Dockerfiles, which reinforces the microservice boundary and independent deployment model.
12. Deployment boundary
- The README indicates the frontend is deployed separately on Vercel, while the Node API and Python AI API are deployed as separate web services.
- That means the diagram should show three independently deployable runtime units, with shared persistence in MongoDB and shared infrastructure support from Redis.
13. Primary data flow
- User actions start in the React SPA, go either to the Node API for trading/account operations or to the Python service for AI analysis, and then persist into MongoDB.
- Live market data arrives from external providers into the backend, then fans out to clients over sockets and updates the relevant stored state.
14. What to emphasize in an architecture diagram
- Show clear separation between presentation, transactional backend, AI backend, and infrastructure dependencies.
- Highlight MongoDB as the main system of record, Redis as operational cache/rate-limit support, and external services as side integrations rather than core components.
Main entry points: App.jsx App shell · server.js Express server · axios.js API client · main.py AI API
Components 30
React SPA
Vite + React presentation layer
- App shell · Bootstraps routing, layouts, and providers
client/src/App.jsx - Main entry · Mounts the SPA into the browser
client/src/main.jsx - API client · Dedicated HTTP client for backend calls
client/src/api/axios.js - Auth context · Client-side identity and session state
client/src/context/AuthContext.jsx - Redux store · Global application state container
client/src/store/index.js - Socket client · Browser connection for live updates
client/src/sockets/socketClient.js - Protected route · Blocks unauthenticated access to private views
client/src/components/ProtectedRoute.jsx - Dashboard · Overview landing for logged-in users
client/src/pages/DashboardPage.jsx - Market · Stocks and market browsing surface
client/src/pages/MarketPage.jsx - Portfolio · Holdings and performance view
client/src/pages/PortfolioPage.jsx - Wallet · Balance and top-up flows
client/src/pages/WalletPage.jsx - Watchlist · Tracked instruments and alerts surface
client/src/pages/WatchlistPage.jsx - AI analyst · User-facing AI analysis and reports
client/src/pages/AiAnalystPage.jsx
Node API
Express transactional backend
- Express server · Primary HTTP entrypoint and runtime orchestrator
server/server.js - Auth routes · Login, signup, and OAuth endpoints
server/routes/authRoutes.js - Stock service · Market data, trading, and price orchestration
server/services/stockService.js - Chat controller · Persists and serves conversational thread data
server/controllers/chatController.js - Socket hub · Broadcasts live market events to clients
server/sockets/index.js - Cache service · Operational caching and request reduction
server/services/cacheService.js - Database config · MongoDB connection bootstrap
server/config/db.js
AI Service
Python service for analysis and forecasting
Data and integrations
Shared storage, cache, and external providers
- MongoDB · Persistent business state and history
- Redis · Rate limiting and API-call reduction
- Upstox · External market data and pricing source
- Razorpay · Virtual wallet top-up integration
- Google OAuth · Third-party sign-in integration
- Groq / NewsData · External intelligence sources for AI outputs
Connections 37
- Main entry → App shell: boots · Browser entry mounts the application shell
- App shell → Auth context: provides · Auth state is shared across the SPA
- App shell → Redux store: provides · Redux store powers global state
- App shell → Protected route: uses · Private routes are wrapped by auth guards
- App shell → Dashboard: routes to · Dashboard is a main authenticated surface
- App shell → Market: routes to · Market browsing surface
- App shell → Portfolio: routes to · Portfolio surface
- App shell → Wallet: routes to · Wallet surface
- App shell → Watchlist: routes to · Watchlist surface
- App shell → AI analyst: routes to · AI analyst surface
- Dashboard → API client: calls · Dashboard fetches backend data
- Market → API client: calls · Market pages use REST APIs
- Portfolio → API client: calls · Portfolio data comes from Node API
- Wallet → API client: calls · Wallet mutations go through the API client
- Watchlist → API client: calls · Watchlist operations use REST APIs
- AI analyst → AI API: calls · AI page can talk directly to the AI service
- Socket client → Socket hub: connects · Browser subscribes to live updates
- API client → Express server: requests · Main HTTP path for application features
- Express server → Auth routes: mounts · Auth endpoints are registered in the server
- Express server → Stock service: mounts · Market and trading logic
- Express server → Chat controller: mounts · Chat and AI-history endpoints
- Express server → Socket hub: hosts · Realtime server is attached to the Node app
- Stock service → Cache service: uses · Protects external market calls and throughput
- Stock service → Upstox: integrates with · Consumes live market data feeds
- Express server → Google OAuth: integrates with · OAuth login provider
- Express server → Razorpay: integrates with · Virtual wallet top-up flow
- Express server → MongoDB: persists to · Primary application state store
- Chat controller → MongoDB: persists to · Conversation history is stored in MongoDB
- Database config → MongoDB: connects · MongoDB connection bootstrap
- Cache service → Redis: uses · Redis backs cache and rate-limiting
- AI API → Agent: orchestrates · Entrypoint routes conversational requests
- AI API → Predictor: orchestrates · Entrypoint exposes forecasting work
- AI API → Reports: orchestrates · Entrypoint exposes report generation
- Agent → MongoDB: reads context · Uses portfolio and chat context
- Predictor → MongoDB: reads context · Consumes stored market and portfolio history
- Reports → Groq / NewsData: uses · Generates insights from external intelligence
- Predictor → Groq / NewsData: uses · Forecasting is informed by external AI/intel sources