Skip to content

Project Structure

Zuno is flexibleβ€”you can start with a single main.cpp file or scale up to a fully modular architecture. This guide shows you how to structure your project for clarity and maintainability.


Here’s the simplest possible Zuno project:

my-zuno-app/
β”œβ”€β”€ CMakeLists.txt
└── main.cpp

This is great for quick experiments or learning the basics.


For real-world projects, we recommend a modular layout:

my-zuno-app/
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ main.cpp
β”‚ β”œβ”€β”€ routes/
β”‚ β”‚ β”œβ”€β”€ index.cpp
β”‚ β”‚ └── users.cpp
β”‚ β”œβ”€β”€ middleware/
β”‚ β”‚ └── auth.cpp
β”‚ └── utils/
β”‚ └── logger.cpp
β”œβ”€β”€ cmake/
β”‚ └── dependencies.cmake
β”œβ”€β”€ include/
β”‚ └── my_zuno_app/
β”‚ β”œβ”€β”€ routes.hpp
β”‚ β”œβ”€β”€ middleware.hpp
β”‚ └── utils.hpp
└── certs/
β”œβ”€β”€ cert.pem
└── key.pem

Contains all your application logic.

  • main.cpp: Entry point of your app.
  • routes/: Define route handlers here.
  • middleware/: Custom middleware functions.
  • utils/: Helper functions, logging, etc.

Public headers for your app. Useful for separating declarations and enabling reuse.

Contains CMake configuration files used for building the project. These files define how the project is compiled, linked, and managed across different platforms.

Store TLS certificates and keys here if you’re using HTTPS.


Here’s how you might define a route in routes/index.cpp:

#include <zuno/zuno.hpp>
void registerIndexRoutes(zuno::App& app) {
app.get("/", [](auto& req, auto& res) {
res.send("Welcome to Zuno!");
});
}

And in main.cpp:

#include <zuno/zuno.hpp>
#include "routes.hpp"
int main(){
zuno::App app;
registerIndexRoutes(app);
app.listen(3000);
}

Now that your project is structured, let’s dive into:


Keep your code clean, modular, and expressive. Zuno makes it easy.