SnippetBox2 is a self-hosted application for organizing your code snippets. It is an evolved version of the original Snippet Box project, adding key features such as a complete user management system, roles, and enhanced security for a multi-user environment.
It allows you to easily create, edit, search, and manage your snippets in various languages. With built-in Markdown support, SnippetBox2 makes it easy to add notes or documentation to your code.
- User Management and Authentication: A complete user registration and login system using a secure JWT (JSON Web Tokens) based system.
- User Roles (Admin and User):
- Admin: Has full control over all snippets and users in the system.
- User: Can only manage their own snippets.
- Admin Panel: A dedicated view for administrators to manage all users on the platform.
- Enhanced Security:
- Secure management of secrets (like
JWT_SECRET
) through environment variables and.env
files, preventing keys from being exposed in the source code. - Updated Docker base image and dependencies to fix known vulnerabilities.
- Secure management of secrets (like
- Dockerized Production Environment: The
Dockerfile
anddocker-compose.yml
have been optimized to build a single, secure, and robust image for production.
- Backend
- Node.js (v24)
- TypeScript
- Express.js
- Sequelize ORM + SQLite
- Frontend
- React
- TypeScript
- Bootstrap
- Deployment
- Docker & Docker Compose
To set up a local development environment with hot-reloading for the frontend and backend.
Requirements: Docker and Docker Compose.
# 1. Clone the repository
git clone https://github.com/danielgap/SnippetBox2.git
cd SnippetBox2
# 2. Start the development containers
# This will use the 'docker-compose.working.yml' file
docker compose -f docker-compose.working.yml up --build
- The frontend will be available at
http://localhost:3000
. - The backend will be available at
http://localhost:5000
.
These instructions use the pre-built, secure image available on Docker Hub.
Requirements: Docker and Docker Compose.
Create a file named .env
in the project root. This file will contain environment variables, such as the secret for signing authentication tokens. It is ignored by Git for security.
# Generate a random secret of 32 characters or more.
# Do not use the '$' character to avoid issues with Docker Compose.
JWT_SECRET=bZ8pD3kF7gRjWnQ4tYvA1xLhS9mC6uE2
Create a docker-compose.yml
file with the following content:
services:
snippetbox2:
image: danielgap/snippetbox2:latest
container_name: SnippetBox2
ports:
- "5000:5000"
volumes:
- ./data:/app/data
environment:
- NODE_ENV=production
- JWT_SECRET=${JWT_SECRET}
restart: unless-stopped
And start the container:
docker compose up -d
The application will be available at http://localhost:5000
.
If you prefer to build and manage your own image instead of using the one from Docker Hub.
# Build the image
docker build -t your-docker-user/snippetbox2:latest .
# Push the image to your repository
docker push your-docker-user/snippetbox2:latest
- Search: Search your snippets with built-in language and tag filters.
- Pinned Snippets: Pin your favorite or important snippets to the home screen for quick access.
- Snippet Library: Manage your snippets and filter by tags.
- Snippet Details: View your code with syntax highlighting, details, and documentation. Perform actions like editing, pinning, or deleting from a single place.
- Editor: Create and edit your snippets from a simple and easy-to-use editor.
Visit wiki for search functionality and available filters reference: Search functionality