How pankajsinghdeveloper26/nse-stock-predictor works
Purpose and Repository Shape
AlphaVision NSE Analytics is a research-oriented NSE equity analysis and forecasting system: historical prices are transformed into technical features, forecast models, trend assessments, and trading signals. The repository contains a root application plus a more complete duplicated snapshot under nse-stock-predictor-zip/; the latter adds modular backend stages such as authentication, caching, cleaning, features, and storage. Treat these as parallel copies unless consolidation is intentional.
Entry Points and Delivery Surfaces
• Python execution is centered on cli.py, data_loader.py, models.py, services.py, and server.py; the README identifies CLI forecasting as the primary workflow.
• The root dashboard is an Astro site with a React island: src/pages/index.astro, src/components/react/Dashboard.tsx, and src/lib/api.ts.
• A separate Astro-only frontend exists in nse-frontend/src/pages/index.astro, backed by nse-frontend/src/lib/api.ts.
• The expanded snapshot has equivalent backend/server entry points at nse-stock-predictor-zip/cli.py and nse-stock-predictor-zip/server.py.
Market Data Boundary
Data acquisition and dataset preparation begin in data_loader.py and feed model-ready tabular data into models.py. The architecture expects external historical market-data access (README names yFinance) or local CSV input; this is the principal external-data boundary. Offline behavior is explicitly represented by test_data_loader_offline.py.
• Expanded pipeline paths: nse-stock-predictor-zip/data_loader.py, nse-stock-predictor-zip/loader.py, nse-stock-predictor-zip/cleaner.py.
Analytics and Forecasting Pipeline
The core control flow is: acquire/load OHLCV data → validate/clean → engineer indicators and patterns → train or invoke forecasting model → classify trend/volatility/sentiment → emit a rule-based signal and forecast response. Root implementation anchors are data_loader.py, models.py, and services.py.
• The expanded implementation separates feature generation in nse-stock-predictor-zip/features.py, model logic in nse-stock-predictor-zip/models.py, and orchestration/services in nse-stock-predictor-zip/services.py.
• Intended model/runtime dependencies include Python, Pandas/NumPy, scikit-learn, XGBoost, and TensorFlow/Keras; indicators include SMA, RSI, MACD, Bollinger Bands, and ATR.
Service, State, and Security Layer
server.py is the backend boundary expected to expose analytics to a browser client, while services.py mediates higher-level operations between request handling and the forecasting pipeline. In the expanded copy, cross-cutting concerns are explicit:
• Configuration/environment handling: nse-stock-predictor-zip/config.py
• Authentication: nse-stock-predictor-zip/auth.py
• Cache and persistence abstractions: nse-stock-predictor-zip/cache.py, nse-stock-predictor-zip/storage.py
Dashboard Composition
The root UI is a dashboard-oriented Astro/React frontend. src/pages/index.astro hosts the application; src/components/react/Dashboard.tsx composes market metrics, index tiles, screening controls/table, signal feed, and sparklines. UI-to-backend calls should remain isolated in src/lib/api.ts, with domain/API shapes centralized in src/lib/types.ts.
• Major presentation components: src/components/react/ScreenerTable.tsx, src/components/react/SignalFeed.tsx, src/components/react/IndexTile.tsx.
• Astro and React/TypeScript run in the browser/build toolchain; Python services are the analytics runtime.
Key Architectural Risks
The README describes an app/ package hierarchy that is absent from the supplied tree, while the actual code is split across root, nse-frontend/, and nse-stock-predictor-zip/ duplicates. Before extending functionality, select a canonical backend/frontend pair, establish the server API contract used by src/lib/api.ts, and avoid implementing changes in both copies.
Main entry points: nse-stock-predictor-zip/services.py Analytics services · data_loader.py Data loader · services.py Analytics services · loader.py Load and clean
Components 19
Root Python backend
- Forecast CLI · Primary documented forecasting workflow.
cli.py - Data loader · Loads and prepares market datasets.
data_loader.py - Forecast models · Technical analysis and forecasting model logic.
models.py - Analytics services · Coordinates forecasts, assessments, and signals.
services.py - Analytics server · Browser-facing analytics boundary.
server.py
Expanded backend snapshot
A parallel, more modular copy under nse-stock-predictor-zip/.
- Forecast CLI
nse-stock-predictor-zip/cli.py - Load and clean · Acquisition, validation, and cleaning stages.
nse-stock-predictor-zip/loader.py - Technical features · Indicators and price-pattern features.
nse-stock-predictor-zip/features.py - Forecast models · scikit-learn, XGBoost, and TensorFlow/Keras model logic.
nse-stock-predictor-zip/models.py - Analytics services · Produces forecasts, trend assessments, and rule-based signals.
nse-stock-predictor-zip/services.py - Analytics server
nse-stock-predictor-zip/server.py - Authentication
nse-stock-predictor-zip/auth.py - Cache and storage · Caching and persistence abstractions.
nse-stock-predictor-zip/storage.py
Root dashboard
- Dashboard page · Hosts the React dashboard island.
src/pages/index.astro - Analytics dashboard · Composes metrics, index tiles, screener, signals, and sparklines.
src/components/react/Dashboard.tsx - API client and types · Isolates backend calls and shared API/domain shapes.
src/lib/api.ts
Separate Astro frontend
- Astro frontend · Separate Astro-only frontend with its own API client.
nse-frontend/src/pages/index.astro - API client
nse-frontend/src/lib/api.ts
Other components
- Historical market data · yFinance access or local CSV OHLCV input.
Connections 20
- Historical market data → Data loader: OHLCV / CSV
- Forecast CLI → Data loader: runs pipeline
- Data loader → Forecast models: prepared data
- Forecast models → Analytics services: forecasts
- Analytics services → Analytics server: analytics responses
- Forecast CLI → Analytics services: forecast output
- Dashboard page → Analytics dashboard: hosts
- Analytics dashboard → API client and types: requests
- API client and types → Analytics server: analytics API · API contract must be established for the canonical backend.
- Historical market data → Load and clean: OHLCV / CSV
- Forecast CLI → Load and clean: runs pipeline
- Load and clean → Technical features: clean data
- Technical features → Forecast models: feature table
- Forecast models → Analytics services: forecasts
- Analytics services → Analytics server: analytics responses
- Authentication → Analytics server: protects
- Cache and storage → Analytics services: cached / persisted state
- Forecast CLI → Analytics services: forecast output
- Astro frontend → API client: uses
- API client → Analytics server: analytics API · Potential client/server pairing; duplicates require canonicalization.