A RESTful Web API built with C# and ASP.NET Core for managing expenses.
This project was developed primarily to understand how to manage database and entities using dependency injection extensions and also generating EXCEL and PDF reports, while also exploring concepts such as business rules, input validation, exception handling, and global exception filter.
- CRUD expenses
- Download Excel report by month
- Download PDF report by month
- Business rule validation
- Status and Priority validation
- Exception filter
- Swagger documentation (HTTP status code handling)
For this project, the following layered architecture was adopted:
- CashFlow.API — The entry point of the application, responsible for handling HTTP requests through the controllers.
- CashFlow.Application — The application/service layer, responsible for implementing the application's use cases and business rules.
- CashFlow.Communication — The DTO layer, responsible for defining and organizing the request and response objects used to communicate between the API and the application layer.
- CashFlow.Exception — The Exception layer, responsible for defining and organizing the aplication errors and saving the resourse message errors.
- CashFlow.Infrastructure — The Infrastructure layer, responsible for defining and organizing the database communication.
- CashFlow.Domain — The Domain layer, responsible for defining the entities and interfaces used in the Infrastructure layer.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/expenses |
Get all expenses |
| GET | /api/expenses/{id} |
Get a expense by ID |
| GET | /api/reports/excel?month=2026-09 |
Get expenses by the year-month and download the Excel report |
| GET | /api/reports/pdf?month=2026-09 |
Get expenses by the year-month and download the PDF report |
| POST | /api/expenses |
Create a expense |
| PUT | /api/expenses/{id} |
Update a expense |
| DELETE | /api/expenses/{id} |
Delete a expense |
Through this project, I practiced:
- Layered architecture in .NET
- ASP.NET Core Web API
- RESTful API design
- HTTP methods and status codes
- Business rule implementation
- Exception handling
- Debugging with Visual Studio
- API documentation with Swagger
- Implement dependency injection
- How to use the MigraDoc to create and style a PDF report
- How to use the ClosedXML to create and style an Excel report
- Create the Migrations
- Implement unit tests
- Add authentication
- Add authorization for specific endpoints
- Visual Studio version 2022+ or Visual Studio Code
- Windows 10+ or Linux/MacOS with .NET SDK 8.0 or 9.0 installed
- PostgreSQL
- Clone the repository:
git clone https://github.com/AnaLinsDev/cash-flow-api.gitcd cash-flow-apiFill in the database information in the appsettings.Development.json file inside the CashFlow.API.
dotnet restoredotnet build// Here will be added the steps to run the migrations, but it will be added in the next steps
dotnet run --project src/CashFlow.APIThe terminal will display the URL where the API is running.
Open the Swagger URL displayed by the application in your browser.
Swagger can be used to test the available API endpoints without requiring Postman or another API client.
