https://github.com/mgomez-dev-code/minimaltodos
A clean and modern .NET 9 Minimal API showcasing CRUD endpoints, validation, pagination, and unit testing with xUnit + Moq, including automated CI with GitHub Actions.
https://github.com/mgomez-dev-code/minimaltodos
ci-cd clean-architecture csharp dependency-injection dotnet github-actions minimal-api moq rest-api swagger todo-app xunit
Last synced: 7 months ago
JSON representation
A clean and modern .NET 9 Minimal API showcasing CRUD endpoints, validation, pagination, and unit testing with xUnit + Moq, including automated CI with GitHub Actions.
- Host: GitHub
- URL: https://github.com/mgomez-dev-code/minimaltodos
- Owner: mgomez-dev-code
- License: mit
- Created: 2025-10-31T00:51:35.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-10-31T01:32:27.000Z (8 months ago)
- Last Synced: 2025-10-31T03:15:16.229Z (8 months ago)
- Topics: ci-cd, clean-architecture, csharp, dependency-injection, dotnet, github-actions, minimal-api, moq, rest-api, swagger, todo-app, xunit
- Language: C#
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MinimalTodos (.NET 9 + Minimal API)





A small **Minimal API** built with **.NET 9** to manage a *Todo* list.
Demonstrates a clean architecture using Dependency Injection, validation, pagination, and unit testing with xUnit & Moq.
Designed to show how Minimal APIs simplify setup compared to traditional MVC Controllers, while keeping strong typing and testability.
## Features
- โก CRUD endpoints (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`)
- ๐ง In-memory repository with **Dependency Injection**
- ๐ **Search filter** (`?search=`) and **pagination** (`pageIndex`, `pageSize`)
- ๐งพ Validation: **Title required, 1โ100 chars**
- ๐งช Unit tests with **xUnit** and **Moq**
- ๐ฌ Proper HTTP responses (200, 201, 400, 404)
- ๐ Swagger UI ready out of the box
## Project Structure
```text
MinimalTodos/
โโ MinimalTodos.sln
โโ MinimalTodos.API/
โ โโ Domain/ # Models & DTOs
โ โโ Endpoints/ # Minimal API routes
โ โโ Extensions/ # App extensions (endpoint registration, DI helpers, etc.)
โ โโ Repositories/ # ITodoRepository + InMemory repo
โ โโ Validation/ # Custom validation
โ โโ Program.cs
โโ MinimalTodos.Tests/
โโ TodoRepositoryTests.cs
โโ TodoNotifierTests.cs
```
## Getting Started
**1) Build & Test**
```bash
dotnet build
dotnet test
```
**2) Run the API**
```bash
dotnet run --project MinimalTodos.API
# Open https://localhost:7026/swagger
```
๐กBy default, the API runs on https://localhost:7026 (HTTPS) and http://localhost:5000 (HTTP).
Swagger UI will open automatically at /swagger, allowing you to explore and test all endpoints interactively.
## Example Endpoints
| Method | Endpoint | Description |
|-------:|----------|-------------|
| `GET` | `/todos` | List todos (with search & pagination) |
| `GET` | `/todos/{id}` | Get a single todo |
| `POST` | `/todos` | Create new todo |
| `PUT` | `/todos/{id}` | Update todo |
| `PATCH`| `/todos/{id}/toggle` | Toggle IsDone |
| `DELETE`| `/todos/{id}` | Delete todo |
## License
This project is licensed under the **MIT License**. See `LICENSE` for details.