This document explains how to deploy the Chat Application locally. It lists all dependencies, database setup instructions, build steps, and how to verify that the system is functioning correctly.
The repository also includes a working script called deploy.sh
which automates most of the setup process.
Important directories in the repository:
client/
business/
data/
service/
sql/
Makefile
deploy.sh
README.md
Each directory corresponds to a layer in the application architecture.
- Client layer – browser interface and test client
- Service layer – HTTP server
- Business layer – application logic
- Data layer – database access
- SQL directory – schema and seed data
sudo pacman -Syu
sudo pacman -S base-devel mariadb gcc make asiosudo apt update
sudo apt install build-essential mariadb-server \
default-libmysqlclient-dev libasio-devRequired components:
- MariaDB database server
- MariaDB client development libraries
- ASIO networking library
- g++ compiler with C++17 support
- make build tool
Crow headers are included in the repository.
Once you have all of the dependencies, just run deploy.sh. Everything below is for running it manually.
Start MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadbCreate the database and user:
sudo mariadb <<SQL
CREATE DATABASE IF NOT EXISTS chat_app;
CREATE USER IF NOT EXISTS 'chat_user'@'localhost'
IDENTIFIED BY 'chatpass';
GRANT ALL PRIVILEGES ON chat_app.* TO 'chat_user'@'localhost';
FLUSH PRIVILEGES;
SQLImport schema and seed data:
mariadb -u chat_user -pchatpass chat_app < sql/tables.sql
mariadb -u chat_user -pchatpass chat_app < sql/insert.sqlFrom the project root directory:
make clean
makeThis compiles the server binary.
Start the server:
./mychat-serverOpen the application in a browser:
http://localhost:18080
To confirm the system works:
- Open the web interface.
- Create a user through the UI.
Verify with SQL:
mariadb -u chat_user -pchatpass chat_app -e \
"SELECT * FROM users;"- Create a conversation.
- Send a message.
Verify messages in the database:
mariadb -u chat_user -pchatpass chat_app -e \
"SELECT * FROM messages;"- Edit a message.
- Delete a message.
Example request:
curl http://localhost:18080/usersQuery recent messages:
mariadb -u chat_user -pchatpass chat_app -e \
"SELECT * FROM messages ORDER BY message_id DESC LIMIT 10;"Database does not exist
Create it manually:
CREATE DATABASE chat_app;Server returns 404
Ensure the server is started from the repository root directory.
MariaDB running with skip-grant-tables
Restart MariaDB:
sudo systemctl restart mariadbInclude screenshots showing:
- Web interface loaded
- Creating a user
- Database showing inserted user
- Creating a conversation
- Sending a message
- Editing a message
- Deleting a message
- Running the automated test client