A simple Todo API implemented with Clean Architecture principles and Test-Driven Development (TDD) in Laravel 12.
This app demonstrates:
- Separation of concerns with Entities, Use Cases, Interfaces, and Infrastructure
- Fully testable code with Unit and Feature tests
- Flexibility to swap database or repository without affecting core business logic
- Entities: Core business logic (
Todoentity) - Use Cases: Application actions (
CreateTodo,UpdateTodo,DeleteTodo) - Interfaces: Contracts and controllers (
TodoRepositoryInterface,TodoController) - Infrastructure: Eloquent repository (
EloquentTodoRepository)
- Create, Read, Update, Delete Todos
- Status:
pendingordone - Fully layered architecture
- Unit and Feature tests included
# Clone the repo
git clone https://github.com/tharakadoo/clean-arch-tdd-1
cd clean-arch-tdd
# Install dependencies
composer install
# Set up environment
cp .env.example .env
php artisan key:generate
# Install API routes
php artisan install:api
# Run migrations
php artisan migrate
# Start server
php artisan serve- Create a Todo: POST /api/todos
{
"title": "Learn TDD in Laravel"
}- Get all Todos: GET /api/todos
- Update a Todo: PUT /api/todos/{id}
{
"title": "Updated title",
"status": "done"
}- Delete a Todo: DELETE /api/todos/{id}
Postman Collection Attached to repo. (Todo-clean-arch.postman_collection.json)
Run all tests (Unit + Feature):
php artisan test