How danielcba/mini_dashboard works
Project Type and Purpose
• This is a single-page interactive web dashboard built with Streamlit (a Python framework that combines frontend UI and backend logic in one application).
• It fetches financial data (prices, dividends, metrics) for stock tickers (local and international), renders interactive Plotly charts, and allows CSV export.
File Structure Analysis
• Top-level files:
• mini_dashboard.py (core Streamlit app)
• requirements.txt (dependencies: streamlit, yfinance, plotly, pandas)
• .devcontainer (optional VSCode/container setup)
• README.md / README-EN.md & LICENSE
• No separate “frontend” or “backend” folders—Streamlit unifies both.
• No database directory—data comes from external API (yfinance).
a. Streamlit App Server
• Hosts mini_dashboard.py
• Exposes a web UI (HTTP:8501) to the user’s browser
b. Client Browser
• Renders the UI (charts, selectors, buttons) served by Streamlit
c. External Data Provider
• yfinance module issues HTTP requests to Yahoo Finance API
• Returns historical price and dividend data
d. Data Processing Layer
• pandas computes metrics (P/E, ROE, Beta)
• plotly generates interactive chart objects
e. Export Service
• CSV creation via pandas.to_csv
• Delivers downloadable file to the client
f. (Optional) Dev Container / Local Env
• .devcontainer/devcontainer.json for reproducible dev environment
Relationships & Data Flows
1. Client → Streamlit Server: UI interactions (ticker selection, export clicks)
2. Streamlit → yfinance: Data fetch requests → Yahoo Finance API → Streamlit
3. Streamlit: pandas transforms data, plotly builds charts
4. Streamlit → Browser: Renders updated charts and metrics
5. (On Export) Streamlit → Browser: CSV file download
Architectural Patterns & Design Principles
• Single-page application paradigm (no page reloads; reactive callbacks)
• Separation of concerns (within one file):
• Presentation (Streamlit UI components)
• Business Logic (data fetch + metric calculations)
• Data Layer (external API)
• Use of caching (Streamlit.cache, if implemented) to avoid refetching
Final Advice
• Be exhaustive: break the mini_dashboard.py into sub‐blocks (UI, fetch, transform, render, export).
• External dependencies (yfinance, pandas, plotly).
• Keep labels concise but informative (e.g., “Fetch via yfinance”, “Compute metrics with pandas”).