This project is a C++ full-stack boilerplate designed for creating REST APIs and embeds a static web apps. It leverages modern C++ for backend API development and supports serving static frontend applications. It includes essential features to get started quickly with both API and web development, while following a containerized development workflow with Docker.
- Project Structure
- Key Features
- Prerequisites
- Installation and Usage
- Environment Variables
- Docker Configuration
- Contributing
- License
.
├── CMakeLists.txt # CMake configuration for C++ build
├── app-dev.env # Development environment variables
├── docker-compose.yml # Docker Compose configuration
├── include/ # C++ header files
├── src/ # C++ source files
└── www/ # Frontend application (React/Vite/TypeScript)
├── dist/ # Build output directory for frontend
├── public/ # Public assets
├── src/ # Frontend source code
└── package.json # Frontend dependencies and scripts
- REST API with Modern C++: Implements HTTP REST endpoints using
Boost.Beast. - Static Frontend Support: Hosts and serves static frontend applications built with React and Vite.
- Database Abstraction: Support for SQLite and PostgreSQL with interchangeable database interfaces.
- Containerized Development: Docker and Docker Compose for easy setup and deployment.
- Authentication Helpers: Provides helper utilities for authentication (e.g., session management).
- Static Code Analysis: Integrated ESLint for code linting and Tailwind for styling the frontend.
Make sure you have the following installed:
- Docker and Docker Compose: For containerized environments.
- C++ Compiler: A modern C++ compiler like GCC or Clang.
- Yarn: For frontend package management.
- CMake: To build the C++ project.
To start the full application (frontend + backend) using Docker, simply run:
make allThis command will:
- Install and build the frontend using Yarn.
- Spin up the backend and frontend containers via Docker Compose.
To stop the running containers:
make downTo remove the build artifacts for the frontend:
make cleancurl http://localhost:8080/helloYou can configure the environment by modifying the following files:
app-dev.env: Environment variables for the development environment.docker-compose.yml: Docker configuration that references environment variables for services.
Key Variables:
DATABASE_URL: Connection URL for PostgreSQL or SQLite.PORT: The port on which the backend API runs (default:8080).
Dockerfile: Used for production deployment.Dockerfile.dev: Used for development with live-reload features.docker-compose.yml: Defines services and networking for the containers.
