A RESTful API for personal finance management with JWT authentication, transaction tracking, and category organization.
FinancialAPI allows users to register, authenticate, and manage their personal finances by creating income and expense transactions organized into custom categories. Each user's data is fully isolated.
- π JWT Authentication β secure registration and login
- ποΈ Categories β create and manage custom transaction categories
- πΈ Transactions β record income and expenses in cents
- π Summaries β overall and monthly financial summaries
- π Filters β query transactions by date range or category
- π Swagger/OpenAPI β interactive API documentation
- .NET 8.0 β Web framework
- ASP.NET Core Web API β RESTful API construction
- Entity Framework Core 8.0 β ORM for data access
- Pomelo MySQL 8.0 β MySQL EF Core provider
- AutoMapper 12.0 β Object-to-object mapping
- FluentValidation 11 β Input validation
- JWT Bearer β Stateless authentication
- Swagger/OpenAPI β API documentation
FinancialAPI/
βββ Controllers/
β βββ AuthController.cs # Register & login
β βββ CategoryController.cs # Category CRUD
β βββ TransactionController.cs # Transaction CRUD & summaries
βββ Services/
β βββ CategoryService.cs
β βββ TransactionService.cs
β βββ JwtService.cs
β βββ PasswordService.cs
β βββ CurrentUserService.cs
βββ Entities/
β βββ User.cs
β βββ Category.cs
β βββ Transaction.cs # TransactionType enum (Income/Expense)
βββ DTOs/
β βββ Requests/ # Auth, Category, Transaction DTOs
β βββ Responses/
βββ Interfaces/
β βββ ICategoryService.cs
β βββ ITransactionService.cs
β βββ ICurrentUserService.cs
βββ Context/
β βββ AppDbContext.cs
βββ Mappings/
β βββ CategoryMapping.cs
β βββ TransactionMapping.cs
βββ Migrations/
- .NET SDK 8 or higher
- MySQL 8.0 or Docker
- Git
- IDE: JetBrains Rider, Visual Studio 2022, or VS Code
git clone https://github.com/renanzitoo/FinancialAPI.git
cd FinancialAPIEdit FinancialAPI/appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Port=3306;Database=financialapi;User=root;Password=your-password;"
},
"Jwt": {
"Secret": "your-secret-key-at-least-32-characters-long"
}
}docker run --name mysql-financialapi -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=financialapi -p 3306:3306 -d mysql:8.0dotnet ef database update --project FinancialAPIdotnet restore
dotnet run --project FinancialAPIAPI available at: https://localhost:7000 or http://localhost:5000
All endpoints except Auth require a Bearer token in the Authorization header.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Create a new account |
| POST | /api/auth/login |
Authenticate and receive a JWT |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/categories |
Create a category |
| GET | /api/categories |
List all user categories |
| GET | /api/categories/{id} |
Get a category by ID |
| PUT | /api/categories/{id} |
Update a category |
| DELETE | /api/categories/{id} |
Delete a category |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/transactions |
Create a transaction |
| GET | /api/transactions |
List all user transactions |
| GET | /api/transactions/{id} |
Get a transaction by ID |
| PUT | /api/transactions/{id} |
Update a transaction |
| DELETE | /api/transactions/{id} |
Delete a transaction |
| GET | /api/transactions/by-date |
Filter by date range (?startDate=&endDate=) |
| GET | /api/transactions/by-category/{categoryId} |
Filter by category |
| GET | /api/transactions/summary |
Overall financial summary |
| GET | /api/transactions/summary/{year}/{month} |
Monthly financial summary |
POST /api/auth/register
{
"name": "John Doe",
"email": "john@example.com",
"password": "P@ssw0rd!"
}POST /api/transactions
Authorization: Bearer <token>
{
"title": "Salary",
"categoryId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"amountInCents": 500000,
"type": 1,
"description": "Monthly salary",
"date": "2026-03-16T00:00:00Z"
}
type:1= Income,2= Expense.amountInCents: amount in the smallest currency unit (e.g. 500000 = $5,000.00).
| Column | Type |
|---|---|
| Id | GUID |
| Name | VARCHAR |
| VARCHAR(100) | |
| PasswordHash | VARCHAR |
| CreatedAt | DATETIME |
| Column | Type |
|---|---|
| Id | GUID |
| Name | VARCHAR |
| UserId | GUID (FK) |
| Column | Type |
|---|---|
| Id | GUID |
| UserId | GUID (FK) |
| CategoryId | GUID (FK) |
| Title | VARCHAR |
| AmountInCents | BIGINT |
| Description | VARCHAR |
| Date | DATETIME |
| Type | INT (1=Income, 2=Expense) |
- Service Layer β Business logic isolated in service classes
- DTO Pattern β Separation of entities and API models
- Interface Segregation β Services registered via interfaces
- Dependency Injection β Native ASP.NET Core DI
- AutoMapper Profiles β Clean entity β DTO conversion
- β
External API consumption with
HttpClient - β Resilience and error handling
- β Local caching for optimization
- β Async/Await patterns
- β Entity Framework Core with MySQL
- β AutoMapper for DTOs
- β Data validation
- β Call auditing
- β RESTful patterns
- β Dependency injection
- Add
ILoggerfor structured observability - Implement Circuit Breaker with Polly
- Create unit tests (xUnit)
- Integration tests
- Health checks
- Metrics (Prometheus)
- Containerize the application
- CI/CD with GitHub Actions
- Rate limiting
Renan Costa
GitHub: renanzitoo
β If this project was useful to you, consider giving it a star!