All Projects
Low Level Development

Server-X

About

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.

Tech Stack

C++23
Raw Sockets
OpenSSL (SHA-256)
CMake
File System I/O
HTML
JavaScript
Tailwind CSS

Features

Custom HTTP Server

Serves static files and handles RESTful API endpoints natively without relying on external libraries.

Secure Authentication Engine

User registration and login utilizing SHA-256 password hashing with cryptographic salts.

URL Shortening & Redirection

Generates 8-character random collision-resistant hashes, tracks user-specific URL history, and detects duplicates.

Custom Session Management

Implements proprietary cookie-based session tokens for stateful user authentication over stateless HTTP.

Zero-Dependency Database

Persists user data, session states, and URL mappings entirely through highly structured, raw text file storage.

Architecture

01

Networking Layer

A custom socket listener binds to a specified port, accepting incoming TCP connections and parsing raw HTTP request headers.

02

Routing Layer

Decoupled logic maps specific HTTP methods and URIs to dedicated C++ handler functions.

03

Storage & Data Access Layer

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.

04

Response Generation

The server dynamically constructs valid HTTP response headers (status codes, content types, cookies) and appends HTML payloads or redirect locations.

Future Improvements

Thread Pooling & Concurrency

Implement a thread pool or an asynchronous event loop (using epoll or kqueue) to handle thousands of concurrent TCP connections.

In-Memory Caching (LRU)

Build an in-memory hash map cache for frequently accessed short URLs to minimize disk I/O reads.

Rate Limiting & Security

Add IP-based and user-based rate limiting natively at the socket layer to protect from DDoS attacks.