Smart Finance Manager is a powerful Django web application for tracking personal expenses, managing savings goals, and monitoring financial analytics. Users can register accounts, log in securely, record expenses and additions, set savings targets, and view detailed transaction history with interactive charts.
- Secure user registration (signup)
- User login with session management
- Logout functionality
- Automatic UserProfile and ExpenseAccount creation for new users
- Record expenses with descriptions
- Add balance/income to account
- Real-time balance updates
- Transaction history with timestamps
- Set monthly savings targets
- Track progress towards goals
- See remaining amount to save
- Interactive doughnut chart showing balance breakdown
- View all transactions with filtering
- Delete transactions (reverses the impact on balance)
- Calculate total expenses and additions
- Mobile-friendly interface
- Bootstrap 5 styling
- Beautiful gradient backgrounds
- Smooth animations
- Backend: Django 5.2
- Database: SQLite3
- Frontend: HTML5, CSS3, Bootstrap 5
- Charts: Chart.js
- Authentication: Django's built-in auth system
- Environment: Python 3.8+
mini/
├── home/
│ ├── migrations/ # Database migration files
│ ├── templates/home/ # HTML templates
│ │ ├── base.html
│ │ ├── homepage.html
│ │ ├── login.html
│ │ ├── signup.html
│ │ ├── transcations.html
│ │ ├── navbar.html
│ │ ├── finance.html
│ │ ├── analytics.html
│ │ └── pricing.html
│ ├── static/ # Static files (CSS, JS, images)
│ ├── admin.py # Django admin configuration
│ ├── apps.py # App configuration with signals
│ ├── forms.py # Django forms for signup, login, expense
│ ├── models.py # Database models
│ ├── signals.py # Signal handlers for auto-creation
│ ├── urls.py # URL routing
│ ├── views.py # View logic
│ └── tests.py # Unit tests
├── smart_finance/
│ ├── settings.py # Django settings
│ ├── urls.py # Main URL configuration
│ ├── wsgi.py # WSGI application
│ └── asgi.py # ASGI application
├── manage.py # Django management script
└── db.sqlite3 # SQLite database file
Extends Django's User model with additional user information.
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
phone = models.CharField(max_length=15, blank=True)
address = models.CharField(max_length=200, blank=True)
city = models.CharField(max_length=50, blank=True)
profile_picture = models.ImageField(upload_to='profiles/', blank=True)
bio = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)Relationships:
- OneToOne with
django.contrib.auth.User
Tracks financial data for each user.
class UserExpenseAccount(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
total_amount = models.DecimalField(max_digits=10, decimal_places=2)
current_balance = models.DecimalField(max_digits=10, decimal_places=2)
target_amount = models.DecimalField(max_digits=10, decimal_places=2)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)Fields:
total_amount: Sum of all additionscurrent_balance: total_amount - total_expensestarget_amount: User's monthly savings goal
Relationships:
- OneToOne with
django.contrib.auth.User - ForeignKey from
Transaction(reverse:transactions)
Records all financial transactions (expenses and additions).
class Transaction(models.Model):
TRANSACTION_TYPE = [
('expense', 'Expense'),
('addition', 'Addition'),
]
user_account = models.ForeignKey(UserExpenseAccount, on_delete=models.CASCADE)
transaction_type = models.CharField(max_length=10, choices=TRANSACTION_TYPE)
amount = models.DecimalField(max_digits=10, decimal_places=2)
description = models.CharField(max_length=200, blank=True)
created_at = models.DateTimeField(auto_now_add=True)Fields:
transaction_type: Either 'expense' or 'addition'amount: Transaction amountdescription: Description of transactioncreated_at: Timestamp
Ordering: By created_at descending (newest first)
- User fills signup form with first name, last name, email, username, password
SignUpFormvalidates:- Password strength
- Email uniqueness
- Username uniqueness
- User is created in database
- Signal automatically creates:
UserProfilelinked to UserUserExpenseAccountlinked to User
- User redirected to login page
- User enters username and password
- Django's
authenticate()validates credentials - Session is created
- User redirected to dashboard (homepage)
- User clicks logout
- Session is destroyed
- User redirected to finance page
Located in home/signals.py, these automatically handle data creation:
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
"""Creates UserProfile when new User is created"""
if created:
UserProfile.objects.create(user=instance)
@receiver(post_save, sender=User)
def create_user_expense_account(sender, instance, created, **kwargs):
"""Creates UserExpenseAccount when new User is created"""
if created:
UserExpenseAccount.objects.create(user=instance)Extends Django's UserCreationForm with additional fields.
Fields:
first_name: User's first namelast_name: User's last nameemail: Unique email addressusername: Unique usernamepassword1: Passwordpassword2: Password confirmation
Validations:
- Email must be unique
- Username must be unique
- Passwords must match
- Password strength requirements
Extends Django's AuthenticationForm with Bootstrap styling.
Fields:
username: User's usernamepassword: User's password
For recording expense transactions.
Fields:
expense_amount: Decimal amountdescription: Optional description
For adding balance to account.
Fields:
add_amount: Decimal amount
For setting monthly savings target.
Fields:
target_amount: Decimal target amount
- URL:
/signup/ - Methods: GET, POST
- Requires Login: No
- Returns: Renders signup form or redirects to login on success
- URL:
/login/ - Methods: GET, POST
- Requires Login: No
- Returns: Renders login form or redirects to homepage on success
- URL:
/logout/ - Methods: GET
- Requires Login: No
- Returns: Redirects to finance page
- URL:
/home/ - Methods: GET, POST
- Features:
- Display expense tracking forms
- Handle form submissions
- Calculate analytics
- Generate chart data
- Context Variables:
account: User's ExpenseAccountexpense_form: Form to add expenseadd_form: Form to add balancetarget_form: Form to set targetlast_transactions: Last 5 transactionstotal_expenses: Sum of all expensestotal_additions: Sum of all additionschart_data: JSON for Chart.js
- URL:
/transcations/ - Methods: GET, POST
- Features:
- Display all transactions
- Handle transaction deletion
- Reverse transaction effects on balance
- POST Parameters:
delete_transaction: Transaction ID to delete
- URL:
/analytics/ - Methods: GET
- Features:
- Display detailed analytics
- Calculate statistics
- URL:
/ - Methods: GET
- Features:
- Display landing page
- No login required
- URL:
/pricing/ - Methods: GET
- Features:
- Display pricing information
- Python 3.8+
- pip (Python package manager)
- Virtual environment (recommended)
python -m venv env
# On Windows:
env\Scripts\activate
# On macOS/Linux:
source env/bin/activatepip install django==5.2.7
pip install pillow # For image uploadscd minipython manage.py makemigrations
python manage.py migratepython manage.py createsuperuser
# Enter username, email, passwordpython manage.py collectstaticpython manage.py runserverVisit: http://127.0.0.1:8000/
-
Sign Up
- Click "Sign Up" in navbar
- Fill in details (first name, last name, email, username, password)
- Click "Create Account"
-
Login
- Enter username and password
- Click "Login"
- Redirected to dashboard
-
Add Balance
- Enter amount in "Add Amount" form
- Click "Add to Balance"
- Balance and total_amount increase
-
Record Expense
- Enter expense amount in "Add Expense" form
- Optionally add description
- Click "Deduct Expense"
- Current balance decreases, transaction recorded
-
Set Savings Goal
- Enter target amount in "Set Target Amount" form
- Click "Set Target"
- View progress on dashboard
-
View Transactions
- Click "Transactions" in navbar
- See all transactions with details
- Delete unwanted transactions
- Deletion reverses the transaction effect
-
View Analytics
- Click "Analytics" in navbar
- See detailed financial statistics
- View interactive charts
- Password Hashing: Passwords are hashed using Django's PBKDF2 algorithm
- CSRF Protection: All forms include CSRF tokens
- SQL Injection: Django ORM prevents SQL injection
- Authentication: Session-based authentication
- Login Required: Dashboard views protected with
@login_requireddecorator
Solution: Ensure virtual environment is activated and dependencies installed
pip install -r requirements.txtSolution: Run migrations
python manage.py migrateSolution: Collect static files
python manage.py collectstatic --noinputSolution: Signals might not be registered. Check apps.py has ready() method
account = request.user.expense_accounttransactions = account.transactions.all()expenses = account.transactions.filter(transaction_type='expense')total = sum(t.amount for t in account.transactions.filter(transaction_type='expense'))transaction = Transaction.objects.get(id=1)
if transaction.transaction_type == 'expense':
account.current_balance += transaction.amount
else:
account.current_balance -= transaction.amount
account.total_amount -= transaction.amount
account.save()
transaction.delete()Edit templates/home/homepage.html CSS:
.card-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}Edit models.py:
TRANSACTION_TYPE = [
('expense', 'Expense'),
('addition', 'Addition'),
('transfer', 'Transfer'), # Add this
]Edit templates/home/homepage.html Bootstrap grid columns
For issues, questions, or suggestions:
- Check existing documentation
- Review Django documentation: https://docs.djangoproject.com/
- Check application logs:
python manage.py runserver
This project is open source and available for personal and educational use.
Last Updated: November 6, 2025
Version: 1.0.0