- It should solve a simple, real problem.
- It should work end-to-end without breaking.
- You should be able to explain every part of it.
Project Overview
People spend money every day but often do not track where it goes. Over time, this leads to confusion about spending habits.Solution:
You will build a system that allows users to:
- Record expenses
- Store them safely
- View all expenses
- Filter by category
- Analyze total and category-wise spending
You are building a backend API system. That means:
- It receives requests (like “add expense”)
- Processes them
- Stores data
- Sends back responses
- User sends data → “₹200 for food”
- Your API receives it
- It stores the data in a database
- When requested, it returns stored data or summaries
Software Required
Before starting, install the following tools.- Python: Python is the programming language used to build the project. It is easy to learn and widely used in backend development.
- Command Prompt (CMD): CMD is where you will type all commands to create folders, run the project, and install libraries.
- Flask: Flask is a lightweight framework that helps you create APIs and handle requests.
- SQLite: SQLite is a simple database that stores your data in a file without needing complex setup.
- Postman: Postman is used to test your API by sending requests and checking responses.
- Git and GitHub: Git tracks your code changes, and GitHub stores your project online.
- Render: Render is used to deploy your project and make it live on the internet.
Step 1: Setting Up the Environment
In this step, you are preparing your system so that your project runs smoothly without errors.1. Open Command Prompt
This opens the command line where you will type all commands.Press Windows + R, type cmd, and press Enter
2. Check Python Installation
Type this in CMD:
This command checks whether Python is installed.python --version
If successful, you will see something like:
If not, install Python and enable “Add to PATH”.Python 3.x.x
3. Create Project Folder
Now type:
This creates your project folder and moves you inside it.mkdir expense-tracker
cd expense-tracker
4. Create Virtual Environment
Type:
This creates an isolated environment for your project.python -m venv venv
5. Activate Virtual Environment
Type:
You should now see (venv) in your terminal. This confirms activation.venv\Scripts\activate
6. Install Required Libraries
Type:
This installs:pip install flask gunicorn
Flask for backend
Gunicorn for deployment
Step 2: Create Project File
You are creating the main file where your backend logic will exist.1. Create file
Type:
This opens Notepad.notepad app.py
Note:
- Save file as app.py
- Make sure it is not saved as .txt
Type:
You should see:dir
app.py
venv
Step 3: Add Complete Code
You are adding the full backend logic so the application can handle requests, store data, and return results.Paste the following code into app.py and save it:
from flask import Flask, request, jsonify
import sqlite3
app = Flask(__name__)
def get_db_connection():
conn = sqlite3.connect("database.db")
conn.row_factory = sqlite3.Row
return conn
def init_db():
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS expenses (
id INTEGER PRIMARY KEY AUTOINCREMENT,
amount REAL NOT NULL,
category TEXT NOT NULL,
date TEXT NOT NULL,
description TEXT
)
""")
conn.commit()
conn.close()
init_db()
@app.route("/")
def home():
return "Expense Tracker API is running"
@app.route("/add", methods=["POST"])
def add_expense():
data = request.get_json()
if not data:
return jsonify({"error": "No input data"}), 400
if not data.get("amount") or not data.get("category") or not data.get("date"):
return jsonify({"error": "Missing fields"}), 400
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute(
"INSERT INTO expenses (amount, category, date, description) VALUES (?, ?, ?, ?)",
(
float(data["amount"]),
data["category"],
data["date"],
data.get("description", "")
)
)
conn.commit()
conn.close()
return jsonify({"message": "Expense added successfully"})
@app.route("/expenses", methods=["GET"])
def get_expenses():
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM expenses")
rows = cursor.fetchall()
conn.close()
return jsonify([dict(row) for row in rows])
@app.route("/expenses/category", methods=["GET"])
def filter_category(category):
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("SELECT * FROM expenses WHERE category=?", (category,))
rows = cursor.fetchall()
conn.close()
return jsonify([dict(row) for row in rows])
@app.route("/summary", methods=["GET"])
def summary():
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("SELECT SUM(amount) as total FROM expenses")
result = cursor.fetchone()
conn.close()
return jsonify({"total": result["total"] or 0})
@app.route("/category-summary", methods=["GET"])
def category_summary():
conn = get_db_connection()
cursor = conn.cursor()
cursor.execute("SELECT category, SUM(amount) as total FROM expenses GROUP BY category")
rows = cursor.fetchall()
conn.close()
return jsonify([dict(row) for row in rows])
if __name__ == "__main__":
app.run(debug=True)
Step 4: Run the Project
You are starting your backend server.1. In the command prompt, type:
This runs your application.python app.py
You should see:
2. Open your browser and go to:Running on http://127.0.0.1:5000/
You should see:http://127.0.0.1:5000/
Expense Tracker API is running
Step 5: Test the API
You are verifying that your backend works correctly. To test API open Postman:1. Add Expense
Expected result:POST → /add
{
"amount": 200,
"category": "Food",
"date": "2026-04-13",
"description": "Lunch"
}
2. Get ExpensesExpense added successfully
3. FilterGET → /expenses
4. SummaryGET → /expenses/Food
5. Category SummaryGET → /summary
GET → /category-summary
Step 6: Create requirements.txt
You are saving project dependencies for deployment. In the command prompt, type:pip freeze requirements.txt
Step 7: Deployment
You are making your project live.1. Initialize Git
In the command prompt, type:
2. Push to GitHubgit init
git add .
git commit -m "Initial commit"
In the command prompt, type:
3. On Rendergit remote add origin YOUR_REPO_URL
git push -u origin main
Build:
Start:pip install -r requirements.txt
gunicorn app:app
Conclusion
This project shows that you can take an idea and turn it into a working system. You set up the environment, built a backend, handled data, tested your APIs, and deployed the application.That is exactly what recruiters look for, not just code, but the ability to build something complete and explain it clearly.
Frequently Asked Questions
1. Can beginners complete this project?2. Do I need frontend?Yes, every step is explained clearly with expected outcomes.
3. What if my project does not run?No, backend is enough for most placements.
4. Is deployment important?Check each step and ensure outputs match expectations.
5. How can I improve this project?Yes, it shows real-world readiness.
Add login, charts, or convert it into a full-stack app.
0 Comments