How nishichandra/stock-index-screenr works
Project type and purpose
• This is a containerized backend API service (“stock-index-screenr”) built with FastAPI. Its primary purpose is to ingest raw stock data, build and store stock index metrics in a local DuckDB database, cache hot reads in Redis, and expose a RESTful interface (with Swagger UI) for clients to query or export that data.
File structure
• Top-level:
• Dockerfile & docker-compose.yml – containers for the FastAPI app, Redis, (and possibly other services).
• app/ – Python source for ingestion, indexing, database connectivity, API routes, models, and utilities.
• outputs/ – sample artifacts (Excel export, Swagger UI PDF).
• requirements.txt – Python dependencies.
• app/:
• data_ingest.py – standalone job to pull raw data and populate DuckDB.
• build_index.py – logic to compute index performance and composition.
• database.py – DuckDB connection management (and Redis caching hooks).
• main.py – FastAPI application with route definitions.
• models.py – Pydantic schemas for request/response bodies.
• utils.py – shared helpers.
• data/index_data.duckdb – the embedded database file.
README for additional insights
• Describes Docker vs. local setup, API endpoints (build-index, index-performance, index-composition, composition-changes, export-data), and the DuckDB schema (stock_metadata, daily_data, index_composition, index_performance).
• Mentions Redis for caching but does not list a Redis config file—assumed to be defined in docker-compose.yml.