A comprehensive Streamlit-based banking dashboard designed for executive-level financial monitoring, risk assessment, and automated report generation. This application provides real-time insights into banking performance metrics with interactive visualizations and scenario analysis capabilities.
Experience the dashboard online: data-banking-dashboard.streamlit.app
- Revenue & Margin Tracking: Monitor monthly revenue trends and gross margin performance
- Balance Sheet Analytics: Track deposits and Assets Under Management (AUM) growth
- Profitability Analysis: Segment-wise operating profit breakdown (Retail, Private, Corporate)
- Key Performance Indicators: Real-time KPI dashboard with growth metrics
- Liquidity Coverage Ratio (LCR): Real-time monitoring with color-coded alerts
- Non-Performing Loan (NPL) Ratio: Track credit quality indicators
- Market Value at Risk (VaR): Monitor market risk exposure
- Counterparty Exposure: Track credit concentration risks
- Automated Risk Alerts: Color-coded warnings for threshold breaches
- Baseline Scenario: Normal market conditions
- Adverse Scenario: Economic downturn simulation
- Severe Scenario: Crisis scenario modeling
- Customizable Timeframes: 12-60 months analysis periods
- PDF Report Generation: Automated executive reports with charts
- Interactive Charts: Plotly-powered visualizations
- Export Capabilities: Download reports in PDF format
- Professional Templates: Executive-ready report formatting
- Responsive Design: Works on desktop and mobile devices
- Interactive Sidebar: Easy parameter adjustment
- Real-time Updates: Dynamic chart updates based on scenario changes
- Professional Styling: Clean, executive-friendly interface
- Python 3.8 or higher
- Git
-
Clone the repository
git clone https://github.com/michaelgermini/banking-dashboard.git cd banking-dashboard
-
Create virtual environment
python -m venv .venv
-
Activate virtual environment
# Windows .\.venv\Scripts\Activate.ps1 # macOS/Linux source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Launch the application
python -m streamlit run streamlit_app.py
-
Access the dashboard
- Open your browser and go to:
http://localhost:8501
- The dashboard will automatically open in your default browser
- Open your browser and go to:
- Sidebar Controls: Adjust scenario, time period, and export settings
- KPI Metrics: View key performance indicators in the top row
- Risk Alerts: Monitor risk indicators with color-coded status
- Interactive Charts: Explore financial trends with zoom and hover capabilities
- Report Generation: Create and download PDF reports
- Baseline: Normal economic conditions with steady growth
- Adverse: Economic downturn with reduced growth and increased volatility
- Severe: Crisis scenario with negative growth and high risk
- Configure report settings in the sidebar
- Click "Generate PDF" button
- Download the executive report with charts and analysis
streamlit_app.py
: Main application interface and user interactionsdata.py
: Financial data generation and KPI calculationsreporting.py
: PDF report generation and HTML templatingtemplates/
: HTML templates for report generation
- Frontend: Streamlit (Python web framework)
- Data Visualization: Plotly (Interactive charts)
- Data Processing: Pandas, NumPy
- Report Generation: xhtml2pdf, Jinja2
- Styling: Streamlit native components
Key packages include:
streamlit>=1.36
- Web application frameworkpandas>=2.2
- Data manipulation and analysisplotly>=5.22
- Interactive data visualizationxhtml2pdf>=0.2.15
- PDF report generationjinja2>=3.1
- HTML templatingkaleido>=0.2.1
- Static image export for charts
- Push this repository to GitHub
- Connect your repository to Streamlit Cloud
- Select
streamlit_app.py
as the main file - Deploy with one click
streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Overall Score: 8.5/10 - Well-structured application with recommended improvements
- Excellent modularity: Clear separation of responsibilities
- Clean code: Use of type hints and dataclasses
- Logical structure:
streamlit_app.py
,data.py
,reporting.py
- Separated templates: HTML in
templates/
folder
- No sensitive data: Uses simulated data only
- Input validation: User parameter controls
- Secure file handling:
tempfile.TemporaryDirectory()
- No SQL injection: No database queries
- Streamlit caching:
@st.cache_data
for performance optimization - Efficient generation: Vectorized calculations with NumPy/Pandas
- Memory management: Automatic cleanup of temporary files
- Responsive design: Adaptive layout
- User feedback: Spinners and status messages
- Visual alerts: Color coding for risks (red/yellow/green)
# β Issue: No robust error handling
def generate_pdf_from_html(html: str) -> bytes:
buffer = BytesIO()
result = pisa.CreatePDF(src=html, dest=buffer, encoding="UTF-8")
if result.err:
return buffer.getvalue() # Returns corrupted PDF
return buffer.getvalue()
# β
Recommendation: Proper error handling
def generate_pdf_from_html(html: str) -> bytes:
try:
buffer = BytesIO()
result = pisa.CreatePDF(src=html, dest=buffer, encoding="UTF-8")
if result.err:
raise ValueError(f"PDF generation failed: {result.err}")
return buffer.getvalue()
except Exception as e:
st.error(f"Failed to generate PDF: {str(e)}")
return b""
# β Issue: No parameter validation
def generate_financial_data(periods: int = 36, scenario: str = "Baseline"):
# No validation of 'periods' or 'scenario'
# β
Recommendation: Input validation
def generate_financial_data(periods: int = 36, scenario: str = "Baseline"):
if periods < 1 or periods > 120:
raise ValueError("Periods must be between 1 and 120")
if scenario not in SCENARIOS:
raise ValueError(f"Invalid scenario: {scenario}")
- Missing docstrings for main functions
- No comments on complex business logic
# β Issue: No template validation
def render_html_report(context: Dict[str, Any]) -> str:
template = env.get_template("report.html")
html = template.render(**context) # No context validation
# β
Recommendation: Context validation
def render_html_report(context: Dict[str, Any]) -> str:
required_keys = ["scenario", "period_start", "period_end", "kpis", "risks"]
for key in required_keys:
if key not in context:
raise ValueError(f"Missing required key: {key}")
# β Issue: Unsanitized user data
st.metric("Revenue", format_currency_chf_m(kpis["revenue_chf_m"]))
# β
Recommendation: Type validation
def safe_format_currency(value: Any) -> str:
if not isinstance(value, (int, float)):
raise ValueError("Invalid currency value")
return format_currency_chf_m(float(value))
# β Issue: No NaN handling
deposits_growth = np.r_[np.nan, np.diff(deposits)] / np.r_[np.nan, deposits[:-1]] * 100.0
# β
Recommendation: Handle missing values
deposits_growth = np.r_[np.nan, np.diff(deposits)] / np.r_[np.nan, deposits[:-1]] * 100.0
deposits_growth = np.nan_to_num(deposits_growth, nan=0.0)
# β Issue: No logging
# β
Recommendation: Add logging
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def generate_financial_data(...):
logger.info(f"Generating data for scenario: {scenario}")
# ... code ...
logger.info(f"Generated {len(df)} data points")
- Add user parameter validation
- Implement robust error handling
- Add data sanitization
- Add docstrings and comments
- Implement logging
- Add unit tests
- Handle missing data
- Validate templates
- Performance monitoring
- β No sensitive data exposed
- β Secure temporary file handling
- β No code injection
β οΈ User input validation (needs improvement)β οΈ Error handling (needs improvement)β οΈ Data sanitization (needs to be added)
The software has a solid architecture and clean codebase. The main improvements concern robustness and error handling rather than critical security issues. The application is production-ready with the recommended improvements.
Recommendation: Implement security and robustness improvements before critical production deployment.
Michael Germini - GitHub Profile
This project is open source and available under the MIT License.
For questions, issues, or feature requests, please:
- Open an issue on GitHub, or
- Contact the author directly: michael@germini.info
Built with β€οΈ using Streamlit and Python