In effort to leverage modern C++20 features and understand how to build REST API's with Boost. I have opted to replicate my JobTracker application in C++20, which is a locally hosted containerized Job Application management tool for you to track your job applications in a Postgres Database instead of a spreadsheet.
I will be leveraging CMake for our build system, Docker for housing our PostgreSQL container and Ollama, and Clang for formatting and linting our project.
1.First and foremost install Docker on your system. Follow Docker's instructions
- Create a
.envfile in the project root with the following variables:
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_password
POSTGRES_DB=your_database_name
DB_HOST=localhost
DB_PORT=5432
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOST}:${DB_PORT}/${POSTGRES_DB}"To run JobTracker in Linux/MacOS run the following commands in your terminal:
# Get the production enviroment running
make start-prod
# Type the following to start the app:
./build/Jobtracker
# When you are done and type 'n' to end the app, then type "exit":
exit
# Clean up when you are done
make clean-prodgraph TD
subgraph "C++ Client & CLI"
C[C++ Client App]
end
subgraph "FastAPI Spacy Backend"
F[FastAPI Spacy App]
end
subgraph "Postgres Database"
P[(Postgres DB)]
end
C-- 1.Connect (libpqxx) -->P
C-- 2.POST /process_job -->F
F-- 3.JSON Response -->C
C-- 4.INSERT Query -->P
- Internally C++ Client of JobTracker establishes a connection with the Database and FastAPI backend
- Obtain the pasted Job Application from C++ Command Line Component and submit post request to FastAPI backend to process it
- Retrieve the process Job Application as JSON in the C++ Client
- Submit the JSON Job Application into the Database
.
├── CMakeLists.txt
├── compose.yaml
├── Dockerfile.cpp-dev-env
├── Dockerfile.cpp-dev-env.dockerignore
├── Dockerfile.cpp-prod
├── Dockerfile.cpp-prod.dockerignore
├── Dockerfile.spacy-ner
├── Dockerfile.spacy-ner.dockerignore
├── include
│ ├── app
│ │ └── JobTracker.hpp
│ ├── data
│ │ └── JobApplication.hpp
│ ├── db
│ │ └── PostgresDatabaseManager.hpp
│ └── llm
│ └── FastAPIClient.hpp
├── init.sql
├── logo.jpeg
├── Makefile
├── README.md
├── requirements.txt
├── src
│ ├── cpp
│ │ ├── app
│ │ │ └── JobTracker.cpp
│ │ ├── data
│ │ │ └── JobApplication.cpp
│ │ ├── db
│ │ │ └── PostgresDatabaseManager.cpp
│ │ ├── llm
│ │ │ └── FastAPIClient.cpp
│ │ └── main.cpp
│ └── python
│ ├── main.py
│ └── nlp_utils.py
└── tests
└── cpp
├── CMakeLists.txt
└── pasteJobDescription_test.cpp
src/cpp/app/JobTracker.cpp: This is the main program which contains the core logic for accepting pasted Job Applications, requesting the FastAPI backend to process it with Spacy, and saving the returned parsed JSON data to the Postgres database.src/cpp/data/JobApplication.cpp: Contains the data structure that encapsulates a Job Application with fields specified ininit.sqlsrc/cpp/db/PostgresDatabaseManager.cpp: Contains the libpqxx interface and logic to submit parsed, JSON applications to the databasesrc/cpp/llm/FastAPIClient.cpp: Serves as the backbone for creating POST requests to the FastAPI backend to process raw plain text Job Applicationsrc/python/main.py: Creates the FastAPI backend which accepts POST requests and processes them into formatted JSON Job Application objects with the Natural Language Processing (NLP) utilityJobProcessorsrc/python/nlp_utils.py: Homes theJobProcessorclass that executes the parsing logic to parse the raw plain text Job Application into a JSON format