How naushikmaurya/aeroflex-financial-analytics works
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 Python dependencies · app.py Live dashboard · extract_excel.py Excel extractor · load_to_postgres.py PostgreSQL loader
Components 17
Ingestion
- Company model workbook · Compatible Excel financial-model input.
- Excel extractor · Label-driven workbook parser.
etl/extract_excel.py - Staging CSVs · Normalized statements and peer multiples.
- PostgreSQL loader
etl/load_to_postgres.py - Sample data bootstrap · Alternative restore path when Excel ETL is skipped.
data/sample_data.sql
PostgreSQL
- Financial schema · Normalized companies, statements, prices, peers, multiples, and valuations.
sql/01_schema.sql - Financial data store · System of record and integration point.
- Analytics views · KPIs, trends, and peer comparisons.
sql/02_analytics_views.sql - Query-facing views · Downstream contract over statements and market data.
- Persisted source valuations · Excel-originated figures used for cross-checking.
Analytics & valuation
- DCF valuation · Independently calculates FCFF, WACC, and terminal value.
analysis/valuation.py - Chart exporter · Builds static visualization outputs.
analysis/charts.py
Presentation
- Chart PNGs
- Live dashboard · KPI, statements, peers, and valuation views.
dashboard/app.py - BI tools · Power BI or Tableau can consume semantic views.
Other components
- Database environment · DATABASE_URL is externalized through environment settings.
.env.example - Python dependencies
requirements.txt
Connections 22
- 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