A production-ready full-stack Django 4.x web application for tracking income, expenses, budgets, and financial analytics.
| Module | Capabilities |
|---|---|
| Auth | Register Β· Login Β· Logout Β· Password change |
| Transactions | Add Β· Edit Β· Delete Β· Filter by type/category/date/search Β· Pagination |
| Categories | 15 predefined global categories + unlimited custom categories |
| Budgets | Monthly budgets per category Β· Progress bars Β· 80%/100% email alerts |
| Analytics | Google Charts: Pie (category spend) Β· Line (monthly trend) Β· Bar (weekly spend) |
| Exports | CSV (all transactions) Β· PDF (monthly report via ReportLab) |
| Dashboard | Income Β· Expense Β· Net balance Β· Budget progress Β· Recent transactions |
- Backend: Django 4.2, Python 3.11+
- Database: SQLite3
- Frontend: Bootstrap 5.3, Vanilla JS (ES6+)
- Charts: Google Charts API
- Email: Django SMTP (console backend for dev)
- PDF: ReportLab 4.x
- CSV: Python
csvmodule
pip install -r requirements.txtcp .env.example .env
# Open .env and set:
# SECRET_KEY=<generate with: python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())">
# EMAIL_HOST_USER / EMAIL_HOST_PASSWORD (or leave console backend for dev)python manage.py migrateThis applies two migrations:
0001_initialβ creates all tables with indexes & constraints0002_seed_predefined_categoriesβ inserts 15 global categories
python manage.py seed_demo
# Creates user: demo / Demo@1234
# Populates 3 months of sample transactions and budgetspython manage.py createsuperuserpython manage.py runserverVisit: http://127.0.0.1:8000
finance_tracker/
βββ manage.py
βββ requirements.txt
βββ .env.example
β
βββ finance_tracker/ β Django project package
β βββ settings.py β All configuration (uses python-decouple)
β βββ urls.py β Root URL router
β βββ wsgi.py / asgi.py
β
βββ tracker/ β Main Django app
β βββ models.py β Category, Transaction, Budget
β βββ forms.py β All ModelForms + filter form
β βββ services.py β Business logic (summaries, chart data)
β βββ signals.py β post_save β budget alert emails
β βββ admin.py β Rich admin interface
β βββ apps.py β AppConfig (registers signals)
β βββ templatetags/
β β βββ finance_tags.py β currency, percentage, income_color filters
β βββ migrations/
β β βββ 0001_initial.py
β β βββ 0002_seed_predefined_categories.py
β βββ views/
β β βββ auth_views.py
β β βββ dashboard_views.py
β β βββ transaction_views.py
β β βββ category_views.py
β β βββ budget_views.py
β β βββ chart_views.py β JSON endpoints for Google Charts
β β βββ analytics_views.py
β β βββ export_views.py β CSV + PDF
β βββ urls/
β β βββ auth_urls.py β /auth/β¦
β β βββ app_urls.py β /dashboard/, /transactions/, /api/β¦
β βββ management/commands/
β βββ seed_demo.py
β
βββ templates/
β βββ base.html β Master layout (sidebar + topbar)
β βββ registration/ β login, register, password_change
β βββ email/ β budget_warning.html, budget_critical.html
β
βββ tracker/templates/tracker/
β βββ dashboard.html
β βββ analytics.html β Google Charts page
β βββ transactions/ β list, form, confirm_delete
β βββ categories/ β list, form, confirm_delete
β βββ budgets/ β list, form, confirm_delete
β
βββ static/
βββ css/main.css β Custom styles on Bootstrap 5
βββ js/main.js β Sidebar, animations, UX helpers
| URL | View | Description |
|---|---|---|
/ |
Redirect | β /dashboard/ |
/auth/register/ |
RegisterView | Create account |
/auth/login/ |
CustomLoginView | Sign in |
/auth/logout/ |
CustomLogoutView | Sign out |
/dashboard/ |
DashboardView | Main overview |
/analytics/ |
AnalyticsView | Google Charts page |
/transactions/ |
TransactionListView | Filtered paginated list |
/transactions/add/ |
TransactionCreateView | Add transaction |
/transactions/<pk>/edit/ |
TransactionUpdateView | Edit transaction |
/transactions/<pk>/delete/ |
TransactionDeleteView | Delete transaction |
/categories/ |
CategoryListView | List all categories |
/budgets/ |
BudgetListView | Current month budgets |
/export/csv/ |
ExportCSVView | Download all transactions |
/export/pdf/ |
ExportPDFView | Download monthly PDF report |
/api/charts/category-spending/ |
CategorySpendingAPIView | JSON for pie chart |
/api/charts/monthly-trend/ |
MonthlyTrendAPIView | JSON for line chart |
/api/charts/weekly-spending/ |
WeeklySpendingAPIView | JSON for bar chart |
/admin/ |
Django Admin | Admin panel |
Development (default β prints to console):
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackendProduction (Gmail example):
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-email@gmail.com
EMAIL_HOST_PASSWORD=your-app-password # Use Gmail App Password, not main password
DEFAULT_FROM_EMAIL=Finance Tracker <your-email@gmail.com>Budget alert emails fire automatically via Django signals when:
- A transaction pushes category spending to β₯ 80% of the budget β warning email
- A transaction pushes category spending to β₯ 100% of the budget β critical email
Each alert is sent once per budget period (tracked via warning_sent/critical_sent flags).
All endpoints require login (@login_required).
GET /api/charts/category-spending/?month=M&year=Y
{
"data": [["Category", "Amount"], ["Food & Dining", 4200.0], ["Transport", 1500.0]],
"status": "ok"
}GET /api/charts/monthly-trend/?months=6
{
"labels": ["Nov 24", "Dec 24", "Jan 25"],
"income": [65000.0, 70000.0, 68000.0],
"expense": [28000.0, 35000.0, 29000.0],
"status": "ok"
}GET /api/charts/weekly-spending/?weeks=8
{
"data": [["Week Starting", "Expenses"], ["Apr 01", 3200.0], ["Apr 08", 4100.0]],
"status": "ok"
}After python manage.py runserver:
- Register a new account β redirected to dashboard
- Login / Logout works
- Add income transaction β balance increases
- Add expense transaction β balance decreases
- Filter transactions by type, category, date range, search
- Create a budget β progress bar appears on dashboard
- Add expense that crosses 80% β warning email in console
- Add expense that crosses 100% β critical email in console
- Analytics page loads all 3 Google Charts
- Change month selector on analytics β pie chart refreshes
- Download CSV β file opens in spreadsheet app
- Download PDF β clean formatted report with tables
- Admin panel at
/admin/β verify all models visible - Mobile layout β sidebar collapses, hamburger appears
-
python manage.py seed_demoβ demo/Demo@1234 works
- All views behind
LoginRequiredMixinor@login_required - CSRF protection on all POST forms (
{% csrf_token %}) - Users can only access their own data (queryset filtered by
user=request.user) PermissionDeniedraised if user tries to edit/delete another user's data- Predefined categories are read-only (protected in view layer)
- Passwords hashed with Django's default PBKDF2+SHA256
MIT β free to use, modify, and distribute.