Skip to content

SuperbTUM/CPlusPlus_General_Management_System

 
 

Repository files navigation

Introduction

We developed a complicated full stack application with socket-based single-server-multi-client connection. The front-end of this application is window-based Qt6 and back-end is SQLite3/MongoDB(experimental). Serveral highlights of this application are:

  • Modern C++23
  • Multiplexing with epoll (unix-based system only) to achieve pseudo-concurrency
  • Multi-threading & vectorization
  • A variety of database selection
  • API for user customization

Goal & Vision

The aim of this full-stack application is to provide a smooth and robust (high scalability & low latency) user experience while maintaining low memory occupation at the same time. We leveraged unix-domain socket(We don't wish to use asio at this stage as we don't want to have boost library involved.) and epoll connection to achieve faster pseudo-concurrency and lots of move(forward) operations to avoid unnecessary copy and reduce memory cost. We applied vectorization to process messages faster. We explicitly added clustered indexes in our relational database to achieve faster queries.

Other than performance, we also take safety into consideration. We had pragma key credentials in the database to avoid sensitive information leakage. We also had encrypted TCP connection with digital certificate and private key verification.

Dependencies & Requirements

  • CMake 3.25

  • g++-14! Installation

  • Ninja (Optional)

  • String formatting tool: fmt

  • JSON formatting tool: json, glaze(faster)

  • Database: Install with sudo apt-get install libsqlite3-dev, and optionally, SQLite3 Encryption (Only accessible on Windows system, MSVC)

  • Parallelism: openmp

  • Security: Install with sudo apt install libssl-dev

Quick Start

In the front-end part, install Qt6 on your local operating system, navigate to front-end directory compile with cmake.

In the back-end part, compile server with CMakeLists.txt.

If you are working with Ninja, execute the following commands:

cmake -G Ninja
ninja

Otherwise,

cmake CMakeLists.txt
make

You can also make it work in docker environment:

docker build .

If activate without openssl, on the server side,

cd bin/
./cplusplusproject2022fall

On the client side, after compiled with C++20,

./client_unencrypted.cpp SERVER_IP

If activate with openssl (after quick modification on the CMakeLists.txt), additionally, you need CA certificate and private key,

cd bin/
./cplusplusproject2022fall PATH_TO_CA_CERTIFICATE PATH_TO_UNSECURED_PRIVATE_KEY

On the client side, after compiled with C++20,

./client.cpp SERVER_IP PATH_TO_CA_CERTIFICATE PATH_TO_UNSECURED_PRIVATE_KEY

OpenSSL sample certificates and private keys Drive

Memory Check with Valgrind

To install Valgrind, please follow the steps

wget https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2
tar xvf valgrind-3.20.0.tar.bz2
cd valgrind-3.20.0
./configure
make
sudo make install

Or

sudo snap install valgrind --classic

For memcheck

cd bin/
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ./cplusplusproject2022fall

Benchmark

System CPU Round Trip Time (Example data, nano-scale)
Ubuntu 20 4-core 88.16 ms

Part of C++ new features

  • Concept & Requires & template
  • Vectorization
  • Structural binding
  • Chrono
  • Constexpr & Lambda
  • Smart pointers
  • Const transformation
  • Final
  • Variant
  • Explicit
  • Variadic Template

Acknowledge

We thank the assistance and guidance from Prof. Bjarne Stroustrup.

Languages

  • C++ 99.8%
  • Other 0.2%