scraf-backend is the backend of Scraf. It is developed as a REST API, and handles all the interactions between the frontend and the persistent storage (database) as well as the integration with the various online school registers.
This project follows the Canonical Project Structure for C++ projects: no separation of src/
and include/
, unit tests in the same directory as the main source directory and integration tests in the tests/
directory.
scraf-backend uses the Meson build system.
scraf-backend can only run and compile on Linux (because of Pistache).
scraf-backend uses C++20 and requires a modern compiler. It should work on Clang and GCC 10 or newer.
If using Clang, you must link the program using LLD (probably a Meson bug related to static libraries)
ODB is an Object-Relational Mapping (ORM) library. The stable version of ODB packaged by Debian does not support anything newer than C++14, so it is required to use the beta plus the module for PostgreSQL. It is recommended to follow the official installation guide, but if you're lazy you can install it with these commands (spoiler: it is goning to take more than 10 minutes, go drink a tea or something)
sudo apt install gcc-10-plugin-dev
cd /directory/of/your/choice/where/you/ll/store/build/cache
mkdir build2-build && cd build2-build
curl --silent --remote-name https://download.build2.org/0.13.0/build2-install-0.13.0.sh
sh build2-install-0.13.0.sh --yes --trust yes --no-check
cd /directory/of/your/choice/where/you/ll/store/build/cache
mkdir odb-build && cd odb-build
bpkg --quiet create --directory odb-gcc-10 cc config.cxx=g++ config.c.std=gnu17 config.cxx.std=gnu++17 config.cc.coptions=-O3 config.bin.rpath=/usr/local/lib config.install.root=/usr/local config.install.sudo=sudo
cd odb-gcc-10
bpkg --quiet --trust-yes build --yes odb@https://pkg.cppget.org/1/beta
bpkg test odb
bpkg --quiet install odb
cd ..
bpkg --quiet create --directory gcc-10 cc config.cxx=g++ config.c.std=gnu17 config.cxx.std=gnu++17 config.cc.coptions=-O3 config.install.root=/usr/local config.install.sudo=sudo
cd gcc-10
bpkg --quiet add https://pkg.cppget.org/1/beta
bpkg --quiet --trust-yes fetch
bpkg --quiet build --yes libodb
bpkg --quiet build --yes libodb-pgsql
bpkg --quiet install --all --recursive
We use GoogleTest for unit testing. We chose not to include the library as a submodule of scraf-backend because it is already packaged by most Linux distributions. We use the latest version provided by Debian Testing, but probably anything newer than 1.9.x will work. On Debian you can install it with apt install libgtest-dev
For parsing and serializing JSON we use simdjson and nlohmann json (also known as JSON for Modern C++). On a Debian system, you can install them with apt install libsimdjson-dev nlohmann-json3-dev
.
After you installed all the dependencies, you can build Scraf with Meson.
First, clone the repository
git clone https://github.com/PwRAu/scraf-backend.git
Then configure the build directory
cd scraf-backend
meson setup build --buildtype=release
And finally compile the executable
meson compile -C build