Server-X is a highly performant, fully self-contained custom HTTP server and URL shortener built completely from scratch in modern C++23. Bypassing high-level web frameworks and external databases, the project relies purely on raw socket programming and file handling to serve HTTP requests, manage user sessions, and resolve shortened URLs. It demonstrates a deep understanding of network protocols, memory management, and low-level system design.
Serves static files and handles RESTful API endpoints natively without relying on external libraries.
User registration and login utilizing SHA-256 password hashing with cryptographic salts.
Generates 8-character random collision-resistant hashes, tracks user-specific URL history, and detects duplicates.
Implements proprietary cookie-based session tokens for stateful user authentication over stateless HTTP.
Persists user data, session states, and URL mappings entirely through highly structured, raw text file storage.
A custom socket listener binds to a specified port, accepting incoming TCP connections and parsing raw HTTP request headers.
Decoupled logic maps specific HTTP methods and URIs to dedicated C++ handler functions.
database.txt acts as the user table, storing comma-separated records. url-mapping.txt functions as a fast key-value store linking hashes to destination URLs.
The server dynamically constructs valid HTTP response headers (status codes, content types, cookies) and appends HTML payloads or redirect locations.
Implement a thread pool or an asynchronous event loop (using epoll or kqueue) to handle thousands of concurrent TCP connections.
Build an in-memory hash map cache for frequently accessed short URLs to minimize disk I/O reads.
Add IP-based and user-based rate limiting natively at the socket layer to protect from DDoS attacks.
Interested in this project?