A modern, microservices-based expense tracking application built with .NET 9.0, featuring robust authentication, comprehensive expense management, and advanced analytics capabilities.
- Features
- Architecture
- Quick Start
- API Documentation
- Development
- Deployment
- Documentation
- Contributing
- Troubleshooting
- License
- 🔐 Secure Authentication - JWT-based authentication with role management
- 💰 Expense Management - Full CRUD operations for expense tracking
- 📊 Analytics & Reporting - Comprehensive financial insights and trends
- 💳 Budget Management - Budget creation, tracking, and alerts
- 📱 RESTful APIs - Well-documented, scalable REST endpoints
- 🐳 Containerized - Docker-ready for easy deployment
- 🏗️ Microservices Architecture - Loosely coupled, independently deployable services
- 🔒 Secure by Design - JWT authentication, input validation, SQL injection protection
- 📈 Scalable - Horizontal scaling support with load balancing
- 🔍 Observable - Comprehensive logging and health checks
- 🧪 Well-Tested - Unit tests with high coverage
- 📖 API Documentation - Interactive Swagger/OpenAPI documentation
graph TB
Client[Client Application] --> Gateway[API Gateway<br/>Nginx:8080]
Gateway --> Auth[Auth Service<br/>:5001]
Gateway --> Expense[Expense Service<br/>:5002]
Gateway --> Budget[Budget Service<br/>:5003]
Gateway --> Analytics[Analytics Service<br/>:5004]
Auth --> AuthDB[(Auth Database)]
Expense --> ExpenseDB[(Expense Database)]
Budget --> BudgetDB[(Budget Database)]
Analytics --> AnalyticsDB[(Analytics Database)]
AuthDB --> SQL[SQL Server<br/>:1433]
ExpenseDB --> SQL
BudgetDB --> SQL
AnalyticsDB --> SQL
style Client fill:#e1f5fe
style Gateway fill:#f3e5f5
style SQL fill:#fff3e0
| Service | Port | Responsibility | Database |
|---|---|---|---|
| API Gateway | 8080 | Request routing, load balancing | - |
| Auth Service | 5001 | Authentication, user management | ExpenseTrackerAuth |
| Expense Service | 5002 | Expense CRUD operations | ExpenseTrackerExpenses |
| Budget Service | 5003 | Budget management, alerts | ExpenseTrackerBudgets |
| Analytics Service | 5004 | Financial analytics, reporting | ExpenseTrackerAnalytics |
| SQL Server | 1433 | Database server | Multiple databases |
- Docker (v20.10+)
- Docker Compose (v2.0+)
- Git
-
Clone the repository
git clone https://github.com/your-username/ExpenseTracker.git cd ExpenseTracker -
Start all services
docker-compose up --build -d
-
Verify deployment
# Check service health curl http://localhost:8080/health # View service status docker-compose ps
-
Access the application
- API Gateway: http://localhost:8080
- Auth Service: http://localhost:8080/auth/swagger
- Expense Service: http://localhost:8080/expense/swagger
- Budget Service: http://localhost:8080/budget/swagger
- Analytics Service: http://localhost:8080/analytics/swagger
-
Register a new user
curl -X POST http://localhost:8080/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "username": "demo_user", "email": "demo@example.com", "password": "SecurePassword123!" }'
-
Login and get JWT token
curl -X POST http://localhost:8080/api/auth/login \ -H "Content-Type: application/json" \ -d '{ "email": "demo@example.com", "password": "SecurePassword123!" }'
-
Create your first expense
curl -X POST http://localhost:8080/api/expense \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_JWT_TOKEN" \ -d '{ "description": "Coffee", "amount": 4.50, "category": "Food & Drink", "date": "2025-10-10T10:30:00Z" }'
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| POST | /api/auth/register |
Register new user | ❌ |
| POST | /api/auth/login |
User login | ❌ |
| GET | /api/auth/profile |
Get user profile | ✅ |
| PUT | /api/auth/profile |
Update profile | ✅ |
| POST | /api/auth/refresh |
Refresh JWT token | ✅ |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/expense |
List user expenses | ✅ |
| POST | /api/expense |
Create new expense | ✅ |
| GET | /api/expense/{id} |
Get expense details | ✅ |
| PUT | /api/expense/{id} |
Update expense | ✅ |
| DELETE | /api/expense/{id} |
Delete expense | ✅ |
| GET | /api/expense/categories |
Get expense categories | ✅ |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/budget |
List user budgets | ✅ |
| POST | /api/budget |
Create budget | ✅ |
| GET | /api/budget/{id} |
Get budget details | ✅ |
| PUT | /api/budget/{id} |
Update budget | ✅ |
| DELETE | /api/budget/{id} |
Delete budget | ✅ |
| GET | /api/budget/{id}/status |
Get budget status | ✅ |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/analytics/dashboard |
Financial dashboard | ✅ |
| GET | /api/analytics/summary |
Expense summary | ✅ |
| GET | /api/analytics/categories |
Category breakdown | ✅ |
| GET | /api/analytics/trends |
Spending trends | ✅ |
| GET | /api/analytics/health-status |
Financial health | ✅ |
Access comprehensive API documentation with interactive testing:
- Swagger UI: http://localhost:8080/swagger
- OpenAPI Spec: http://localhost:8080/swagger/v1/swagger.json
-
Install .NET 9.0 SDK
# macOS (using Homebrew) brew install dotnet # Windows (using Chocolatey) choco install dotnet-9.0-sdk # Or download from: https://dotnet.microsoft.com/download
-
Start dependencies
# Start only database docker-compose up sqlserver -d -
Run services locally
# Auth Service cd Backend/AuthService dotnet run # Expense Service cd Backend/ExpenseService dotnet run # Budget Service cd Backend/BudgetService dotnet run # Analytics Service cd Backend/AnalyticsService dotnet run
ExpenseTracker/
├── Backend/ # .NET microservices
│ ├── AuthService/ # Authentication service
│ ├── ExpenseService/ # Expense management
│ ├── BudgetService/ # Budget management
│ ├── AnalyticsService/ # Analytics & reporting
│ └── Backend.sln # Solution file
├── Gateway/ # Nginx configuration
├── Tests/ # Test projects
├── Docs/ # Documentation
├── Scripts/ # Deployment scripts
├── docker-compose.yml # Container orchestration
├── docker-compose.override.yml # Development overrides
└── README.md # This file
# Run all tests
dotnet test Backend/Backend.sln
# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"
# Run specific service tests
dotnet test Backend/AuthService.Tests/
dotnet test Backend/ExpenseService.Tests/
dotnet test Backend/BudgetService.Tests/
dotnet test Backend/AnalyticsService.Tests/# Format code
dotnet format Backend/Backend.sln
# Static analysis
dotnet build --verbosity normal-
Environment Configuration
# Copy and customize environment file cp .env.example .env # Edit configuration vim .env
-
Production Build
# Build for production docker-compose -f docker-compose.yml -f docker-compose.prod.yml build # Deploy docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
| Variable | Description | Default | Required |
|---|---|---|---|
DB_PASSWORD |
SQL Server password | ExpenseTracker123! |
✅ |
JWT_SECRET |
JWT signing key | Generated | ✅ |
ASPNETCORE_ENVIRONMENT |
Environment | Development |
✅ |
AUTH_SERVICE_PORT |
Auth service port | 5001 |
❌ |
EXPENSE_SERVICE_PORT |
Expense service port | 5002 |
❌ |
BUDGET_SERVICE_PORT |
Budget service port | 5003 |
❌ |
ANALYTICS_SERVICE_PORT |
Analytics service port | 5004 |
❌ |
GATEWAY_PORT |
API Gateway port | 8080 |
❌ |
Monitor service health using built-in endpoints:
# Overall system health
curl http://localhost:8080/health
# Individual service health
curl http://localhost:5001/health # Auth Service
curl http://localhost:5002/health # Expense Service
curl http://localhost:5003/health # Budget Service
curl http://localhost:5004/health # Analytics ServiceComprehensive documentation is available in the docs/ folder:
- 📋 Documentation Index - Complete documentation guide and navigation
- 🏗️ Infrastructure Improvements - Production-ready infrastructure setup and best practices
- 🚀 ArgoCD Deployment - GitOps deployment with ArgoCD
- 🔒 Security Guide - Security practices and vulnerability reporting
- ⚡ General Improvements - Project enhancements and features
- 🛠️ Quality Status - Backend code quality tracking
| Role | Recommended Starting Point |
|---|---|
| Developers | Quality Status → General Improvements |
| DevOps Engineers | Infrastructure Improvements → ArgoCD Deployment |
| Security Teams | Security Guide → Infrastructure Improvements |
| Project Managers | Documentation Index → General Improvements |
- ✅ Production-ready Kubernetes manifests with Kustomize overlays
- ✅ GitOps deployment with ArgoCD for multiple environments
- ✅ Security hardening with RBAC, network policies, and security contexts
- ✅ Auto-scaling with HPA and resource management
- ✅ Monitoring stack with Prometheus and Grafana
- ✅ Backup strategy with automated PostgreSQL backups
- ✅ TLS ingress with rate limiting and security headers
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Add tests for your changes
- Ensure all tests pass
dotnet test Backend/Backend.sln - Commit with conventional commits
git commit -m "feat: add amazing feature" - Push to your fork
git push origin feature/amazing-feature
- Create a Pull Request
- Follow Microsoft C# Coding Conventions
- Write unit tests for new features
- Update documentation for API changes
- Use conventional commit messages
Port Conflicts
# Check which process is using a port
lsof -i :8080
lsof -i :5001
# Kill process using port
sudo kill -9 $(lsof -t -i:8080)Database Connection Issues
# Check SQL Server status
docker-compose logs sqlserver
# Test database connection
docker-compose exec sqlserver /opt/mssql-tools/bin/sqlcmd \
-S localhost -U sa -P ExpenseTracker123! -Q "SELECT 1"
# Reset database
docker-compose down -v
docker-compose up sqlserver -dService Not Starting
# Check service logs
docker-compose logs [service-name]
# Rebuild specific service
docker-compose build [service-name]
docker-compose up [service-name] -d
# Full reset
docker-compose down -v
docker system prune -f
docker-compose up --build -dJWT Token Issues
# Verify JWT configuration
echo $JWT_SECRET
# Check token expiration in logs
docker-compose logs auth-service | grep -i jwt
# Test with new token
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"password"}'# Monitor resource usage
docker stats
# Scale services
docker-compose up --scale expense-service=3
# View detailed logs
docker-compose logs -f --tail=100 [service-name]- 📖 Check our Documentation
- 🐛 Report bugs via Issues
- 💬 Join our Discussions
- 📧 Email: support@expensetracker.com
This project is licensed under the MIT License - see the LICENSE file for details.
- ASP.NET Core - Web framework
- Entity Framework Core - ORM
- Docker - Containerization
- Nginx - Reverse proxy
- SQL Server - Database