# naushikmaurya/aeroflex-financial-analytics architecture

> Architecture diagram of the GitHub repository naushikmaurya/aeroflex-financial-analytics, 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/aeroflex-financial-analytics
- Repository: https://github.com/naushikmaurya/aeroflex-financial-analytics

## Overview

#### Purpose and execution surface
Aeroflex Financial Analytics is a rerunnable single-company equity-research pipeline: Excel financial-model inputs become normalized PostgreSQL data, SQL-derived operating KPIs, Python valuation outputs, and a live Streamlit dashboard. Primary entry points are `etl/extract_excel.py`, `etl/load_to_postgres.py`, `analysis/valuation.py`, `analysis/charts.py`, and `dashboard/app.py`.

#### Source extraction and staging
`etl/extract_excel.py` is the ingestion boundary for external workbooks. It uses label-driven parsing rather than fixed cell coordinates, enabling compatible company-model workbooks to be converted into tidy staging CSVs under `data/`. Core staged statement datasets are `data/income_statement.csv`, `data/balance_sheet.csv`, and `data/cash_flow_statement.csv`; peer valuation input is `data/peer_multiples.csv`.

#### Relational financial store
PostgreSQL is the system of record and integration point between ingestion, analytics, valuation, and UI. `sql/01_schema.sql` defines the normalized financial model for companies, statements, prices, peers, multiples, and valuation summaries. `etl/load_to_postgres.py` loads staged CSVs into this schema using a database URL, separating source-file parsing from database persistence. `data/sample_data.sql` is a bootstrap/restore path when Excel ETL is skipped.

#### SQL analytics layer
`sql/02_analytics_views.sql` creates the query-facing semantic layer over raw statements and market data. Views calculate revenue growth, EBITDA margin, ROE, ROCE, leverage, free cash flow, year-over-year trends, and peer comparisons using joins and window functions. This layer is the principal contract for downstream dashboarding and can also be consumed directly by Power BI or Tableau without duplicating business logic.

#### Independent valuation and validation
`analysis/valuation.py` reads financial data back from PostgreSQL and independently computes FCFF DCF valuation, including WACC and terminal-growth assumptions. It intentionally cross-checks against valuation figures persisted from the source model rather than force-matching them; differences from discounting/day-count methodology remain observable. This establishes a validation boundary between Excel-originated valuation data and Python-derived valuation logic.

#### Visual analysis and presentation
`analysis/charts.py` queries/calculates visualization inputs and exports static chart PNGs to `dashboard/screenshots/`. `dashboard/app.py` is the interactive presentation runtime: a Streamlit application that issues live PostgreSQL queries for KPI overview, statement browsing, peer comparison, and valuation-summary views. The dashboard depends on the database/view contracts rather than local CSV files.

#### End-to-end control flow and runtime dependencies
The normal flow is workbook → extraction → CSV staging → PostgreSQL schema/tables → SQL views → Python valuation/charts and Streamlit dashboard. PostgreSQL is required before loading, analysis, or live dashboard use; Python dependencies are defined in `requirements.txt` and include the data/DB/visualization stack implied by pandas, SQLAlchemy, matplotlib, and Streamlit. Database connection configuration is externalized through `DATABASE_URL`/environment settings, with `.env.example` documenting expected local configuration.

Main entry points: [`requirements.txt`](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/requirements.txt) (Python dependencies), [`dashboard/app.py`](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/dashboard/app.py) (Live dashboard), [`etl/extract_excel.py`](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/extract_excel.py) (Excel extractor), [`etl/load_to_postgres.py`](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/load_to_postgres.py) (PostgreSQL loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion"]
  node_workbook["Company model workbook<br/>external input"]
  node_extract["Excel extractor<br/>Python ETL<br/>[extract_excel.py]"]
  node_staging["Staging CSVs<br/>CSV datasets"]
  node_loader["PostgreSQL loader<br/>Python ETL"]
  node_bootstrap["Sample data bootstrap<br/>SQL seed<br/>[sample_data.sql]"]
end

subgraph group_postgres["PostgreSQL"]
  node_schema["Financial schema<br/>SQL DDL<br/>[01_schema.sql]"]
  node_database[("Financial data store<br/>PostgreSQL")]
  node_views_sql["Analytics views<br/>SQL semantic layer"]
  node_analytics_views["Query-facing views<br/>SQL views"]
  node_source_valuation["Persisted source valuations<br/>Database records"]
end

subgraph group_analytics["Analytics &amp; valuation"]
  node_valuation["DCF valuation<br/>Python analysis<br/>[valuation.py]"]
  node_charts["Chart exporter<br/>Python analysis<br/>[charts.py]"]
end

subgraph group_presentation["Presentation"]
  node_screenshots["Chart PNGs<br/>Static assets"]
  node_dashboard["Live dashboard<br/>Streamlit app<br/>[app.py]"]
  node_bi_tools["BI tools<br/>External consumers"]
end

node_environment["Database environment<br/>Runtime configuration<br/>[.env.example]"]
node_dependencies["Python dependencies<br/>Requirements<br/>[requirements.txt]"]

node_workbook -->|"parse"| node_extract
node_extract -->|"write"| node_staging
node_staging -->|"load"| node_loader
node_environment -.->|"DATABASE_URL"| node_loader
node_schema -->|"defines tables"| node_database
node_loader -->|"persist"| node_database
node_bootstrap -.->|"seed / restore"| node_database
node_database -->|"source tables"| node_views_sql
node_views_sql -->|"creates"| node_analytics_views
node_database -->|"contains"| node_source_valuation
node_database -->|"read financials"| node_valuation
node_source_valuation -.->|"cross-check"| node_valuation
node_database -->|"query inputs"| node_charts
node_charts -->|"export PNG"| node_screenshots
node_analytics_views -->|"live KPIs and views"| node_dashboard
node_database -->|"live queries"| node_dashboard
node_analytics_views -->|"semantic contract"| node_bi_tools
node_dependencies -.->|"runtime"| node_extract
node_dependencies -.->|"runtime"| node_valuation
node_dependencies -.->|"runtime"| node_charts
node_dependencies -.->|"runtime"| node_dashboard
node_environment -.->|"DATABASE_URL"| node_dashboard

click node_extract "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/extract_excel.py"
click node_loader "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/load_to_postgres.py"
click node_bootstrap "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/data/sample_data.sql"
click node_schema "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/sql/01_schema.sql"
click node_views_sql "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/sql/02_analytics_views.sql"
click node_valuation "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/analysis/valuation.py"
click node_charts "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/analysis/charts.py"
click node_dashboard "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/dashboard/app.py"
click node_environment "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/.env.example"
click node_dependencies "https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/requirements.txt"

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_workbook,node_extract,node_staging,node_loader,node_bootstrap toneBlue
class node_schema,node_database,node_views_sql,node_analytics_views,node_source_valuation toneAmber
class node_valuation,node_charts toneMint
class node_screenshots,node_dashboard,node_bi_tools toneRose
class node_environment,node_dependencies toneNeutral
```

## Components

### Ingestion

- **Company model workbook**: external input · Compatible Excel financial-model input.
- [Excel extractor](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/extract_excel.py): Python ETL · Label-driven workbook parser. · `etl/extract_excel.py`
- **Staging CSVs**: CSV datasets · Normalized statements and peer multiples.
- [PostgreSQL loader](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/etl/load_to_postgres.py): Python ETL · `etl/load_to_postgres.py`
- [Sample data bootstrap](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/data/sample_data.sql): SQL seed · Alternative restore path when Excel ETL is skipped. · `data/sample_data.sql`

### PostgreSQL

- [Financial schema](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/sql/01_schema.sql): SQL DDL · Normalized companies, statements, prices, peers, multiples, and valuations. · `sql/01_schema.sql`
- **Financial data store**: PostgreSQL · System of record and integration point.
- [Analytics views](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/sql/02_analytics_views.sql): SQL semantic layer · KPIs, trends, and peer comparisons. · `sql/02_analytics_views.sql`
- **Query-facing views**: SQL views · Downstream contract over statements and market data.
- **Persisted source valuations**: Database records · Excel-originated figures used for cross-checking.

### Analytics & valuation

- [DCF valuation](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/analysis/valuation.py): Python analysis · Independently calculates FCFF, WACC, and terminal value. · `analysis/valuation.py`
- [Chart exporter](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/analysis/charts.py): Python analysis · Builds static visualization outputs. · `analysis/charts.py`

### Presentation

- **Chart PNGs**: Static assets
- [Live dashboard](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/dashboard/app.py): Streamlit app · KPI, statements, peers, and valuation views. · `dashboard/app.py`
- **BI tools**: External consumers · Power BI or Tableau can consume semantic views.

### Other components

- [Database environment](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/.env.example): Runtime configuration · DATABASE_URL is externalized through environment settings. · `.env.example`
- [Python dependencies](https://github.com/naushikmaurya/aeroflex-financial-analytics/blob/main/requirements.txt): Requirements · `requirements.txt`

## Connections

- Company model workbook → Excel extractor: parse
- Excel extractor → Staging CSVs: write
- Staging CSVs → PostgreSQL loader: load
- Database environment → PostgreSQL loader: DATABASE_URL
- Financial schema → Financial data store: defines tables
- PostgreSQL loader → Financial data store: persist
- Sample data bootstrap → Financial data store: seed / restore
- Financial data store → Analytics views: source tables
- Analytics views → Query-facing views: creates
- Financial data store → Persisted source valuations: contains
- Financial data store → DCF valuation: read financials
- Persisted source valuations → DCF valuation: cross-check
- Financial data store → Chart exporter: query inputs
- Chart exporter → Chart PNGs: export PNG
- Query-facing views → Live dashboard: live KPIs and views
- Financial data store → Live dashboard: live queries
- Query-facing views → BI tools: semantic contract
- Python dependencies → Excel extractor: runtime
- Python dependencies → DCF valuation: runtime
- Python dependencies → Chart exporter: runtime
- Python dependencies → Live dashboard: runtime
- Database environment → Live dashboard: DATABASE_URL
