A baseline template for a budget tracking application built with ASP.NET Core 9 Web API and React with TypeScript. This template provides essential user authentication and a foundation for building budget tracking features.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React Frontend β β ASP.NET Core β β PostgreSQL β
β (Port 5173) βββββΊβ Web API βββββΊβ Database β
β β β (Port 5295) β β (Port 5432) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
Backend:
- ASP.NET Core 9 (Minimal APIs)
- Entity Framework Core
- PostgreSQL 17
- ASP.NET Core Identity for authentication
- Static API Key authentication support
- Swagger UI for API documentation
- xUnit v3 for testing
Frontend:
- React 18 with TypeScript
- Vite (build tool and dev server)
- React Router v7
- Tailwind CSS for styling
- Axios for API communication
- date-fns for date formatting
Infrastructure:
- Docker Compose for PostgreSQL database
- Testcontainers for integration testing
- Cross-platform development support
Before you begin, ensure you have the following tools installed:
| Tool | Version | Download Link |
|---|---|---|
| .NET 9 SDK | 9.0+ | Download .NET 9 |
| Node.js | 18+ | Download Node.js |
| Docker Desktop | Latest | Download Docker |
| Git | Latest | Download Git |
git clone <repository-url>
cd ai-budget-tracker-workshopCopy the environment template and configure your settings:
cp .env.example .envEdit .env with your preferred settings (optional - defaults work for local development).
Option A: Database Only (Recommended for Development)
Start just the PostgreSQL database using Docker:
cd docker
docker-compose up -dcd docker
docker-compose up -dOption B: Full Stack with Docker
Alternatively, you can run the entire stack (database, API, and web) using Docker:
# From project root
docker-compose up -dThis will start:
- Database: PostgreSQL on port 5432
- API: ASP.NET Core on port 5295
- Web: React app on port 5173
Database Configuration:
- Host: localhost
- Port: 5432
- Database: budgettracker
- Username: budgetuser
- Password: budgetpass123
Build and run the ASP.NET Core API:
# Build the solution
dotnet build
# Run the API
cd src/BudgetTracker.Api
dotnet runThe API will be available at:
- API Base URL: http://localhost:5295
- Swagger UI: http://localhost:5295/swagger
- API Status: http://localhost:5295/ (returns "API")
Install dependencies and start the React development server:
cd src/BudgetTracker.Web
npm install
npm run devThe React application will be available at: http://localhost:5173
-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -
Install .NET 9 SDK:
brew install --cask dotnet-sdk
-
Install Node.js:
brew install node
-
Install Docker Desktop:
brew install --cask docker
-
Verify installations:
dotnet --version # Should show 9.x.x node --version # Should show 18.x.x or higher docker --version # Should show Docker version
-
Install .NET 9 SDK:
- Download from Microsoft's website
- Run the installer and follow the setup wizard
-
Install Node.js:
- Download from nodejs.org
- Choose the LTS version
- Run the installer with default settings
-
Install Docker Desktop:
- Download from Docker's website
- Enable WSL 2 integration during installation
- Restart your computer after installation
-
Verify installations (in PowerShell):
dotnet --version # Should show 9.x.x node --version # Should show 18.x.x or higher docker --version # Should show Docker version
Option A: Individual Services (Recommended for Development)
-
Start the database:
cd docker && docker-compose up -d
-
Start the backend (in a new terminal):
cd src/BudgetTracker.Api && dotnet run
-
Start the frontend (in another terminal):
cd src/BudgetTracker.Web && npm run dev
Option B: Full Docker Stack
# From project root
docker-compose up -dAccess the applications:
- Frontend: http://localhost:5173
- API: http://localhost:5295
- Database: localhost:5432
When you make changes to the data model:
cd src/BudgetTracker.Api
dotnet ef migrations add MigrationName -o Infrastructure/Migrations
dotnet ef database updateProblem: Cannot connect to PostgreSQL database Solutions:
- Ensure Docker is running:
docker ps - Check if database container is up:
docker-compose ps - Restart database:
docker-compose down && docker-compose up -d - Verify connection string in
appsettings.json
Problem: Port 5295 or 5173 already in use Solutions:
- Find process using port:
lsof -i :5295(macOS/Linux) ornetstat -ano | findstr :5295(Windows) - Kill the process or change ports in configuration
- For API: Update
launchSettings.json - For frontend: Update
vite.config.ts
Problem: Frontend cannot connect to API Solutions:
- Verify API is running on port 5295
- Check CORS configuration in
Program.cs - Ensure frontend is running on port 5173
- Check browser console for specific error messages
Problem: dotnet build fails
Solutions:
- Clear NuGet cache:
dotnet nuget locals all --clear - Restore packages:
dotnet restore - Clean and rebuild:
dotnet clean && dotnet build
Problem: npm install fails
Solutions:
- Clear npm cache:
npm cache clean --force - Delete
node_modulesandpackage-lock.json - Reinstall:
npm install
ai-budget-tracker-workshop/
βββ src/
β βββ BudgetTracker.Api/ # ASP.NET Core Web API
β β βββ Auth/ # Authentication endpoints and models
β β βββ AntiForgery/ # Anti-forgery token endpoints
β β βββ Infrastructure/ # Entity Framework DbContext & migrations
β β βββ BudgetTracker.Api.csproj # Project file
β β βββ Program.cs # Application entry point
β βββ BudgetTracker.Web/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ services/ # API service layer
β β βββ types/ # TypeScript type definitions
β β βββ routes/ # React Router components
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ vite.config.ts # Vite configuration
βββ tests/
β βββ BudgetTracker.Api.Tests/ # Unit and integration tests
β βββ Auth/ # Authentication endpoint tests
β βββ AntiForgery/ # Anti-forgery endpoint tests
β βββ Extensions/ # Test helper extensions
β βββ Fixtures/ # Test fixtures and setup
β βββ BudgetTracker.Api.Tests.csproj
βββ docker/ # Docker configuration
β βββ docker-compose.yml # PostgreSQL database setup
βββ .gitignore # Git ignore rules
βββ BudgetTracker.sln # .NET Solution file
βββ README.md # This file
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Run tests:
dotnet testandnpm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow C# coding conventions for backend code
- Use TypeScript strict mode for frontend code
- Write tests for new functionality
- Update documentation for API changes
- Use conventional commit messages
If you encounter issues:
- Review the API documentation when running locally
- Check the test files for usage examples
- Open an issue on GitHub with detailed error information
The API supports two authentication methods:
- Header:
X-API-Key - Development Key:
bt_dev_key_admin - Usage: Add the API key header to your requests or use the "Authorize" button in Swagger UI
- Register/login through the
/api/users/registerand/api/users/loginendpoints - Session-based authentication for web applications
POST /api/users/register- User registrationPOST /api/users/login- User loginPOST /api/users/logout- User logoutGET /api/users/me- Get current user infoGET /api/antiforgery/token- Get anti-forgery token