Project Structure
ποΈ Project Structure
Section titled βποΈ 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.
π§ͺ Minimal Example
Section titled βπ§ͺ Minimal ExampleβHereβs the simplest possible Zuno project:
my-zuno-app/βββ CMakeLists.txtβββ main.cpp
This is great for quick experiments or learning the basics.
π§± Recommended Structure
Section titled βπ§± Recommended Structureβ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
π Folder Breakdown
Section titled βπ Folder Breakdownβ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.
include/
Section titled βinclude/β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.
π§© Example: Modular Route
Section titled βπ§© Example: Modular Routeβ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);}
π§ Next Steps
Section titled βπ§ Next StepsβNow that your project is structured, letβs dive into:
Keep your code clean, modular, and expressive. Zuno makes it easy.