Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” PasteVault – High-Performance C++ Paste Sharing Platform

A light, blazingly fast, and security-focused Pastebin microservice engineered in C++17, powered by Crow, Asio, and SQLite3. Features Zero-Knowledge Client-Side AES-256 Encryption, Prism.js Syntax Highlighting, πŸ”₯ Burn After Reading, and a sleek Slate Glassmorphism UI.

Containerized with Docker and deployed on Render.

Language Framework Database Encryption Build System Docker

🌐 Live Demo

πŸš€ Live Application: https://pastevault-tbl1.onrender.com/

Live Demo



πŸš€ Key Features

  • πŸ”’ Client-Side Zero-Knowledge Encryption: Optional password protection uses AES-256 (CryptoJS) directly in the browser. Text is encrypted before leaving the clientβ€”the C++ backend and SQLite database store only scrambled ciphertext and never see plaintext or passwords.
  • ⚑ Automatic Prism.js Syntax Highlighting: Dynamic language detection and syntax highlighting for C++, Python, JavaScript, HTML, SQL, CSS, and more with Prism.js dark themes.
  • πŸ”₯ "Burn After Reading" One-Time Pastes: Optional single-view pastes that automatically self-destruct and purge permanently from SQLite the instant they are retrieved.
  • πŸš€ Top-Down Toast Notifications & Quick Actions: Modern floating toast popup on creation with direct share-link copying and a 1-click "Copy Content" button for viewers.
  • πŸ’Ž Slate Glassmorphism UI: Modern developer-focused design inspired by Vercel and Linear, complete with ambient background glows, responsive layouts, and custom scrollbars.
  • RESTful C++ Backend: Structured routing supporting POST (create), GET (retrieve), and DELETE (explicit deletion) with JSON request/response payloads.
  • SQLite Persistence: Thread-safe C++ database wrapper using parameterized prepared statements to prevent SQL injection.
  • Auto-Expiration Handling: Flexible TTL (Time-To-Live) support (5 minutes, 1 hour, 1 day, or permanent) with automatic expiration checks and database cleanup.
  • Dynamic Base62 ID Generator: Short 7-character unique identifier generation using C++ <random> (std::mt19937).
  • Automated Cloud Pipeline: Containerized multi-stage Docker build pipeline deployed to Render with zero-downtime auto-deploys via GitHub webhooks.

πŸ› οΈ Tech Stack & Architecture

Backend

  • Language: C++17
  • HTTP Framework: Crow Framework (built on Asio)
  • Database: SQLite3
  • Build System: CMake 3.14+ (using FetchContent for automated dependency management)

Frontend

  • UI & Styling: HTML5, Modern CSS3 (CSS Variables, Backdrop Filters, Glassmorphism, Custom Scrollbars)
  • Encryption: CryptoJS (AES-256 Client-Side)
  • Code Highlighting: Prism.js (Core + Autoloader)
  • Scripting: Vanilla JavaScript (ES6+ async/await with fetch & Clipboard API)

Infrastructure

  • Containerization: Multi-stage Docker
  • Hosting: Render Cloud Platform

πŸ“‚ Project Structure

PasteVault/
β”œβ”€β”€ CMakeLists.txt         # Root build configuration
β”œβ”€β”€ Dockerfile             # Multi-stage container build spec
β”œβ”€β”€ pastevault.db          # SQLite persistent storage (auto-generated)
β”œβ”€β”€ include/               # Header includes
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.cpp           # Server entry point & static file routing
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ DatabaseManager.hpp
β”‚   β”‚   └── DatabaseManager.cpp # SQLite C++ wrapper, migration & prepared statements
β”‚   β”œβ”€β”€ handlers/
β”‚   β”‚   β”œβ”€β”€ PasteHandler.hpp
β”‚   β”‚   └── PasteHandler.cpp    # ID generation, TTL/Burn logic & JSON handling
β”‚   └── routes/
β”‚       └── Router.hpp          # Crow REST API endpoints definition
└── public/
    β”œβ”€β”€ index.html         # Single-page UI layout & Toast containers
    β”œβ”€β”€ style.css          # Glassmorphism dark slate styling & Prism overrides
    └── app.js             # Client routing, AES encryption/decryption & clipboard actions

πŸ”Œ API Reference

1. Create a Paste

Endpoint

POST /api/paste

Request Body (Plaintext)

{
  "content": "Hello world from PasteVault!",
  "ttl_minutes": 60,
  "is_encrypted": false,
  "burn_after_reading": false
}

Request Body (Client-Encrypted & Burn-After-Reading)

{
  "content": "U2FsdGVkX1+x9b...",
  "ttl_minutes": -1,
  "is_encrypted": true,
  "burn_after_reading": true
}

Note: Set ttl_minutes to -1 for permanent or burn-after-reading pastes.

Response (201 Created)

{
  "id": "RCOtjlQ",
  "is_encrypted": true,
  "burn_after_reading": true,
  "created_at": 1784874104,
  "expires_at": -1
}

2. Retrieve a Paste

Endpoint

GET /api/paste/<paste_id>

Response (200 OK)

{
  "id": "RCOtjlQ",
  "content": "U2FsdGVkX1+x9b...",
  "is_encrypted": true,
  "burn_after_reading": true,
  "created_at": 1784874104,
  "expires_at": -1
}

Note: If burn_after_reading is true, this request returns the payload and deletes the row from SQLite immediately.


3. Delete a Paste

Endpoint

DELETE /api/paste/<paste_id>

Response (200 OK)

{
  "message": "Paste deleted successfully"
}

βš™οΈ Local Development Setup

Prerequisites

  • GCC / G++ (supporting C++17)
  • CMake (v3.14+)
  • SQLite3 library installed locally

Building & Running

Clone the repository

git clone https://github.com/<YOUR_USERNAME>/PasteVault.git
cd PasteVault

Configure with CMake

mkdir build && cd build
cmake ..

Compile

make              # Linux/Mac
# OR
mingw32-make      # Windows MinGW

Launch the server

# Run from project root so static public files load correctly
cd ..
./build/pastevault

Open http://localhost:18080/ in your web browser.


🐳 Docker Setup

Build and run locally using Docker:

docker build -t pastevault .
docker run -p 18080:18080 pastevault

πŸ“œ License

Distributed under the MIT License. See LICENSE for more information.

About

A high-performance C++17 RESTful pastebin service engineered with Crow, SQLite3, CMake, and Docker.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages