A C++17 service for managing electronic contracts: creation, versioning, digital signatures, lifecycle tracking, and compliance metadata.
- Overview
- Features
- Project structure
- Build requirements
- Build & run
- Configuration
- Database
- Security
- License
This repository contains a C++17 application that exposes contract functionality (create, update, sign, audit, and search). It links against OpenSSL for cryptographic operations and libpqxx/libpq for PostgreSQL access.
- Contract CRUD and lifecycle (draft -> finalized -> archived)
- Versioning and audit trail
- Signer workflow & signature verification (OpenSSL)
- PostgreSQL persistence (libpqxx)
- Clean build targets via Makefile
├─ Makefile
├─ src/
│ ├─ api/ # HTTP/API layer (handlers)
│ ├─ services/ # Business logic
│ ├─ database/ # Database access (libpqxx)
│ ├─ crypto/ # Crypto helpers (OpenSSL)
│ ├─ blockchain/ # Block/ledger utilities
│ ├─ config/ # Configuration helpers
│ └─ main.cpp # Entry point
- g++ with C++17 support
- OpenSSL (libssl, libcrypto)
- PostgreSQL client libraries (libpq, libpqxx)
- pthread
- make
Ubuntu/Debian example:
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev libpq-dev libpqxx-devUse the provided Makefile:
# build
make
# run
./econtract_api
# clean
make clean
# rebuild from scratch
make rebuildTargets are defined in the Makefile and compile all sources under src/ into the build/ directory, linking into the econtract_api executable.
Place configuration (e.g., database connection) in the config layer (see src/config). If you prefer environment variables, load them early in main.cpp and pass to components. Example variables you might use:
- DATABASE_URL=postgres://user:pass@localhost:5432/econtract
- APP_ENV=development
Migrations are not included here. Recommended approaches:
- SQL files in a migrations/ directory
- A migration tool (e.g., sqitch or a simple custom runner)
Ensure a PostgreSQL database is available and your DATABASE_URL is correctly set before running.
- Validate and sanitize all inputs in the API layer
- Use parameterized queries for PostgreSQL
- Protect secrets (never commit secrets; use environment variables or external secret stores)
- Keep OpenSSL and libpqxx up to date
MIT. See LICENSE.