This project is a simple credit simulator. It calculates a monthly amortization schedule (French system) and shows it in a table. The backend also saves each simulation in a database, and it runs a mock “risk audit” asynchronously (it does not block the main response).
- Frontend: React (Vite).
- Backend: FastAPI(Python).
- Database: SQLite.
Requirements:
- Node.js (recommended: LTS)
- Python (recommended: 3.10+)
- pip (Python package manager)
- Create and activate a virtual environment.
Windows:
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1MacOS/Linux:
cd backend
python3 -m venv .venv
source .venv/bin/activate- Install dependencies.
pip install -r requirements.txt- Run the API (local).
fastapi dev main.pyThe backend will run at:
Optional (Swagger UI):
- Install dependencies.
cd frontend
npm install- Run the app local.
npm run dev-
Start the backend.
-
Start the frontend.
-
Open the frontend URL in your browser.
-
Enter:
- Monto del crédito (Loan amount)
- Interés anual (%) (Annual interest rate)
- Plazo (meses) (Term in months)
-
Click "Calcular" to generate the amortization table.
POST /simulate
Calculates the amortization schedule and saves the simulation in the database.
Request body (JSON):
{
"amount": 50000,
"rate": 24,
"months": 1
}Response (example):
{
"ok": true,
"simulation_id": 1,
"audit_status": "PENDING",
"data": {
"monthly_payment": 25752.48,
"total_paid": 1504.95,
"total_interest": 51504.95,
"schedule": [
{ "month": 1, "payment": 25752.48, "interest": 1000.00, "principal": 24752.48, "balance": 25247.52 },
{ "month": 2, "payment": 25752.48, "interest": 504.95, "principal": 25247.52, "balance": 0 }
]
}
}GET /simulations/{id}
Returns the current status of the risk audit for a given simulation.
Response (example):
{
"id": 1,
"audit_status": "SUCCESS"
}The database is stored as a file: creditsim.db.
Location: it is created in the directory where the backend is executed.
This project stores:
- Input values (amount, annual rate, months).
- Calculation results (monthly payment, total interest and principal).
- Full amortization schedule (stored as JSON).
- Audit status (PENDING, SUCCESS, FAILED)
After each simulation:
- The API triggers a mock external scoring/audit process.
- It runs asynchronously (background) and does not block the /simulate response.
- It takes 1–3 seconds.
- It fails ~10% of the time (simulated).
This project is licensed under the MIT License (2026). See the LICENSE file for details.