Skip to content

Project Structure

While you are free to organize your project however you like, here is a recommended structure that works well with the framework:

my-service/
├── CMakeLists.txt
├── config.json
├── main.cpp              # Entry point, app creation, route registration
├── src/
│   ├── controllers/      # HTTP request handlers
│   ├── models/           # Database model definitions
│   ├── jobs/             # Job class definitions
│   ├── handlers/         # WebSocket / TCP handlers
│   └── middleware/       # Custom middleware
├── include/
│   └── my_service/       # Public headers for your service
├── migrations/           # SQL migration files (if using the ORM)
├── tests/                # Unit and integration tests
├── docker/               # Docker-related files
└── scripts/              # Deployment and maintenance scripts

The Entry Point

Your main.cpp is where everything comes together:

cpp
#include <framework.hpp>

using namespace framework;

int main() {
    framework::app app;

    // Register routes
    app.register_endpoint(
        http_verb_t::get,
        "/api/users",
        UserController::index);

    // Start
    app.run_http_service(8080);
    app.run();
    return 0;
}

Header-Only or Compiled

The framework works in both modes:

  • Header-only: Include <framework.hpp> and you have access to everything
  • Compiled library: Link against libframework.a for faster compilation

The recommended approach for production is to use the compiled library.