A RESTful backend service for task management with PostgreSQL persistence, in-memory caching, and automated tests. Implemented in both Python (FastAPI) and Java (Spring Boot).
- CRUD operations for task management
- Status management (OPEN/DONE)
- Pagination with configurable limit (max 200) and offset
- Status filtering and ordering by creation date
- Input validation with error handling
- In-memory caching (10-second TTL with automatic invalidation)
- PostgreSQL persistence with migration scripts
- Comprehensive test coverage
Python: FastAPI, SQLAlchemy, Pydantic, pytest, Uvicorn Java: Spring Boot 3.2.1, Spring Data JPA, Caffeine Cache, JUnit 5, Maven Infrastructure: PostgreSQL 16, Docker Compose
- Docker Desktop installed and running
Start all services:
docker compose up -d --buildThis starts:
- PostgreSQL on port 5432
- Python API on port 8000
- Java API on port 8080
Verify health:
curl http://localhost:8000/health # Python API
curl http://localhost:8080/health # Java APIStop services:
docker compose down| Method | Endpoint | Description |
|---|---|---|
| POST | /tasks |
Create task (requires "title", optional "status": "OPEN") |
| GET | /tasks |
List tasks (query params: status, limit, offset) |
| GET | /tasks/{id} |
Get task by ID |
| PATCH | /tasks/{id}/complete |
Mark task as DONE |
| DELETE | /tasks/{id} |
Delete task |
Note: Status values must be OPEN or DONE (case-sensitive).
Example request:
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{"title": "Buy groceries", "status": "OPEN"}'| Field | Type | Description |
|---|---|---|
| id | UUID | Primary key |
| title | VARCHAR(500) | Task title (required) |
| status | VARCHAR(20) | OPEN or DONE |
| created_at | TIMESTAMP | Auto-set on creation |
| updated_at | TIMESTAMP | Auto-updated on modification |
| completed_at | TIMESTAMP | Set when marked DONE |
Migration file: migrations/001_create_tasks_table.sql
- 10-second TTL for list operations
- Cache key includes status, limit, and offset parameters
- Automatic invalidation on create, update, and delete operations
- Python: Custom in-memory implementation
- Java: Caffeine Cache with Spring annotations
task-api-project/
├── docker-compose.yml
├── migrations/
├── python-api/
│ ├── app/
│ ├── tests/
│ └── Dockerfile
└── java-api/
├── src/
├── pom.xml
└── Dockerfile