# naushikmaurya/fros-project architecture

> Architecture diagram of the GitHub repository naushikmaurya/fros-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/naushikmaurya/fros-project
- Repository: https://github.com/naushikmaurya/fros-project

## Overview

#### Purpose and Entry Points
FROS is an internal financial-research pipeline: financial and market data ingestion → PostgreSQL warehouse → analytics, comparison, validation, forecasting, reports, and Streamlit exploration. Main operational entry points are `run_pipeline.sh`, ETL scripts under `python/etl/`, the dashboard at `dashboard/app.py`, and forecast commands in `python/forecasting/backtest.py` and `python/forecasting/forecast_future.py`.

#### Warehouse-Centered Data Model
PostgreSQL is the system-of-record boundary for all downstream features. Schema evolution defines core financial, source-tracking, and forecast tables in `sql/01_schema.sql`, `sql/02_add_data_source_tracking.sql`, and `sql/03_forecast_schema.sql`. Python data access/loading is concentrated in `python/etl/load_to_postgres.py` and `python/data_sources/db_writer.py`.

#### Synthetic ETL and Canonical Dataset
In restricted-network environments, the platform generates realistic synthetic financial statements, stock prices, and macro series, then loads them into PostgreSQL. The stages are `python/etl/generate_financials.py`, `python/etl/generate_prices.py`, `python/etl/generate_macro.py`, and `python/etl/load_to_postgres.py`. Company/sector scope originates in `python/etl/company_master.py`; generated/intermediate files are persisted under `data/processed/`, `data/yahoo/`, and `data/fred/`.

#### Live Financial-Source Ingestion
Source-specific ingestion is separated from the warehouse through a dispatcher/client/load pattern. SEC EDGAR extraction is implemented in `python/data_sources/sec/sec_edgar_client.py`, transformed by `python/data_sources/sec/build_real_dataset.py`, and upserted by `python/data_sources/sec/load_real_financials.py`. Parallel NSE integration exists under `python/data_sources/nse/`, while `python/data_sources/dispatcher.py` is the cross-source routing boundary. Loaded records retain provenance through the data-source tracking schema.

#### Analytics and Research Outputs
Financial statements in the warehouse feed ratio calculation, health scoring, peer comparison, red-flag analysis, and research-note generation. The core engines are `python/analytics/ratio_engine.py`, `python/analytics/comparison_engine.py`, and `python/reports/report_generator.py`. Generated analyst-facing artifacts are materialized as Markdown under `reports/`, including per-ticker research notes.

#### Validation and Forecasting
Post-load validation checks warehouse integrity and accounting/plausibility assumptions in `python/validation/data_validator.py`; independent SEC-versus-platform accuracy assessment is in `python/validation/ground_truth_validator.py`. Forecasting reads historical warehouse metrics, evaluates multiple methods by walk-forward error, persists backtest summaries/results, then produces future values. This sequence is owned by `python/forecasting/backtest.py`, `python/forecasting/forecast_methods.py`, and `python/forecasting/forecast_future.py`; backtesting must precede future forecasting because it resets forecast result tables.

#### User and Runtime Surface
`dashboard/app.py` is the Streamlit interactive surface for company research, comparisons, and sector benchmarking, backed by PostgreSQL-derived outputs. The deployable runtime is Python with pandas, SQLAlchemy, psycopg2, and Streamlit, plus PostgreSQL 16. Containerized local/deployment infrastructure is defined by `Dockerfile` and `docker-compose.yml`; environment configuration is represented by `.env.example`.

Main entry points: [`python/forecasting/backtest.py`](https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/backtest.py) (Forecast backtesting), [`python/etl/generate_financials.py`](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_financials.py) (Financial generator), [`python/forecasting/forecast_future.py`](https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/forecast_future.py) (Future forecasting), [`python/etl/load_to_postgres.py`](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/load_to_postgres.py) (Warehouse loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_synthetic["Synthetic ETL"]
  node_company_master["Company master<br/>scope catalog<br/>[company_master.py]"]
  node_financial_generator["Financial generator<br/>synthetic ETL"]
  node_price_generator["Price generator<br/>synthetic ETL<br/>[generate_prices.py]"]
  node_macro_generator["Macro generator<br/>synthetic ETL<br/>[generate_macro.py]"]
  node_staged_data["Staged datasets<br/>file datasets"]
end

subgraph group_live["Live Source Ingestion"]
  node_dispatcher{{"Source dispatcher<br/>ingestion router<br/>[dispatcher.py]"}}
  node_sec_client["SEC EDGAR client<br/>source client"]
  node_sec_dataset["SEC dataset builder<br/>transformer"]
  node_sec_loader["SEC financial loader<br/>upsert loader"]
  node_nse["NSE integration<br/>source adapter"]
end

subgraph group_research["Analytics &amp; Forecasting"]
  node_analytics["Research analytics<br/>analytics engines<br/>[ratio_engine.py]"]
  node_reports["Research reports<br/>report generator"]
  node_report_files["Analyst reports<br/>Markdown artifacts"]
  node_validation["Data validation<br/>validation engine<br/>[data_validator.py]"]
  node_backtest["Forecast backtesting<br/>forecast evaluator<br/>[backtest.py]"]
  node_forecast_methods["Forecast methods<br/>forecast models"]
  node_future_forecast["Future forecasting<br/>forecast producer<br/>[forecast_future.py]"]
end

subgraph group_runtime["User &amp; Runtime"]
  node_pipeline{{"Pipeline runner<br/>orchestrator<br/>[run_pipeline.sh]"}}
  node_dashboard["Streamlit dashboard<br/>interactive UI<br/>[app.py]"]
  node_containers["Container runtime<br/>deployment infrastructure<br/>[docker-compose.yml]"]
end

node_warehouse_schema["Warehouse schema<br/>SQL schema<br/>[01_schema.sql]"]
node_postgres[("PostgreSQL warehouse<br/>system of record")]
node_warehouse_loader["Warehouse loader<br/>data access"]

node_pipeline -->|"runs"| node_financial_generator
node_pipeline -->|"runs"| node_warehouse_loader
node_company_master -->|"defines scope"| node_financial_generator
node_company_master -->|"defines scope"| node_price_generator
node_financial_generator -->|"writes"| node_staged_data
node_price_generator -->|"writes"| node_staged_data
node_macro_generator -->|"writes"| node_staged_data
node_staged_data -->|"loads"| node_warehouse_loader
node_warehouse_schema -->|"defines"| node_postgres
node_warehouse_loader -->|"loads"| node_postgres
node_dispatcher -->|"routes SEC"| node_sec_client
node_dispatcher -->|"routes NSE"| node_nse
node_sec_client -->|"extracts"| node_sec_dataset
node_sec_dataset -->|"transforms"| node_sec_loader
node_sec_loader -->|"upserts with provenance"| node_postgres
node_nse -->|"loads"| node_postgres
node_postgres -->|"financial data"| node_analytics
node_analytics -->|"research findings"| node_reports
node_reports -->|"writes"| node_report_files
node_postgres -->|"validates"| node_validation
node_postgres -->|"historical metrics"| node_backtest
node_forecast_methods -->|"evaluates"| node_backtest
node_backtest -->|"persists results"| node_postgres
node_backtest -->|"must precede"| node_future_forecast
node_forecast_methods -->|"generates values"| node_future_forecast
node_future_forecast -->|"persists forecasts"| node_postgres
node_postgres -->|"serves derived outputs"| node_dashboard
node_containers -->|"runs"| node_postgres
node_containers -->|"runs"| node_dashboard

click node_pipeline "https://github.com/naushikmaurya/fros-project/blob/main/run_pipeline.sh"
click node_company_master "https://github.com/naushikmaurya/fros-project/blob/main/python/etl/company_master.py"
click node_financial_generator "https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_financials.py"
click node_price_generator "https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_prices.py"
click node_macro_generator "https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_macro.py"
click node_dispatcher "https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/dispatcher.py"
click node_sec_client "https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/sec_edgar_client.py"
click node_sec_dataset "https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/build_real_dataset.py"
click node_sec_loader "https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/load_real_financials.py"
click node_warehouse_schema "https://github.com/naushikmaurya/fros-project/blob/main/sql/01_schema.sql"
click node_warehouse_loader "https://github.com/naushikmaurya/fros-project/blob/main/python/etl/load_to_postgres.py"
click node_analytics "https://github.com/naushikmaurya/fros-project/blob/main/python/analytics/ratio_engine.py"
click node_reports "https://github.com/naushikmaurya/fros-project/blob/main/python/reports/report_generator.py"
click node_validation "https://github.com/naushikmaurya/fros-project/blob/main/python/validation/data_validator.py"
click node_backtest "https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/backtest.py"
click node_forecast_methods "https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/forecast_methods.py"
click node_future_forecast "https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/forecast_future.py"
click node_dashboard "https://github.com/naushikmaurya/fros-project/blob/main/dashboard/app.py"
click node_containers "https://github.com/naushikmaurya/fros-project/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_company_master,node_financial_generator,node_price_generator,node_macro_generator,node_staged_data toneBlue
class node_dispatcher,node_sec_client,node_sec_dataset,node_sec_loader,node_nse toneAmber
class node_analytics,node_reports,node_report_files,node_validation,node_backtest,node_forecast_methods,node_future_forecast toneMint
class node_pipeline,node_dashboard,node_containers toneRose
class node_warehouse_schema,node_postgres,node_warehouse_loader toneNeutral
```

## Components

### Synthetic ETL

- [Company master](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/company_master.py): scope catalog · `python/etl/company_master.py`
- [Financial generator](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_financials.py): synthetic ETL · `python/etl/generate_financials.py`
- [Price generator](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_prices.py): synthetic ETL · `python/etl/generate_prices.py`
- [Macro generator](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/generate_macro.py): synthetic ETL · `python/etl/generate_macro.py`
- **Staged datasets**: file datasets · Generated and downloaded intermediate data.

### Live Source Ingestion

- [Source dispatcher](https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/dispatcher.py): ingestion router · `python/data_sources/dispatcher.py`
- [SEC EDGAR client](https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/sec_edgar_client.py): source client · `python/data_sources/sec/sec_edgar_client.py`
- [SEC dataset builder](https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/build_real_dataset.py): transformer · `python/data_sources/sec/build_real_dataset.py`
- [SEC financial loader](https://github.com/naushikmaurya/fros-project/blob/main/python/data_sources/sec/load_real_financials.py): upsert loader · `python/data_sources/sec/load_real_financials.py`
- **NSE integration**: source adapter

### Analytics & Forecasting

- [Research analytics](https://github.com/naushikmaurya/fros-project/blob/main/python/analytics/ratio_engine.py): analytics engines · Ratios, health scoring, peer comparison, and red flags. · `python/analytics/ratio_engine.py`
- [Research reports](https://github.com/naushikmaurya/fros-project/blob/main/python/reports/report_generator.py): report generator · Produces per-ticker Markdown research notes. · `python/reports/report_generator.py`
- **Analyst reports**: Markdown artifacts
- [Data validation](https://github.com/naushikmaurya/fros-project/blob/main/python/validation/data_validator.py): validation engine · Checks integrity, plausibility, and SEC accuracy. · `python/validation/data_validator.py`
- [Forecast backtesting](https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/backtest.py): forecast evaluator · Walk-forward method evaluation; resets forecast result tables. · `python/forecasting/backtest.py`
- [Forecast methods](https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/forecast_methods.py): forecast models · `python/forecasting/forecast_methods.py`
- [Future forecasting](https://github.com/naushikmaurya/fros-project/blob/main/python/forecasting/forecast_future.py): forecast producer · `python/forecasting/forecast_future.py`

### User & Runtime

- [Pipeline runner](https://github.com/naushikmaurya/fros-project/blob/main/run_pipeline.sh): orchestrator · Operational entry point for pipeline stages. · `run_pipeline.sh`
- [Streamlit dashboard](https://github.com/naushikmaurya/fros-project/blob/main/dashboard/app.py): interactive UI · Company research, comparisons, and sector benchmarking. · `dashboard/app.py`
- [Container runtime](https://github.com/naushikmaurya/fros-project/blob/main/docker-compose.yml): deployment infrastructure · Python and PostgreSQL local/deployment environment. · `docker-compose.yml`

### Other components

- [Warehouse schema](https://github.com/naushikmaurya/fros-project/blob/main/sql/01_schema.sql): SQL schema · Defines financial, provenance, and forecast tables. · `sql/01_schema.sql`
- **PostgreSQL warehouse**: system of record · Central boundary for downstream data and results.
- [Warehouse loader](https://github.com/naushikmaurya/fros-project/blob/main/python/etl/load_to_postgres.py): data access · `python/etl/load_to_postgres.py`

## Connections

- Pipeline runner → Financial generator: runs
- Pipeline runner → Warehouse loader: runs
- Company master → Financial generator: defines scope
- Company master → Price generator: defines scope
- Financial generator → Staged datasets: writes
- Price generator → Staged datasets: writes
- Macro generator → Staged datasets: writes
- Staged datasets → Warehouse loader: loads
- Warehouse schema → PostgreSQL warehouse: defines
- Warehouse loader → PostgreSQL warehouse: loads
- Source dispatcher → SEC EDGAR client: routes SEC
- Source dispatcher → NSE integration: routes NSE
- SEC EDGAR client → SEC dataset builder: extracts
- SEC dataset builder → SEC financial loader: transforms
- SEC financial loader → PostgreSQL warehouse: upserts with provenance
- NSE integration → PostgreSQL warehouse: loads
- PostgreSQL warehouse → Research analytics: financial data
- Research analytics → Research reports: research findings
- Research reports → Analyst reports: writes
- PostgreSQL warehouse → Data validation: validates
- PostgreSQL warehouse → Forecast backtesting: historical metrics
- Forecast methods → Forecast backtesting: evaluates
- Forecast backtesting → PostgreSQL warehouse: persists results
- Forecast backtesting → Future forecasting: must precede
- Forecast methods → Future forecasting: generates values
- Future forecasting → PostgreSQL warehouse: persists forecasts
- PostgreSQL warehouse → Streamlit dashboard: serves derived outputs
- Container runtime → PostgreSQL warehouse: runs
- Container runtime → Streamlit dashboard: runs
