Skip to content

YOUSSEFLJ9/expense_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Expense Tracker - Django Web Application

A comprehensive Django web application designed for individual users to manage their personal finances and track expenses.

Python Django License

๐Ÿ“‹ Features

โœ… User Authentication

  • User registration with email
  • Secure login/logout functionality
  • Each user has isolated data (can only view/manage their own expenses)

๐Ÿ’ฐ Expense Management

  • Add new expenses with amount, category, description, and date
  • Edit existing expenses
  • Delete unwanted expenses
  • List all expenses with filtering options

๐Ÿท๏ธ Category Management

  • Predefined categories: Food, Transport, Rent, Entertainment, Health, Shopping, Utilities, Education, Other
  • Custom categories: Users can create their own categories
  • Ability to delete custom categories

๐Ÿ“Š Monthly Reports

  • Filter expenses by month and year
  • View total spending per month
  • Category-wise breakdown with percentages
  • CSV Export: Download monthly reports as CSV files

๐Ÿ“ˆ Data Visualization (Chart.js)

  • Pie Chart: Visual breakdown of expenses by category
  • Bar Chart: Daily expenses for the last 7 days
  • Interactive and responsive charts

๐ŸŽฏ Dashboard

  • Quick overview of monthly and total expenses
  • Recent expenses list
  • Visual charts and statistics
  • Quick action buttons

๐Ÿ› ๏ธ Technical Stack

  • Backend: Django 5.0.1
  • Database: SQLite (for development)
  • Frontend: Django Templates + Bootstrap 5
  • Charts: Chart.js 4.4.0
  • Icons: Font Awesome 6.4.0

๐Ÿ“ Project Structure

project/
โ”œโ”€โ”€ manage.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ db.sqlite3 (created after migrations)
โ”œโ”€โ”€ expense_tracker/          # Main project configuration
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ settings.py          # Project settings
โ”‚   โ”œโ”€โ”€ urls.py              # Main URL configuration
โ”‚   โ”œโ”€โ”€ wsgi.py
โ”‚   โ””โ”€โ”€ asgi.py
โ”œโ”€โ”€ expenses/                 # Main application
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ models.py            # Category & Expense models
โ”‚   โ”œโ”€โ”€ views.py             # All view logic
โ”‚   โ”œโ”€โ”€ forms.py             # Django forms
โ”‚   โ”œโ”€โ”€ urls.py              # App URL patterns
โ”‚   โ”œโ”€โ”€ admin.py             # Admin interface configuration
โ”‚   โ”œโ”€โ”€ apps.py
โ”‚   โ””โ”€โ”€ management/          # Custom management commands
โ”‚       โ””โ”€โ”€ commands/
โ”‚           โ””โ”€โ”€ create_categories.py
โ””โ”€โ”€ templates/               # HTML templates
    โ”œโ”€โ”€ base.html           # Base template with Bootstrap
    โ””โ”€โ”€ expenses/
        โ”œโ”€โ”€ login.html
        โ”œโ”€โ”€ register.html
        โ”œโ”€โ”€ dashboard.html
        โ”œโ”€โ”€ expense_list.html
        โ”œโ”€โ”€ expense_form.html
        โ”œโ”€โ”€ expense_confirm_delete.html
        โ”œโ”€โ”€ category_list.html
        โ”œโ”€โ”€ category_form.html
        โ”œโ”€โ”€ category_confirm_delete.html
        โ””โ”€โ”€ monthly_report.html

๐Ÿš€ Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)

Step-by-Step Setup

  1. Clone or navigate to the project directory

    cd /root/ymomen/project
  2. Create a virtual environment (recommended)

    python -m venv venv
    source venv/bin/activate  # On Linux/Mac
    # or
    venv\Scripts\activate  # On Windows
  3. Install dependencies

    pip install -r requirements.txt
  4. Run database migrations

    python manage.py makemigrations
    python manage.py migrate
  5. Create predefined categories

    python manage.py create_categories
  6. Create a superuser (for admin access)

    python manage.py createsuperuser
  7. Run the development server

    python manage.py runserver
  8. Access the application

๐Ÿ“– Usage Guide

Getting Started

  1. Register a new account

    • Navigate to the registration page
    • Fill in username, email, and password
    • You'll be automatically logged in after registration
  2. Add your first expense

    • Click "Add Expense" button
    • Enter amount, select category, choose date
    • Optionally add a description
    • Click "Save Expense"
  3. View your dashboard

    • See monthly and total spending summaries
    • View charts showing expense breakdown
    • Check recent expenses
  4. Manage categories

    • View all predefined categories
    • Create custom categories for your needs
    • Delete custom categories if not needed
  5. Generate reports

    • Go to "Reports" section
    • Select month and year
    • View detailed breakdown
    • Export to CSV for external use

Key Features Explained

Expense Filtering

  • Filter by category to see specific types of expenses
  • Filter by month and year to analyze spending patterns
  • View total amounts for filtered results

Monthly Reports

  • Comprehensive breakdown by category
  • Shows count and percentage for each category
  • Detailed list of all expenses in the month
  • One-click CSV export

Data Security

  • Each user can only see their own data
  • Secure authentication required
  • Database-level isolation ensures privacy

๐ŸŽจ UI Features

  • Responsive Design: Works on desktop, tablet, and mobile
  • Bootstrap 5: Modern and clean interface
  • Font Awesome Icons: Visual clarity and appeal
  • Color-coded Cards: Easy identification of different metrics
  • Interactive Charts: Hover for detailed information
  • Alert Messages: User feedback for all actions

๐Ÿ”ง Django Best Practices Implemented

Models

  • Proper field types with validation
  • Database indexes for performance
  • Relationships with appropriate on_delete behavior
  • Model methods and properties for reusability

Views

  • Function-based views (FBVs) for clarity
  • @login_required decorator for security
  • Proper user filtering to ensure data isolation
  • Django ORM aggregation (Sum, Count, Annotate)

Forms

  • Django ModelForms for DRY principle
  • Custom widgets for better UX
  • Form validation
  • Dynamic form field queries based on user

Templates

  • Template inheritance with base.html
  • Context processors for global data
  • Template filters for formatting
  • DRY principle with reusable components

Security

  • CSRF protection enabled
  • User-specific queries prevent data leaks
  • Password validation
  • SQL injection protection via ORM

๐Ÿ“Š Database Schema

Category Model

  • name: CharField (max 100 characters)
  • user: ForeignKey to User (nullable for predefined)
  • is_predefined: BooleanField
  • created_at: DateTimeField (auto)
  • Unique together constraint on (name, user)

Expense Model

  • user: ForeignKey to User
  • amount: DecimalField (10 digits, 2 decimal places)
  • category: ForeignKey to Category (nullable, SET_NULL on delete)
  • description: TextField (max 500 characters, optional)
  • date: DateField
  • created_at, updated_at: DateTimeField (auto)
  • Indexes on (user, date) and (user, category)

๐Ÿ”ฎ Future Enhancements (Optional)

  • Budget setting and alerts
  • Recurring expenses
  • Income tracking
  • Multi-currency support
  • Mobile app version
  • Email notifications
  • Advanced analytics and trends
  • Data import from CSV
  • Expense categories with subcategories
  • Tags for expenses
  • Search functionality
  • Pagination for large datasets

Built with โค๏ธ using Django

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors