A modern, full-stack code snippet manager built with cutting-edge technologies. Store, organize, and share your code snippets with beautiful syntax highlighting and a clean, intuitive interface.
- Smart Code Storage: Save code snippets with intelligent language detection
- Syntax Highlighting: Beautiful syntax highlighting for 20+ programming languages
- Public/Private Snippets: Control visibility of your code snippets
- Instant Search: Fast search through your snippets by title, description, or content
- Advanced Filtering: Filter by language, visibility, and creation date
- Share Snippets: Generate shareable links for public snippets
- Copy to Clipboard: One-click code copying with visual feedbacks
- React - Modern React with hooks and concurrent features
- TypeScript - Type-safe JavaScript with excellent DX
- Vite - Lightning-fast build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Beautiful, accessible UI components
- React Router - Client-side routing
- Bun - Fast JavaScript runtime and package manager
- Hono - Modern web framework for edge computing
- Drizzle ORM - Type-safe database ORM
- PostgreSQL - Robust relational database
- Cloudflare Workers - Edge computing platform
- GitHub Actions - CI/CD automation
- Drizzle Kit - Database migrations and introspection
- ESLint - Code linting and formatting
- Bun installed on your system
- PostgreSQL database (local or cloud)
- GitHub OAuth App configured
git clone https://github.com/cojocaru-david/snippetslibrary.com.git
cd snippetslibrary.com
bun install
Create a .env
file in the server
directory:
# Database
DATABASE_URL=postgresql://username:password@localhost:5432/snippets_library
# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
# JWT
JWT_SECRET=your_super_secret_jwt_key
# Frontend URL (for OAuth redirects)
FRONTEND_URL=http://localhost:5173
# Navigate to server directory
cd server
# Run database migrations
bun run db:migrate
# (Optional) Seed the database
bun run db:seed
# Start all services (from root directory)
bun run dev
# Or start individually:
bun run dev:server # Backend on port 8000
bun run dev:client # Frontend on port 5173
Visit http://localhost:5173
to see the application!
snippetslibrary.com/
βββ client/ # Frontend (React + Vite + Tailwind + shadcn/ui)
β βββ src/
β β βββ components/ # UI components
β β βββ pages/ # Page views
β β βββ contexts/ # Global state (Auth, Settings)
β β βββ hooks/ # Custom hooks
β β βββ lib/ # Utilities (API, helpers)
β β βββ types/ # TypeScript types
β βββ vite.config.ts
β
βββ server/ # Backend (Bun + Hono + Drizzle + JWT)
β βββ src/
β β βββ routes/ # API endpoints
β β βββ db/ # DB config & schema
β β βββ lib/ # Auth & middleware
β β βββ index.ts # App entry point
β βββ drizzle/ # Migrations
β βββ wrangler.jsonc # Cloudflare Workers config
β
βββ shared/ # Shared types across client & server
β βββ src/types/
β
βββ package.json # Root config (monorepo)
GET /api/auth/login
- Initiate GitHub OAuth loginGET /api/auth/callback
- Handle OAuth callbackGET /api/auth/me
- Get current user infoPOST /api/auth/logout
- Logout user
GET /api/snippets
- Get user's snippets (paginated)GET /api/snippets/:id
- Get specific snippetPOST /api/snippets
- Create new snippetPUT /api/snippets/:id
- Update snippetDELETE /api/snippets/:id
- Delete snippetPOST /api/snippets/:id/share
- Generate share linkGET /api/snippets/share/:shareId
- Get shared snippet
page
- Page number (default: 1)limit
- Items per page (default: 20, max: 50)language
- Filter by programming languagesearch
- Search in title/descriptionpublic
- Filter by visibility (true/false)
- Supports 20+ programming languages
- Automatic language detection
- Multiple themes (light/dark)
- Copy code with syntax preservation
- Code formatting
- Generate unique shareable links
- Public snippets accessible without authentication
- SEO-friendly URLs
- Embed-friendly snippet display
- Real-time search across title, description, and code
- Language-based filtering
- Visibility filtering (public/private)
- Date-based sorting
- Pagination for large result sets
# Development
bun run dev # Start all services
bun run dev:client # Start frontend only
bun run dev:server # Start backend only
bun run dev:shared # Build shared types in watch mode
# Building
bun run build # Build all projects
bun run build:client # Build frontend
bun run build:server # Build backend
bun run build:shared # Build shared types
# Database
bun run db:migrate # Run database migrations
bun run db:reset # Reset database
bun run db:seed # Seed database with sample data
bun run db:studio # Open database studio
# Deployment
bun run deploy:server # Deploy to Cloudflare Workers
id
- UUID primary keygithub_id
- GitHub user IDusername
- GitHub usernameemail
- User emailname
- Display nameavatar_url
- Profile picture URLbio
- User biographyui_theme
- UI theme preferencecode_theme
- Code highlighting themecreated_at
- Account creation dateupdated_at
- Last update date
id
- UUID primary keytitle
- Snippet titledescription
- Optional descriptioncode
- Snippet code contentlanguage
- Programming languagetags
- JSON array of tagsis_public
- Visibility flagshare_id
- Unique sharing identifieruser_id
- Foreign key to usersseo_title
- SEO title for public snippetsseo_description
- SEO descriptionseo_keywords
- SEO keywordscreated_at
- Creation dateupdated_at
- Last update date
id
- Session IDuser_id
- Foreign key to usersaccess_token
- OAuth access tokenexpires_at
- Session expirationcreated_at
- Session creation date
# Build and deploy
bun run build
bun run deploy:server
# Set environment variables in Cloudflare dashboard
# Configure custom domain if needed
# Build all projects
bun run build
# Deploy client to static hosting (Vercel, Netlify, etc.)
# Deploy server to any Node.js hosting provider
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow TypeScript best practices
- Update documentation as needed
- Follow the existing code style
- Use conventional commits
This project is licensed under the MIT License - see the LICENSE file for details.
- shadcn/ui for beautiful UI components
- Shiki for syntax highlighting
- Drizzle ORM for type-safe database queries
- Hono for the lightweight web framework
- Bun for the fast JavaScript runtime
- BHVR the base for the project
- Create an issue for bug reports
- Start a discussion for questions
Built with β€οΈ by developers, for developers