service -> CMake + cmd + internalGenerate C++ Microservices: Project Structure
C++ generation emits standalone CMake projects for CppUserver or CppCoro, with native runtime wiring, typed headers, tests and reusable build images.
When to use
Use this reference when generating, reviewing or operating a Service Architect project.
Behavior
- The service language selects CppUserver or CppCoro; these are distinct runtime implementations, not different graph semantics.
- CppCoro uses C++20 awaitable operators and business handlers. Await downstream calls with co_await so completion, cancellation and value lifetimes follow the graph contract.
- CppCoro runs HTTP, gRPC Callback API and timers on the Coro worker pool without periodic completion-queue polling or stackful CooperativeExecution. Select cppIoBackend=epoll (default) or uring during generation; CPP_CORO_IO_BACKEND selects the corresponding build dependencies. The choice is independent of cppGraph=typed or dynamic and preserves the business API. io_uring requires Linux and a container security profile that permits io_uring_setup/enter/register; generated Docker settings use seccomp:unconfined, so production should supply a restricted compatible profile. There is no silent backend fallback. The upstream gRPC timer thread and optional Kafka/configuration infrastructure are accounted for separately.
- CMakeLists.txt defines the standalone service and generated code targets.
- cmd/service/main.cpp is the executable entrypoint.
- internal/app contains generated service wiring plus preserved service.cpp/service.hpp extensions.
- internal/functions contains business headers, implementations and unit tests.
- config contains generated C++ configuration types and runtime values. static_config.yaml is specific to userver; Coro uses config/config.yaml and config/overrides.yaml.
- Referenced user-named Modules become independent CMake projects with generated include/schema trees determined by their graph references.
Run a complete C++ microservice example
CMake and Conan projects with userver; cppcoroexample demonstrates the C++20 coroutine runtime with epoll or io_uring selected at generation/build time.
The runnable C++ example contains business implementations as well as generated infrastructure. A new Designer archive provides extension points for your own business code.
Install Git, GNU Make, Docker with Compose v2, and the host toolchain required by the repository README. Run these commands from the example workspace root; make help lists the targets available in that version.
git clone https://github.com/gorundebug/cppexample.git
cd cppexample
make help
make init
make docker-up- Use the service README and generated configuration for endpoint addresses and example requests.
- When finished, make docker-down stops the stack while preserving its volumes.
- Continue with the visual design guide or safe regeneration.
C++ service directories
Important paths in each generated C++ service.
CMakeLists.txtManagedBuild graph for service, contracts, generators, lint and tests.
cmd/service/main.cppPreserved entrypointStarts the generated C++ service.
internal/app/service.generated.*GeneratedRuntime graph and connector wiring.
internal/app/service.cpp + service.hppPreservedCustom service lifecycle extensions.
internal/functions/PreservedBusiness operators, endpoint handlers and tests.
internal/types/ + internal/serdes/MixedGenerated/local contracts and serde registration.
config/config.generated.*GeneratedTyped configuration structures.
static_config.yamlManaged; userver onlyuserver component and runtime configuration.
config/config.yaml + config/overrides.yamlBoost and CoroGenerated runtime defaults and preserved environment overrides.
docker-compose.cmake.generated.ymlGeneratedReusable CMake build and runtime workflow.
C++ service tree
<service-name>/
CMakeLists.txt
cmd/service/main.cpp
internal/app/service.generated.cpp
internal/functions/*.{hpp,cpp}
config/ + static_config.yaml
graph/ + docs/ + grafana/ + helm/