Project Structure
When you create an app with xp create my-app, this is what you get:
my-app/
├── main.cpp ← Your application code — start here
├── CMakeLists.txt ← Build configuration
├── .gitignore
├── uploads/ ← Default upload directory
└── vendor/
└── xpresspp/
└── include/ ← Xpress++ headers (copied from the repo)
└── xpresspp/
├── xpresspp.h ← Main include file
├── app.h ← App class
├── request.h ← Request class
├── response.h ← Response class
├── router.h ← Router class
├── errors.h ← Error types
├── logger.h ← Logging middleware
├── config.h ← Config helpers
├── utils.h ← Utility functions
└── middleware/
├── cors.h
├── rate_limit.h
├── body_limit.h
├── request_id.h
├── security.h
└── validation.hThe one include
You only ever need one #include in your files:
cpp
#include <xpresspp/xpresspp.h>This pulls in everything: App, Request, Response, Router, all error classes, all middleware, and all helpers.
Growing your app
As your project grows, split your routes into separate files:
my-app/
├── main.cpp
├── routes/
│ ├── users.h ← User routes
│ ├── posts.h ← Post routes
│ └── admin.h ← Admin routes
├── CMakeLists.txt
└── vendor/routes/users.h:
cpp
#pragma once
#include <xpresspp/xpresspp.h>
inline void registerUserRoutes(xp::App& app) {
app.get("/api/users", [](xp::Request& req, xp::Response& res) {
res.json({{"users", {}}});
});
app.post("/api/users", [](xp::Request& req, xp::Response& res) {
res.status(201).json({{"message", "Created"}});
});
}main.cpp:
cpp
#include <xpresspp/xpresspp.h>
#include "routes/users.h"
#include "routes/posts.h"
int main() {
xp::App app;
app.use(xp::logger());
app.use(xp::cors());
registerUserRoutes(app);
registerPostRoutes(app);
app.listen(8080);
}Build artifacts
The xp build command creates a ./build directory:
my-app/
├── build/ ← Generated by xp build (add to .gitignore)
│ ├── my-app ← The compiled executable
│ ├── CMakeCache.txt
│ └── ...Run xp clean to delete the build directory and start fresh.