Reusable C++ microservice starter template with:
- HTTP API using Drogon
- PostgreSQL connection
- ORM-style repository/service/controller layers
- Ready migration SQL
- Fully Dockerized local runtime
- C++20
- Drogon
- PostgreSQL
- CMake
- Docker Compose
src/controllers: HTTP endpointssrc/services: business logicsrc/repositories: persistence layer using Drogon ORM clientsrc/domain: DTO/domain objectsconfig/config.json: runtime config for local host runconfig/config.docker.json: runtime config for Docker (dbhostname)migrations: SQL schema migrationsDockerfile: app build/runtime imagedocker-compose.yml: app + db orchestration
GET /healthPOST /api/v1/usersGET /api/v1/users/{id}GET /api/v1/usersDELETE /api/v1/users/{id}
Start everything (DB + migration + app):
docker compose up --buildRun in background:
docker compose up --build -dStop:
docker compose downApp URL: http://localhost:8080
Note: Migration SQL is mounted into /docker-entrypoint-initdb.d and is applied automatically when the Postgres data volume is initialized.
If you need to re-apply init scripts from scratch:
docker compose down -v
docker compose up --buildIf you want to run app directly on host:
cmake -S . -B build
cmake --build build -j
cp config/config.json build/config.json
./build/cpp_microservice_templateCreate user:
curl -X POST http://localhost:8080/api/v1/users \
-H "content-type: application/json" \
-d '{"name":"Ada Lovelace","email":"[email protected]"}'Get all users:
curl http://localhost:8080/api/v1/users