The cure for Notepad++ tab hell β a self-hosted snippet manager for all those unnamed code files.
KoalaSnippets is a self-hosted web application for storing, organizing, and sharing code snippets. Make them taggable, searchable, filterable β and finally get rid of those thousands of unnamed files in Notepad++. Features a two-pane interface, server-side syntax highlighting, and a self-contained build with no external CDN calls. Your code, your server, your rules.
Table of Contents
- β¨ Core Features
- π§± Tech Stack
- π Quick Start
- π³ Docker Deployment
- π Project Structure
- π Security
- π Translations & Localization
- πΊοΈ Roadmap
- π License
| Feature | Description |
|---|---|
| Argon2id Password Hashing | Passwords secured with Argon2id, per-user salt, and an application-level pepper via AUTH_PEPPER. |
| Timing-Attack-Resistant Comparisons | Share tokens and API keys compared using crypto.timingSafeEqual with SHA-256 normalization. |
| Content Security Policy | Strict CSP headers configured in Next.js and optionally enforced via Caddy reverse proxy. |
| Visibility Controls | Public Explorer for anyone, secure shared links with unguessable tokens, or keep snippets strictly private. |
| Feature | Description |
|---|---|
| Command Palette | Ctrl+K / βK opens a search and command palette with shortcuts like /new, /settings, /admin, and /theme. |
| Keyboard Shortcuts | 14+ shortcuts including vim-style navigation (j/k), Cmd+S to save, Cmd+Shift+N for new snippets, and ? for help. |
| Themes & Backgrounds | 7 app themes (Dark, Midnight, Nordic, Dracula, Terracotta, Hacker, Light) and 12 CSS background patterns. |
| Statistics Page | Public metrics tracking total snippets, lines of code, unique tags, languages, and more. |
| 2-Pane Layout | Responsive card grid with dark mode by default, JetBrains Mono for code, and a collapsible sidebar. |
| Internationalization | Full English and German localization with a language toggle. Extensible via locale files. |
| Feature | Description |
|---|---|
| Multi-File Snippets & Collections | Group related code files within a single snippet. Organize with tags, collections, and favorites. |
| Custom Code Editor | A lightweight editor with Tab indentation, bracket auto-closing, overtype skipping, and pair-matching deletions. |
| Server-Side Syntax Highlighting | Shiki-based highlighting for 30+ languages, with languages and themes lazy-loaded on demand. |
| Search & Filters | Server-side search with an "include code in search" toggle, filterable by tags and languages, with OR/AND logic. |
| Feature | Description |
|---|---|
| WAL-Mode SQLite | Write-Ahead Logging with tuned busy timeouts for concurrent read/write access. |
| Automated Backups | Built-in VACUUM INTO backup scheduler with Grandfather-Father-Son retention (7 daily, 4 weekly, 12 monthly). |
| Admin Panel | Role-based admin dashboard for managing users, triggering backups, and monitoring system health. |
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router, React Server Components) |
| Language | TypeScript (strict mode) |
| Styling | Tailwind CSS v4 + shadcn/ui-inspired components |
| Database | SQLite via better-sqlite3 |
| ORM | Drizzle ORM |
| Syntax Highlighting | Shiki (server-side with lazy-loaded language modules) |
| Authentication | Session cookies + Argon2id + Pepper + RBAC |
| Fonts | next/font/google (Inter, JetBrains Mono) |
| Icons | lucide-react (bundled) |
| i18n | Custom React Context + typed locale files (EN, DE) |
- Node.js 20+ (Node.js 22 used in Docker)
- npm (or pnpm/yarn)
git clone https://github.com/Shik3i/KoalaSnippets.git
cd KoalaSnippets
npm installcp .env.example .envEdit .env with your values:
# Required: Application-level pepper for password hashing
AUTH_PEPPER=your-long-random-string-here
# Required: Session encryption secret
SESSION_SECRET=another-long-random-string
# Optional: Admin user seeded on first boot
# CRITICAL: These default credentials ('admin' / 'admin') are for local testing only
# and MUST be changed to secure values before deploying to production!
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin
# Optional: Enable/disable user registration (default: false)
ALLOW_REGISTRATION=true
# Optional: SQLite database path
DATABASE_URL=file:./data/koalasnippets.db
# Optional: Backup directory (default: ./backups)
BACKUP_DIR=./backups
# Optional: Shared secret for programmatic API access (bypasses CSRF checks)
# API_KEY=your-api-key-hereWarning
The default seeded administrator credentials (ADMIN_USERNAME=admin / ADMIN_PASSWORD=admin) are strictly for local development and verification. You MUST change them to secure random values before pushing to staging or running in production!
Generate secure random strings:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"mkdir -p data
npm run db:generate
npm run db:migratenpm run devOpen http://localhost:3000. The server uses Turbopack for fast hot-reloading. The SQLite database initializes automatically on first access.
| Command | Description |
|---|---|
npm run dev |
Start development server with Turbopack |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run db:generate |
Generate Drizzle migrations |
npm run db:migrate |
Apply database migrations |
npm run db:studio |
Open Drizzle Studio (web-based DB browser) |
# Set environment variables
export AUTH_PEPPER="your-pepper"
export SESSION_SECRET="your-secret"
export ALLOW_REGISTRATION="true"
export ADMIN_USERNAME="admin"
export ADMIN_PASSWORD="your-secure-password"
# Build and run
docker compose up --build -dOpen http://localhost:3000. The SQLite database and backups persist across container restarts via Docker volumes.
docker build -t koalasnippets .
docker run -d -p 3000:3000 \
-v koalasnippets-data:/app/data \
-v koalasnippets-backups:/app/backups \
-e AUTH_PEPPER=your-pepper \
-e SESSION_SECRET=your-secret \
-e ALLOW_REGISTRATION=true \
-e ADMIN_USERNAME=admin \
-e ADMIN_PASSWORD=your-secure-password \
koalasnippetsSee Caddyfile.example for a production-ready Caddy configuration with security headers (CSP, HSTS, X-Content-Type-Options).
KoalaSnippets/
βββ docs/ # Architecture, security, and AI documentation
βββ src/
β βββ app/ # Next.js App Router (pages, API routes)
β β βββ api/ # API routes
β β β βββ auth/ # Login, logout, register
β β β βββ snippets/ # CRUD operations
β β β βββ settings/ # Password change & appearance update
β β β βββ admin/ # Admin-only: users, backups, stats
β β β βββ health/ # Health check endpoint
β β β βββ public/ # Public API (stats)
β β βββ admin/ # Admin dashboard (RBAC protected)
β β βββ dashboard/ # User snippet management
β β βββ snippets/[id]/ # Snippet detail view
β β βββ settings/ # User settings & Appearance settings
β β βββ stats/ # Public statistics page
β β βββ impressum/ # German imprint
β β βββ privacy/ # Privacy policy
β βββ features/ # Domain-driven feature folders
β β βββ admin/ # Backup UI lists, metrics, scheduling logic & admin guards
β β βββ auth/ # Login/register forms, session handlers & crypt auth utils
β β βββ snippets/ # Snippet cards, search header, custom CodeEditor, sort/view toggles & lazy Shiki highlighting
β β β βββ utils/ # Keyboard shortcuts, filter logic (OR/AND), shared constants
β β βββ core/ # Common layouts, confirm modals, rate limiters, CommandPalette & i18n
β βββ components/
β β βββ ui/ # shadcn/ui-inspired base primitives (buttons, inputs, cards, toasts, confirm-modal)
β βββ db/ # Drizzle schema, migrations, connection (WAL enabled)
β βββ proxy.ts # Next.js Middleware
β βββ instrumentation.ts # Server lifecycle hooks (backup, seeding)
βββ Dockerfile # Multi-stage production build
βββ docker-compose.yml # Docker orchestration
βββ Caddyfile.example # Reverse proxy with security headers
KoalaSnippets is fully localized in both English and German.
Want to contribute a translation? See the i18n Translation & Contribution Guide for details on adding a new language.
- Passwords hashed with Argon2id + Salt + Pepper
- Session tokens stored as HMAC-SHA-256 hashes, never plaintext
- Strict CSP and security headers via Next.js config + Caddy
- No external CDN calls β all assets bundled locally
- SQL injection prevented via Drizzle parameterized queries
- Timing-attack-resistant token comparison (
crypto.timingSafeEqual) - Rate limiting on login (5/15min) and registration (3/60min)
- Role-based access control (RBAC) β admin routes return 403 for non-admins
See docs/SECURITY.md for the full security specification.
Check the Roadmap to see planned features like CLI integration and API keys.
MIT