A lightweight Python chat server backend built for real server deployment. Based on the custom HTTP server framework from Chat_Server and extended with MySQL persistence and structured logging for production use.
- Custom Python HTTP server (no heavy frameworks)
- MySQL-backed message and user storage
- CSV-based request/access logging
- Environment-driven configuration via
.env - Designed to run on a real Linux server (e.g. via
systemdorscreen)
- Python 3.10+
- MySQL / MariaDB server running and accessible
- Python packages (install via pip):
pip install -r requirements.txt
If there is no
requirements.txtyet, you will need at minimum:mysql-connector-pythonandpython-dotenv.
ChatServerBackend/
├── src/ # Server source code
├── Configurations/
│ └── mysql.conf # MySQL connection config (not committed)
├── Logs/
│ └── base_log.csv # Access / base log file (not committed)
├── .env # Environment variable file (not committed)
├── .gitignore
└── README.md
Three files must be created manually before running the server. They are excluded from version control via .gitignore.
Create the directory and file:
mkdir -p Configurations[DEFAULT]
host = localhost
port = 3306
[root]
user = your_mysql_username
password = your_mysql_passwordReplace your_mysql_username and your_mysql_password with your actual MySQL credentials.
Create the log directory and an empty log file:
mkdir -p Logs
touch Logs/base_log.csvCreate a .env file in the project root:
MYSQL_CONFIG_FILE=./Configurations/mysql.conf
MYSQL_USER_NAME=root
BASE_LOGFILE=Logs/base_log.csvAdjust MYSQL_USER_NAME to match the section name in your mysql.conf if you use a different database user.
From the project root:
python src/main.pyThe exact entry point filename may vary — check the
src/directory for the main server file.
screen -S chatserver
python src/main.py
# Detach with Ctrl+A, then D- Restrict MySQL user permissions to only the database this server needs.
- If exposing the server to the internet, consider placing it behind a reverse proxy (nginx or Caddy) and using TLS.
- Chat_Server — Original chat server prototype with custom HTTP framework
- Media-System — Media handling component used in this backend