How krupesh0622/trading-view works
1. This is a two-part monorepo: a frontend client in client/ and a Node.js backend in server/. The root package scripts install and run both together, so the main architectural boundary is browser UI vs. API/WebSocket server.
2. The frontend is a React app built with Vite and styled with Tailwind CSS. Its runtime entry points are client/src/main.jsx and client/src/App.jsx, with the UI composed from Header, Sidebar, TradingChart, and Footer components.
3. The client is centered on a trading/charting experience. TradingChart.jsx is the core visualization surface, while Sidebar.jsx likely drives symbol selection or navigation around market views. Header.jsx and Footer.jsx frame the app shell.
4. Client-side integration is split by transport:
- client/src/services/api.js handles HTTP calls to the backend.
- client/src/services/socket.js handles live updates over a WebSocket connection.
- client/src/services/storage.js manages browser persistence for UI state or user selections.
5. The backend is a separate Node.js service, with server/server.js as the entry point. Based on the file layout, it acts as both an HTTP API server and a real-time data server for the client.
6. Persistence is MongoDB-backed. server/config/db.js establishes the database connection, and server/models/PriceData.js defines the stored market data structure. The README confirms the backend depends on MONGODB_URI.
7. The server’s domain logic appears to be market-data centric. server/services/marketService.js is the main business layer for market operations, while server/dataGenerator.js suggests either synthetic tick generation or a local data feed for development/testing.
8. server/utils/SYMBOL.js is a shared symbol registry or mapping layer. That indicates symbols are normalized centrally on the server, which helps keep the frontend and any market data source aligned on instrument identifiers.
9. The main data flow is: browser loads the React UI, requests initial market/chart state through REST, then subscribes to live updates through the socket layer. The server processes or generates market data, stores relevant records in MongoDB, and pushes incremental updates back to connected clients.
10. Environment and runtime are clearly separated:
- Client runs on http://localhost:5173 and reads VITE_API_URL.
- Server runs on http://localhost:3001.
This separation is important for the architecture diagram because the frontend never talks directly to the database; all data access goes through the backend.
11. The repository is currently focused on core market visualization and streaming rather than a full product stack. The README mentions broader future features like auth, watchlists, notifications, and external broker/data integrations, but those capabilities are not represented in the current file tree.
Main entry points: App.jsx App · server.js Server · marketService.js Market Service · client Frontend
Components 18
Workspace
Monorepo boundary and shared runtime coordination
- Trading View · Two-part client/server repository
Client UI
App shell and charting components
- Main · Frontend bootstrap and mount point
client/src/main.jsx - App · Top-level client composition
client/src/App.jsx - Header · Top app framing and controls
client/src/components/Header.jsx - Sidebar · Symbol or view selection area
client/src/components/Sidebar.jsx - Chart · Core trading/chart surface
client/src/components/TradingChart.jsx - Footer · Bottom app framing
client/src/components/Footer.jsx
Client Services
HTTP, websocket, and browser state integration
- API Client · REST calls to backend
client/src/services/api.js - Socket Client · Live updates channel
client/src/services/socket.js - Storage · Local UI state and selections
client/src/services/storage.js
Server Core
Entry point, data services, and storage integration
- Server · Bootstraps API, realtime, and data flow
server/server.js - DB Config · Database connection setup
server/config/db.js - Market Service · Market data processing and orchestration
server/services/marketService.js - Price Data · Stored market data schema
server/models/PriceData.js - Data Generator · Synthetic or local market data source
server/dataGenerator.js - Symbols · Central symbol normalization and lookup
server/utils/SYMBOL.js
Connections 19
- Trading View → Frontend: contains · Frontend workspace boundary
- Trading View → Backend: contains · Backend workspace boundary
- Frontend → Main: starts at · Browser entry point
- Main → App: renders · Mounts the main app shell
- App → Header: uses · App shell layout
- App → Sidebar: uses · Navigation and market selection
- App → Chart: uses · Primary charting surface
- App → Footer: uses · App framing
- App → API Client: uses · Initial and on-demand backend requests
- App → Socket Client: uses · Live market updates
- App → Storage: uses · Persist UI state
- API Client → Server: calls · REST API boundary
- Socket Client → Server: subscribes · Realtime websocket boundary
- Backend → Server: starts with · Backend runtime entry
- Server → DB Config: connects · MongoDB connection setup
- Server → Market Service: delegates to · Domain logic orchestration
- Market Service → Price Data: persists via · Market data storage
- Market Service → Data Generator: sources from · Synthetic or local feed
- Market Service → Symbols: normalizes · Shared symbol handling