A modern, efficient pastebin service specifically designed for sharing AI prompts and context windows. Built with Rust, Next.js, and Redis.
- 🚀 High-performance Rust backend
- ⚡ Real-time Next.js frontend
- 🔄 FIFO/LIFO storage with Redis
- 🌙 Dark/Light mode support
- 📱 Responsive design
- 🔗 Shareable links
- ⌛ Auto-expiring pastes (2 days)
- 📋 Copy to clipboard
- 💾 Download/Upload support
- Rust 1.72 or higher
- Node.js 18 or higher
- Redis 6.0 or higher
- Docker (optional)
markdown-pastebin/
├── backend/
│ ├── src/
│ │ ├── main.rs # Server setup and configuration
│ │ ├── handlers.rs # Request handlers
│ │ ├── models.rs # Data structures
│ │ └── storage.rs # Redis interaction
│ ├── Cargo.toml # Rust dependencies
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ └── MarkdownPastebin.tsx
│ │ │ └── PastebinClientWrapper.tsx
│ │ └── app/
│ │ └── page.tsx
│ │ └── globals.css
│ │ └── p/[id]/page.tsx # Dynamic Pages for created pastebin links
│ ├── package.json
│ └── Dockerfile
├── nginx/
│ └── conf.d/
│ └── default.conf
├── docker-compose.yml
└── README.md
- Clone the repository:
git clone https://github.com/yourusername/markdown-pastebin.git
cd markdown-pastebin- Start Redis:
docker run -d -p 6379:6379 redis:alpine- Set up the backend:
cd backend
cp .env.example .env
cargo run- Set up the frontend:
cd frontend
cp .env.example .env.local
npm install
npm run dev- Visit
http://localhost:3000in your browser
Using Docker Compose:
docker-compose up --build -dREDIS_URL=redis://127.0.0.1:6379
HOST=127.0.0.1
PORT=8080
RUST_LOG=infoNEXT_PUBLIC_API_URL=http://localhost:8080POST /api/pastes
Content-Type: application/json
{
"content": "Your markdown content here"
}Response:
{
"id": "unique-paste-id",
"url": "/p/unique-paste-id"
}GET /api/pastes/{id}Response:
{
"id": "unique-paste-id",
"content": "Your markdown content",
"created_at": "2024-11-25T20:22:16Z",
"last_accessed": "2024-11-25T20:22:16Z"
}- Run tests:
cd backend
cargo test- Run with logging:
RUST_LOG=debug cargo run- Build for release:
cargo build --release- Run development server:
npm run dev- Build for production:
npm run build- Start production server:
npm startBuild and run individual services:
# Backend
docker build -t pastebin-backend ./backend
docker run -p 8080:8080 pastebin-backend
# Frontend
docker build -t pastebin-frontend ./frontend
docker run -p 3000:3000 pastebin-frontend
# Redis
docker run -p 6379:6379 redis:alpine- Configure environment:
cp .env.example .env- Deploy:
docker-compose up -d- Scale services (optional):
docker-compose up -d --scale backend=3- Install dependencies:
apt update
apt install -y docker.io docker-compose nginx- Configure Nginx:
cp nginx/conf.d/default.conf /etc/nginx/conf.d/- SSL Setup (optional):
apt install -y certbot python3-certbot-nginx
certbot --nginx -d yourdomain.com- Start services:
docker-compose up -d# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backenddocker exec -it redis redis-cli
INFO
MONITOR# Create backup
docker run --rm -v markdown-pastebin_redis-data:/data \
-v $(pwd)/backup:/backup alpine tar czf /backup/redis-backup.tar.gz /data
# Restore backup
docker run --rm -v markdown-pastebin_redis-data:/data \
-v $(pwd)/backup:/backup alpine tar xzf /backup/redis-backup.tar.gz- Rate Limiting
- Input Validation
- CORS Configuration
- Redis Security
- SSL/TLS Configuration
- Redis Connection:
docker-compose ps
docker-compose logs redis- Frontend Build:
rm -rf .next
npm install
npm run build- Backend Build:
cargo clean
cargo build- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository.