A production-ready headless TODO API built with ASP.NET Core 8, PostgreSQL, and JWT authentication. Features Docker support, Swagger documentation, and Clean Architecture patterns.
- π Complete CRUD Operations for TODO management
- ποΈ PostgreSQL Database with Entity Framework Core
- π³ Docker Containerization with PostgreSQL & Redis
- π Swagger/OpenAPI Documentation
- ποΈ Clean Architecture implementation
- π JWT Authentication (ready for implementation)
- π§ͺ Comprehensive Testing framework
- β‘ High Performance with async operations
- π§ Development-friendly with hot reload
| Technology | Version | Purpose |
|---|---|---|
| ASP.NET Core | 8.0 | Web API framework |
| PostgreSQL | 15 | Primary database |
| Entity Framework Core | 8.0 | ORM and migrations |
| Docker | Latest | Containerization |
| Redis | 7-alpine | Caching (future) |
| Swagger/OpenAPI | Latest | API documentation |
| xUnit | Latest | Unit testing |
git clone https://github.com/RushitSolanki/headless-todo-api.git
cd headless-todo-apiYou can run each step individually:
Start PostgreSQL and Redis containers:
docker-compose up -d postgres redisRun database migrations:
cd TodoApp.API
dotnet ef database updateStart the API:
dotnet run- API Base URL: http://localhost:5235
- Swagger UI: http://localhost:5235/swagger
- Health Check: http://localhost:5235/health
http://localhost:5235/api/v1
| Method | Endpoint | Description |
|---|---|---|
GET |
/todos |
Get all TODOs |
GET |
/todos/{id} |
Get TODO by ID |
POST |
/todos |
Create new TODO |
PUT |
/todos/{id} |
Update TODO |
DELETE |
/todos/{id} |
Delete TODO |
Using Swagger UI (Recommended)
- Open your browser and go to: http://localhost:5235/swagger
- Find the POST
/api/v1/todosendpoint - Click "Try it out"
- Enter the JSON data in the request body:
{
"title": "Complete API Documentation",
"description": "Write comprehensive API docs",
"priority": 1,
"userId": "12345678-1234-1234-1234-123456789012"
}- Click "Execute"
- Open your browser and go to: http://localhost:5235/swagger
- Find the GET
/api/v1/todosendpoint - Click "Try it out"
- Click "Execute"
- Open your browser and go to: http://localhost:5235/swagger
- Find the GET
/api/v1/todos/{id}endpoint - Click "Try it out"
- Enter the TODO ID in the
idparameter - Click "Execute"
- Open your browser and go to: http://localhost:5235/swagger
- Find the PUT
/api/v1/todos/{id}endpoint - Click "Try it out"
- Enter the TODO ID in the
idparameter - Enter the updated data in the request body:
{
"title": "Updated API Documentation",
"description": "Updated comprehensive API docs",
"priority": 2,
"status": 1,
"dueDate": "2025-12-31T23:59:59Z"
}- Click "Execute"
- Open your browser and go to: http://localhost:5235/swagger
- Find the DELETE
/api/v1/todos/{id}endpoint - Click "Try it out"
- Enter the TODO ID in the
idparameter - Click "Execute"
0= Low1= Medium2= High
0= Pending1= InProgress2= Completed
TodoApp/
βββ π TodoApp.API/ # Web API project
β βββ π Controllers/ # API controllers
β βββ π Properties/ # Launch settings
β βββ π Program.cs # Application entry point
β βββ π appsettings.json # Configuration
βββ π TodoApp.Core/ # Domain layer
β βββ π Models/ # Domain entities
β βββ π Interfaces/ # Repository interfaces
βββ π TodoApp.Infrastructure/ # Data access layer
β βββ π Migrations/ # EF Core migrations
β βββ π TodoAppDbContext.cs # Database context
βββ π TodoApp.Tests/ # Test projects
βββ π docker-compose.yml # Docker services
βββ π Dockerfile # Application container
βββ π README.md # This file
# Database
ConnectionStrings__DefaultConnection=Host=localhost;Port=5433;Database=todoapp;Username=postgres;Password=password
# Redis (for future caching)
ConnectionStrings__Redis=localhost:6379The application uses Docker Compose for easy development setup:
- PostgreSQL: Port 5433
- Redis: Port 6379
- API: Port 5235
# Run all tests
dotnet test
# Run specific test project
dotnet test TodoApp.Tests/
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"- Unit tests for business logic
- Integration tests for API endpoints
- Database tests with in-memory provider
# Build and run with Docker Compose
docker-compose up --build
# Production build
docker build -t todo-api .
docker run -p 5000:80 todo-api- Build the application:
dotnet publish -c Release - Deploy to your preferred hosting platform
- Configure environment variables
- Run database migrations
We welcome contributions! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - 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
- Use meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Basic CRUD operations
- PostgreSQL integration
- Docker containerization
- Swagger documentation
- Clean Architecture setup
- JWT Authentication
- Input validation
- Unit and integration tests
- Advanced filtering and search
- Redis caching
- Rate limiting
- Email notifications
- File attachments
- API versioning
- Performance monitoring
# Check if PostgreSQL is running
docker ps | grep postgres
# Restart containers
docker-compose down
docker-compose up -d postgres redis# Check what's using the port
lsof -i :5235
# Kill the process or change the port in launchSettings.json# Remove existing migrations and recreate
dotnet ef migrations remove --project TodoApp.Infrastructure --startup-project TodoApp.API
dotnet ef migrations add InitialCreate --project TodoApp.Infrastructure --startup-project TodoApp.APIThis project is licensed under the MIT License - see the LICENSE file for details.
- ASP.NET Core for the amazing framework
- Entity Framework Core for data access
- PostgreSQL for the reliable database
- Docker for containerization
- Swagger for API documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
β Star this repository if you found it helpful!