A complete Streamlit application for analyzing banking performance, accounting, and risk management. This platform simulates a Business Analytics system to support strategic decision-making in financial institutions.
- Executive Dashboard: Key performance indicators (ROA, ROE, NIM, CIR)
- Financial Analysis: Monthly trends of revenues, expenses, and profit
- Risk Management: Non-performing loan metrics, NPL ratio, and banking risk index
- Segmented Analysis: Performance by country, branch, and customer segment
- Interactive Visualizations: Dynamic charts with Plotly
- Realistic Synthetic Data: SQLite database with simulated data
- Python 3.10+
- Streamlit: Interactive web interface
- SQLite: Relational database
- Pandas: Data manipulation and analysis
- NumPy: Numerical computations
- Plotly: Interactive visualizations
The database contains the following tables:
- customers: Customer information (country, segment, join date)
- accounts: Bank accounts (type, balance, interest rate)
- loans: Loans (sector, amount, rate, default status)
- transactions: Financial transactions
- branches: Branches and operational costs
- financial_statements: Monthly financial statements
Ensure you have Python 3.10 or higher installed:
python --versionClone or download this repository and install the dependencies:
pip install -r requirements.txtNote: The sqlite3 module is already included in standard Python, but is listed in requirements.txt for reference.
Run the initialization script to create and populate the database with synthetic data:
python database.pyThis script will:
- Create the
bank_data.dbfile - Populate all tables with realistic synthetic data
- Generate approximately 5,000 customers, accounts, loans, and transactions
Start the Streamlit application:
streamlit run app.pyThe application will automatically open in your browser at http://localhost:8501
To run the unit tests:
pytest tests/ -vTo run with code coverage:
pytest tests/ --cov=. --cov-report=html- Key performance indicators (Assets, Deposits, Profit, ROA, ROE)
- Net Interest Margin and Cost-to-Income Ratio
- Banking Risk Index
- Executive summary with financial health analysis
- Monthly trends of revenues and expenses
- Net profit evolution
- Cost-to-Income Ratio analysis
- Period filters
- Default rate and NPL Ratio
- Credit exposure by sector
- Banking Risk Index with detailed explanation
- Risk components
- Performance by country
- Segment analysis (retail vs corporate)
- Interactive filters
- Comparative metrics
- Net Interest Margin (NIM): Net interest margin
- ROA (Return on Assets): Return on assets
- ROE (Return on Equity): Return on equity
- Cost-to-Income Ratio (CIR): Cost-to-income ratio
- Loan-to-Deposit Ratio (LDR): Loan-to-deposit ratio
- Default Rate: Percentage of loans in default
- NPL Ratio: Proportion of non-performing loans
- Sector Exposure: Credit concentration
- Banking Risk Index: Composite score (0-100)
- Clean and professional layout
- Interactive visualizations with Plotly
- Sidebar filters for segmented analysis
- Clear explanations for non-technical users
- Executive-style dashboard
.
βββ app.py # Main Streamlit application
βββ database.py # Database initialization script
βββ metrics.py # Metrics calculation module
βββ config.py # Centralized configuration
βββ logger_config.py # Logging configuration
βββ requirements.txt # Project dependencies
βββ README.md # This file
βββ tests/ # Unit tests
β βββ __init__.py
β βββ test_metrics.py
β βββ test_database.py
βββ bank_data.db # SQLite database (generated after execution)
Edit the database.py file to adjust:
- Number of customers, accounts, and transactions
- Available countries and sectors
- Value and rate distributions
- Historical data periods
- Add the calculation function in
metrics.py - Integrate the metric on the appropriate page in
app.py - Add visualizations as needed
- Synthetic Data: Data is generated randomly but follows realistic distributions
- Performance: SQLite database is suitable for demonstration. For production, consider PostgreSQL or MySQL
- Cache: Streamlit uses cache to optimize database queries
- Reproducibility: Data is generated with a fixed seed (42) to ensure reproducibility
- Indexes: The database includes indexes on frequently queried columns for optimization
- Logging: Structured logging system for operation tracking
- Error Handling: All critical functions include robust error handling
- Type Hints: Code with type annotations for better maintainability
- Tests: Unit tests included for metrics validation
This application is ideal for:
- Business Analytics project portfolio
- Demonstration of financial analysis skills
- Learning Streamlit and data visualization
- Banking executive dashboard simulation
Developed as a portfolio project to demonstrate skills in:
- Data Engineering
- Business Analytics
- Financial Analysis
- Python Development
- Streamlit Development