- Chity Chat
- Chat App Features
- Web Server Features
- Web Server Limitations
- Current Web Server Challenges
- Planned Features
- Learning Experience
- Project Directory Structure
- Build Web Server
- Coding Style
- Fullstack Project
- Frontend: In JavaScript, HTML and CSS. (My first time)
- Backend: Custom web server written in C.
Though the front-end is my initial venture into web development, the standout feature lies in the C-written backend.
- Private/Public Groups: Users have the option to join public groups or enter private ones using specific codes.
- Real-time Communication: Messages are sent and received instantly.
- Real-time User Staus Updates: Instantly see if users comes online and offline.
- HTTP/1.1 Parsing: Basic parsing with support for GET and POST requests.
- Web Sockets Implementation: Real-time communication support.
- SSL/TLS via OpenSSL: Secure connections.
- Password Security: Salting and hashing using SHA512.
- I/O Multiplexing: Utilizes epoll(7) for efficient I/O.
- Database Management: Uses PostgreSQL for SQL database.
- Session Management: Users receive session IDs for persistent login.
- Multi-Threaded: Utilizes a thread pool to efficiently manage concurrent events.
- IP Versions: Supports both IPv4 and IPv6.
- Exclusively designed for this Chat App.
- Basic HTTP Parsing: Limited to handling only GET and POST requests.
- Monolithic Architecture: Combines web server and chat server functionalities within a single process.
Experiences significant slowdowns with only approximately 100 concurrent users.Fixed.Encounters unexpected errors when multiple clients disconnect simultaneously.Fixed.Worker threads are heavly I/O bound to PostgreSQL. Non-blocking postgres connection maybe?- Faces potential deadlock issues during high load, resulting in server unresponsiveness.
- Private Groups: Invitation-only groups.
- Mark group as private, only group members can get it.
- Implement Invite Codes
- Implement Invite Links
- Group Member Roles: Admins, mods, etc.
- User Account Management: Change username, display name, bio, and password.
- Deletion: Ability to delete accounts, messages, and groups.
- Delete messages.
- Delete accounts.
- Detete groups.
- Direct Messaging (DM): Private messaging between users (Create Private Group with only 2 users).
- Enhanced Messaging: Send photos, videos, files, reply to messages, and edit messages.
- Front-end implementation (images)
- Add images and paste image from clipboard.
- Back-end implementation (images)
- Front-end implementation (images)
- Mobile Compatibility: Improve usability on mobile devices.
- URL Parameters Support: Support HTTP URL parameters.
- Real-Time User Status Management: Online, Offline, Away, busy, typing, etc.
- User Online/Offline
- Typing.
- User set status
- Upload File Management: Avoid duplication user files.
- Default profile pic
- Real-Time User Profile Updates: Receive instant updates for user profile changes like usernames, display names, bio, and profile pictures.
- Profile pictures.
- Username / Displayname
- Bio
Through building Chity Chat, I learned:
- Web Server Implementation:
- HTTP
- Web Sockets
- SSL/TLS
- Multi-Threading
- SQL Database Usage with SQLite3, later PostgreSQL.
- Frontend Development with JavaScript, HTML, and CSS.
- Password Security with SHA512 hashing.
# chitychat's root
/
├── server/ # Server/Backend
│ ├── src/ # Server C source code
│ ├── include/ # Server Header Files
│ └── sql/ # SQL schema and queries
│
├── client/ # Client/Frontend
│ ├── public/ # Default Public Directory & Website source code
│ └── headless/ # Headless client; bot source code
│
└── tests/ # Currently only have load_balance_bots.sh
Note
Exclusively for Linux.
- clang
- json-c
- libmagic
- postgresql
- openssl
- meson
Dependencies Package Names
- Arch:
json-c file postgresql openssl meson clang
- Debian:
libjson-c-dev libmagic-dev postgresql postgresql-client libpq-dev libssl-dev meson clang
git clone https://github.com/laxyyza/chitychat.git && cd chitychat
CC=clang meson setup build/
ninja -C build/
Executable name: chitychat
inside build/
Read the Arch Wiki (or your distro wiki) for setting up PostgreSQL.
After you setup PostgreSQL, create a PostgreSQL database called:
chitychat
sudo -u postgres createdb chitychat
Generate self-signed SSL keys: (in project's root directory)
Note
Your browser will display a warning when using self-signed SSL keys.
openssl req -x509 -newkey rsa:4096 -keyout server/server.key -out server/server.crt -days 365 -nodes
Now you should be done, and execute build/chitychat
server.
Config file: server/config.json
Change port in config file or use --port
arguments. See build/chitychat --help