Backend Project Structure
The project follows a modular architecture separating calculation logic from the API layer.
Directory Layout
Models/PerMerito/
├── backend/
│ ├── api/
│ │ └── server.py # FastAPI Entry Point
│ ├── data/
│ │ └── *.json # Historical Market Data
│ ├── src/
│ │ ├── monte_carlo.py # Core Simulation Logic
│ │ └── simulation.py # CLI Wrapper
│ └── requirements.txt
└── frontend/ # React Dashboard
Key Files
simulation_v2.py
The CLI entry point for running Monte Carlo simulations. Supports arguments for:
- Principal Amount (
--principal) - Recall Date (
--recall-date) - Scenarios (
--scenarios)
server.py
FastAPI server that wraps the CLI script creates endpoints for the frontend:
POST /api/run: Triggers a new simulation run.GET /api/results: Retrieves latest JSON results.
Data Schema
All money values are stored as float. Dates are ISO 8601 strings (YYYY-MM-DD).