A modular, Streamlit-based stock market analysis application built on top of the Zerodha Kite Connect API. Below is a clean, polished, open-sourceβready README refactored from your earlier version. This version is suitable for GitHub public repositories, recruiters, contributors, and maintainers. Tone is neutral, professional, and community-friendly, while still explaining internals clearly.
You can use this as-is for README.md.
A modular, Streamlit-based stock market analysis application built on top of the Zerodha Kite Connect API. The project emphasizes clean architecture, separation of concerns, and performance, making it easy to extend for backtesting, algo trading, or multi-broker integrations.
- π Stock search by symbol or company name
- π Live price & historical OHLC data
- π High-performance candlestick charts (Lightweight Charts)
- β Favorites / watchlist management
- π€ User profile, funds & margins view
- β‘ Instrument caching for fast search
- π Secure environment-based configuration
The application follows a layered architecture:
UI Layer (Streamlit)
β
Service Layer (Business Logic)
β
Broker Client Layer (Zerodha Kite)
β
External Broker APIs
- UI never communicates directly with broker APIs
- All broker logic is isolated in services
- Configuration and secrets are environment-driven
- Services are reusable and testable
β
βββ main.py
β
βββ config/
β βββ settings.py
β βββ env.py
β
βββ services/
β βββ kite_client.py
β βββ profile_service.py
β βββ search_service.py
β βββ data_service.py
β βββ fav_service.py
β
βββ ui/
β βββ profile.py
β βββ search.py
β βββ saved.py
β βββ lightweight_charts.py
β
βββ utils/
β βββ instruments.py
β βββ charts.py
β βββ downloader.py
β
βββ data/
β βββ favorites.json
β βββ cache/
β
βββ requirements.txt
βββ .env
- Initializes Streamlit
- Configures page layout and navigation
- Creates shared service instances
- Acts as the orchestration layer for the app
- Centralized application constants
- Time intervals, feature flags, defaults
- Keeps configuration out of business logic
- Loads environment variables from
.env - Prevents secrets from being hardcoded
- Enables easy environment switching
- Initializes and manages the KiteConnect client
- Implemented as a singleton
- Handles authentication and session reuse
- Fetches user profile information
- Retrieves funds and margin details
- Normalizes broker responses for UI
- Performs stock search using cached instruments
- Maps company names β trading symbols
- Fetches historical OHLC data
- Retrieves live market quotes
- Prepares data for chart rendering
- Manages favorites/watchlist persistence
- Abstracts storage away from UI
- Core trading interface
- Search bar and symbol selection
- Triggers data fetch and chart updates
- Displays user profile and account data
- Uses
profile_serviceexclusively
- Displays saved/watchlisted stocks
- Loads data via
fav_service
- High-performance chart renderer
- Candlestick, volume, and indicator support
- Optimized for real-time updates
- Loads and caches instrument dump
- Enables fast symbol-to-token mapping
- Avoids repeated API calls
- Shared Plotly helper functions
- Used for non-real-time visualizations
- CSV export utilities
- Enables data downloads
favorites.jsonstores user watchlistscache/holds cached instrument dumps- Designed for easy migration to DB/Redis later
main.py
β load env
β load settings
β initialize Kite client
β load instrument cache
UI (search.py)
β SearchService
β InstrumentCache
UI (search.py)
β DataService
β KiteClient
β Zerodha API
UI (profile.py)
β ProfileService
β KiteClient
UI (saved.py)
β FavService
β favorites.json
- Python 3.9+
- Zerodha Kite Connect account
pip install -r requirements.txtCreate a .env file:
KITE_API_KEY=your_api_key
KITE_ACCESS_TOKEN=your_access_tokenstreamlit run main.pyPlanned or easily extendable features:
- WebSocket live tick streaming
- Backtesting engine
- Algo trading execution
- Multi-broker support (AngelOne, Upstox)
- Database-backed persistence
- Strategy indicators & signals
βββββββββββββββββββββββββββββββ
β User Browser β
β (Search β’ Charts β’ Profile)β
βββββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Streamlit UI Layer β
β βββββββββββββββββββββββββ β
β β’ search.py β
β β’ profile.py β
β β’ saved.py β
β β’ lightweight_charts.py β
βββββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Service Layer β
β βββββββββββββββββββββββββ β
β β’ SearchService β
β β’ DataService β
β β’ ProfileService β
β β’ FavService β
βββββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Broker Client Layer β
β βββββββββββββββββββββββββ β
β β’ KiteClient (Singleton) β
β β’ Auth / Session Handling β
βββββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Zerodha Kite Connect API β
β βββββββββββββββββββββββββ β
β β’ Quotes β
β β’ Historical OHLC β
β β’ Profile & Margins β
βββββββββββββββββ¬ββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββ
β Local Storage & Cache β
β βββββββββββββββββββββββββ β
β β’ Instrument Cache β
β β’ favorites.json β
βββββββββββββββββββββββββββββββ
- Interacts with the application via Streamlit UI
- Requests data through UI actions (search, select stock, view profile)
Role
- Presentation & interaction only
- No broker logic
- No raw API calls
Key Responsibilities
- Render search interface
- Display charts and tables
- Trigger service calls
- Maintain UI state across reruns
Why this layer exists
- Isolates business rules
- Makes logic testable and reusable
- Prevents UI β Broker coupling
Responsibilities
- Search logic using cached instruments
- Fetch & normalize market data
- Fetch profile, funds, margins
- Handle favorites persistence
Key Characteristics
- Singleton pattern
- Authenticated session reuse
- Centralized API error handling
Why singleton
- Streamlit reruns scripts frequently
- Prevents repeated login / token issues
- Avoids rate-limit problems
Provides
- Live market quotes
- Historical OHLC candles
- User profile & margin data
Access Rules
- Accessed only through KiteClient
- Never directly from UI
Instrument Cache
- Loaded once at startup
- Enables instant symbol search
- Avoids heavy repeated API calls
favorites.json
- Lightweight persistence
- User watchlist storage
- Easily replaceable with DB later
User
β UI (search.py)
β SearchService
β Instrument Cache
User
β UI
β DataService
β KiteClient
β Zerodha API
User
β UI (profile.py)
β ProfileService
β KiteClient
User
β UI (saved.py)
β FavService
β favorites.json
-
Clean separation of concerns
-
Scalable to multi-broker support
-
Interview-grade architecture
-
Easy migration to:
- WebSockets
- Databases
- Algo-trading engines
-
Open-source contributor friendly
- WebSocket live ticks
- Redis instrument cache
- Backtesting engine
- Strategy execution engine
- Cloud deployment (Docker)



