How fumiaki0604/investmentinsight works
Project Type and Purpose
• This is a full-stack analytics application built as a Streamlit front-end (“streamlit_app/”) backed by reusable Python service code (“src/app/”).
• Purpose: fetch mutual fund NAV data from Google Sheets (or local CSV), compute technical indicators and correlations, generate AI-powered analysis via OpenAI, and send notifications to Slack.
Top-Level Components
• Presentation Layer (Streamlit UI)
• streamlit_app/app.py – main UI entrypoint with three tabs (detailed analysis, fund list, correlation analysis)
• streamlit_app/utils – helpers for chart drawing, correlation math, Google Sheets I/O, Slack notifications, GPT prompts
• Core Library Layer (src/app)
• config.py – environment and credential management
• data_sources/loader.py – abstracted data ingestion (Google Sheets API or sample CSV)
• indicators/technical.py – computes moving averages, DMI, etc.
• services/analytics_service.py – orchestrates data loading, indicator computation, correlation analysis, AI prompt assembly, Slack trigger logic
• models/responses.py – pydantic models for structured outputs
• main.py – (future) FastAPI skeleton for exposing the same functionality as an API
• External Systems
• Google Sheets – NAV data storage
• OpenAI API – natural-language explanation and report generation
• Slack Webhook – alert notifications
• Local Sample Data
• data/sample_nav.csv – used in dev/test mode
Relationships and Interactions
• Streamlit UI calls into streamlit_app/utils to fetch data, compute charts, and display results.
• The Chart/Correlation helpers delegate to src/app/services/analytics_service, which in turn:
a) Reads config (GOOGLE_SPREADSHEET_ID, API keys)
b) Loads raw data via data_sources/loader
c) Feeds data into indicators/technical for metrics and into correlation utils
d) Prepares prompt and calls OpenAI (via gpt_analysis.py)
e) Optionally sends alerts via Slack notifier
• All data flows are unidirectional: Data Source → Analytics Service → UI / AI / Slack.
Architectural Patterns and Principles
• Layered Architecture: clear separation between Presentation (Streamlit), Business Logic (analytics_service), Data Access (loader), and External Integrations (OpenAI, Slack).
• Dependency Injection via config.py: environment variables injected at startup.
• Modular Design: utilities and service code are reusable (can be exposed via FastAPI).
• Testable Units: data loader and indicator functions are covered under tests/.