A comprehensive expense tracking application built with ASP.NET Core MVC and SQL Server, featuring AI-powered financial insights and interactive dashboards.
- Real-time financial overview of the last 7 days
- Visual representations of income and expenses using doughnut and spline charts
- Quick summary showing total income, expenses, and current balance
- Recent transactions list
- Category-wise expense breakdown
- Add, edit, and delete transactions
- Categorize transactions
- Add notes to transactions
- Date tracking for each transaction
- Category-based filtering
- Create and manage custom categories
- Assign icons to categories
- Categorize as income or expense
- Edit and delete categories
- Automated financial analysis using OpenAI GPT
- Personalized financial advice
- Spending pattern analysis
- Custom recommendations for better financial management
- Backend: ASP.NET Core MVC
- Database: SQL Server with Entity Framework Core
- Frontend: Bootstrap, JavaScript
- AI Integration: OpenAI GPT-3.5 API
- Charts: Syncfusion (or your chosen charting library)
- Prerequisites
- Visual Studio 2022 or later
- .NET 6.0 or later
- SQL Server
First, ensure you have these NuGet packages installed in your project:
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.EntityFrameworkCore.Design
In appsettings.json
, add your database connection string:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=ExpenseTracker;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
Ensure your models are properly configured. Key models include:
public class Category
{
[Key]
public int CategoryId { get; set; }
[Required]
public string Title { get; set; }
public string Icon { get; set; }
public string Type { get; set; }
}
public class Transaction
{
[Key]
public int TransactionId { get; set; }
[Range(1, int.MaxValue)]
public int CategoryId { get; set; }
public Category Category { get; set; }
public int Amount { get; set; }
public string Note { get; set; }
public DateTime Date { get; set; }
}
Open Package Manager Console and run:
# Create initial migration
Add-Migration InitialCreate
# Apply migration to database
Update-Database
# Create a new migration
Add-Migration MigrationName
# Remove last migration (if not applied to database)
Remove-Migration
# Apply migrations to database
Update-Database
# Generate SQL script (useful for production deployments)
Script-Migration
If you encounter issues:
-
Migration not applying:
Update-Database -Verbose
-
Reset database:
# Drop the database Drop-Database # Remove all migrations Remove-Migration -Force # Start fresh Add-Migration InitialCreate Update-Database
-
Check migration status:
Get-Migration
Then create and apply a new migration:
Add-Migration SeedData
Update-Database
[Rest of the README remains the same...]
-
Configuration
- Update
appsettings.json
with your database connection string - Add your OpenAI API key in configuration:
{ "ApiSettings": { "AI_API_KEY": "your-api-key-here" } }
- Update
-
Run the Application
- Build and run the application in Visual Studio
- Navigate to
https://localhost:[port]
Expense_Tracker/
├── Controllers/
│ ├── DashboardController.cs
│ ├── CategoryController.cs
│ ├── HomeController.cs
│ ├── TransactionController.cs
│ └── AIReportsController.cs
├── Models/
│ ├── Category.cs
│ ├── ApplicationDbContext.cs
│ ├── ErrorViewModel.cs
│ └── Transaction.cs
├── Views/
│ ├── AIReport/index.cshtml
│ ├── Dashboard/index.cshtml
│ ├── Category/index.cshtml
│ └── Transaction/index.cshtml