How kprasanth08/pyalgokite works
Project type and purpose
• From the file tree and minimal README, this is a Python-based full-stack web application called “PyalgoKite.”
• It provides a dashboard for subscribing to market data feeds (via a Protobuf definition), interacting with the Upstox API (token generation, user profile) and displaying real-time data in the browser.
File structure
• Top-level:
• app.py – the web server entry point (likely Flask).
• upstox_service.py – encapsulates the Upstox API/websocket logic.
• generate_token.py, get_profile.py – helpers to authenticate and fetch user profile.
• generate_protobuf.py & MarketDataFeed.proto → MarketDataFeed_pb2.py – pipeline to generate Protobuf classes.
• user_watchlists/ – JSON files for per-user watchlists (simple file-based storage).
• Dockerfile & docker-compose.yml – containerization and orchestration.
• Static assets (CSS/JS) and Jinja2 templates under static/ and templates/ indicate a server-rendered UI plus client-side scripts (including upstox-websocket.js).
Available documentation
• README only gives the project name, so we infer architecture from structure and naming conventions.
Main components and interactions
a. Frontend (Browser)
• HTML pages (templates/*.html) + CSS/JS (static/)
• A client-side WebSocket or Server-Sent Events connection (static/js/upstox-websocket.js) to receive real-time data.
b. Backend Web Server
• app.py defines HTTP routes: login, profile, dashboard, watchlist management.
• Uses generate_token.py for authentication, get_profile.py for user data.
c. Market Data Service Layer
• upstox_service.py handles subscribing to the Upstox market data WebSocket API, decodes Protobuf messages (MarketDataFeed_pb2.py), and pushes updates to connected clients.
d. Data Storage
• File-based storage for user watchlists under user_watchlists/*.json.
e. External Services
• Upstox REST API (token, profile)
• Upstox WebSocket feed (market data)
Architectural patterns and design principles
• MVC‐style separation:
• Views (templates) → Controllers (app.py routes) → Models/Services (upstox_service.py, token/profile generators).
• Service layer isolating external API logic.
• Protobuf code generation decoupled via generate_protobuf.py.
Technologies and frameworks
• Python 3 + Flask (implied by app.py and Jinja2 templates)
• Protobuf (MarketDataFeed.proto → MarketDataFeed_pb2.py)
• Docker & docker-compose for containerization
• Static JavaScript for WebSocket client
Detail
• You cover all data flows: HTTP, WebSocket, file I/O, Protobuf codegen.