Skip to content

itversity/emi-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EMI Calculator Application

A full-stack web application for calculating Equated Monthly Installments (EMI) with advanced features like amortization schedules, prepayment scenarios, and loan comparisons.

Features

  • Basic EMI Calculator: Calculate monthly EMI with detailed breakdown
  • Dual Calculation Methods: Support for both Reducing Balance and Flat Rate interest calculations
  • Amortization Schedule: View month-by-month payment details
  • Visual Charts: Interactive charts showing payment distribution
  • Prepayment Calculator: Analyze impact of prepayments on your loan
  • Loan Comparison: Compare multiple loan scenarios side-by-side

Tech Stack

Backend

  • FastAPI
  • Python 3.8+
  • Pydantic for data validation

Frontend

  • React 18
  • Vite
  • React Router
  • Recharts for visualizations
  • Tailwind CSS for styling
  • Axios for API calls

Project Structure

emi-calculator-1/
├── backend/
│   ├── main.py
│   ├── models.py
│   ├── calculations.py
│   └── requirements.txt
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── services/
│   │   ├── utils/
│   │   └── App.jsx
│   ├── package.json
│   └── vite.config.js
└── README.md

Setup Instructions

Prerequisites

  • Python 3.8 or higher
  • Node.js 16 or higher
  • npm or yarn

🚀 Easiest Way - Use the Startup Scripts

We've provided convenient scripts to run the application with one command:

On macOS/Linux:

./start.sh

On Windows:

start.bat

This will automatically:

  • Set up backend and frontend (first time only)
  • Start both services in separate terminal windows
  • Open the application in your browser

If the automatic script doesn't work, use the manual guide:

./start-manual.sh  # Shows step-by-step instructions

Manual Setup

Backend Setup

Option 1: Using the setup script (Recommended)

On macOS/Linux:

cd backend
./setup.sh
./run.sh

On Windows:

cd backend
setup.bat
run.bat

Option 2: Manual commands

  1. Navigate to the backend directory:
cd backend
  1. Create a virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the FastAPI server:
uvicorn main:app --reload

The backend will be available at http://localhost:8000 API documentation (Swagger UI) at http://localhost:8000/docs

Frontend Setup

Option 1: Using the setup script (Recommended)

On macOS/Linux:

cd frontend
./setup.sh
./run.sh

On Windows:

cd frontend
setup.bat
run.bat

Option 2: Manual commands

  1. Open a new terminal and navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Run the development server:
npm run dev

The frontend will be available at http://localhost:5173

Available Scripts

Root Level

  • start.sh / start.bat - Start both backend and frontend automatically
  • start-manual.sh - Show manual startup instructions

Backend Directory

  • setup.sh / setup.bat - Set up backend environment
  • run.sh / run.bat - Run backend server

Frontend Directory

  • setup.sh / setup.bat - Set up frontend dependencies
  • run.sh / run.bat - Run frontend development server

API Endpoints

  • POST /api/calculate-emi - Calculate basic EMI
  • POST /api/amortization-schedule - Generate payment schedule
  • POST /api/calculate-with-prepayment - Calculate with prepayment
  • POST /api/compare-loans - Compare multiple loans

Usage

Home Page (Basic EMI Calculator)

  1. Start both backend and frontend servers
  2. Open your browser to http://localhost:5173
  3. Enter the following details:
    • Loan Amount: The total amount you want to borrow (e.g., ₹10,00,000)
    • Annual Interest Rate: The yearly interest rate in percentage (e.g., 8.5%)
    • Loan Tenure: Duration of the loan in months (e.g., 240 for 20 years)
    • Calculation Method: Choose between:
      • Reducing Balance: Interest calculated on remaining balance (recommended for most loans)
      • Flat Rate: Interest calculated on original amount (results in higher interest)
  4. Click "Calculate EMI" to see:
    • Monthly EMI amount
    • Total interest payable
    • Total payment amount
    • Calculation method badge
    • Detailed amortization schedule
    • Interactive charts showing payment breakdown
  5. Export the amortization schedule to CSV for record-keeping

Note: For the same loan amount, rate, and tenure, Flat Rate will result in approximately double the interest compared to Reducing Balance. This is because flat rate interest is calculated on the full principal amount throughout the loan period, while reducing balance interest decreases as you pay down the principal.

Prepayment Calculator

  1. Navigate to the "Prepayment" page from the top menu
  2. Enter your loan details and prepayment information:
    • Basic loan parameters (amount, rate, tenure)
    • Calculation Method: Choose Reducing Balance or Flat Rate
    • Prepayment Amount: How much extra you want to pay
    • Prepayment Frequency: Choose monthly, yearly, or one-time
    • Start Month: When to begin prepayments
  3. Click "Calculate Prepayment Impact" to see:
    • Interest savings from prepayment
    • Reduced loan tenure
    • Side-by-side comparison with and without prepayment
    • Visual charts comparing both scenarios

Loan Comparison

  1. Navigate to the "Comparison" page
  2. Add multiple loan scenarios (2-5 scenarios)
  3. For each scenario, enter:
    • Custom name for the loan
    • Principal amount
    • Interest rate
    • Tenure
    • Calculation method (can mix Reducing Balance and Flat Rate)
  4. Click "Compare Loans" to see:
    • Best option by monthly EMI
    • Best option by total payment
    • Detailed comparison table
    • Visual charts comparing all scenarios
  5. Use this to compare offers from different banks or tenure options

Key Features

Calculation Features

  • Accurate EMI Calculation: Uses the standard EMI formula for precise calculations
  • Two Calculation Methods:
    • Reducing Balance (Most Common): Interest is calculated on the outstanding principal balance each month. As you pay down the loan, the interest decreases. This is the standard method used by most banks for home loans, car loans, and personal loans.
    • Flat Rate: Interest is calculated on the original principal amount for all months. The interest remains the same throughout the loan tenure, resulting in higher total interest paid. This method is sometimes used for consumer loans and durables financing.
  • Amortization Schedule: Month-by-month breakdown of principal and interest
  • Prepayment Scenarios: Analyze the impact of extra payments on loan tenure and interest (works with both calculation methods)
  • Multi-Loan Comparison: Compare up to 5 different loan scenarios simultaneously with different calculation methods

User Experience

  • Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
  • Real-time Validation: Input validation with helpful error messages
  • Interactive Charts: Visual representations using Recharts library
  • CSV Export: Download amortization schedules for offline use
  • Toast Notifications: User-friendly feedback for all actions

Technical Features

  • Fast API: High-performance backend with automatic API documentation
  • Modern Frontend: Built with React 18 and Vite for fast development
  • Type Safety: Pydantic models ensure data validation on the backend
  • Clean Architecture: Separation of concerns with organized file structure

Troubleshooting

Backend Issues

Port 8000 already in use:

# Find and kill the process using port 8000
lsof -ti:8000 | xargs kill -9

# Or run on a different port
uvicorn main:app --reload --port 8001

Module not found errors:

# Make sure virtual environment is activated
source venv/bin/activate

# Reinstall dependencies
pip install -r requirements.txt

Frontend Issues

Port 5173 already in use:

  • Vite will automatically try the next available port
  • Or manually specify a port in vite.config.js

npm install fails:

# Clear npm cache
npm cache clean --force

# Try with legacy peer deps
npm install --legacy-peer-deps

CORS errors:

  • Ensure backend is running on http://localhost:8000
  • Check that CORS is properly configured in backend/main.py

General Issues

Calculations seem incorrect:

  • Verify input values are positive numbers
  • Check that interest rate is annual (not monthly)
  • Ensure tenure is in months (not years)

Charts not displaying:

  • Check browser console for errors
  • Ensure recharts library is properly installed
  • Try refreshing the page

Future Enhancements

  • Save and load loan scenarios
  • User authentication and history
  • Email reports
  • More loan types (reducing balance, flat rate) - ✅ COMPLETED
  • Tax benefits calculator
  • Mobile app version
  • Multi-currency support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published