A modern C++ backend service built with Crow framework, providing authentication and profile management functionality.
- RESTful API endpoints for user authentication and profile management
- JWT-based authentication
- PostgreSQL database integration
- Secure password hashing
- CORS support
- Modern C++17 codebase
- C++17 compatible compiler
- CMake 3.15 or higher
- OpenSSL
- PostgreSQL
- libpqxx
- jwt-cpp
- Crow (header-only, included in the project)
brew install openssl postgresql libpqxx cmakegit clone https://github.com/Thalhammer/jwt-cpp.git
cd jwt-cpp
mkdir build && cd build
cmake ..
make
sudo make installbackend/
├── include/ # Header files
│ └── crow/ # Crow framework headers
├── src/
│ ├── controllers/ # Request handlers
│ ├── db/ # Database connection management
│ ├── routes/ # API route definitions
│ ├── services/ # Business logic
│ ├── utils/ # Utility functions
│ └── main.cpp # Application entry point
└── CMakeLists.txt # Build configuration
POST /api/auth/register- Register a new userPOST /api/auth/login- User loginPOST /api/auth/verify-email- Verify user emailPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password
GET /api/profile- Get user profilePUT /api/profile- Update user profilePOST /api/profile/picture- Upload profile picture
- Create a build directory:
cd backend
mkdir build
cd build- Configure and build:
cmake ..
make- Run the server:
./web_matcha- Create a PostgreSQL database:
CREATE DATABASE web_matcha;- Create the users table:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
username VARCHAR(255) UNIQUE NOT NULL,
first_name VARCHAR(255) NOT NULL,
last_name VARCHAR(255) NOT NULL,
profile_picture VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);The application uses the following default database connection settings:
- Host: localhost
- Port: 5432
- Database: web_matcha
- User: postgres
- Password: postgres
To modify these settings, update the connection string in src/main.cpp.
- Password hashing using OpenSSL
- JWT-based authentication
- CORS protection
- Input validation
- SQL injection prevention using parameterized queries
The API uses standard HTTP status codes:
- 200: Success
- 201: Created
- 400: Bad Request
- 401: Unauthorized
- 500: Internal Server Error
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request