A modern web application for storing, managing, and sharing code snippets. Built with Next.js 15+, TypeScript, and MongoDB.
- ✅ JWT-based authentication with cookie secure handling
- ✅ Protected API routes with middleware validation
- ✅ Secure password handling with bcrypt
- ✅ Token-based session management
- ✅ HTTP-only cookies for enhanced security
- ✅ Rate limiting protection
- ✅ Edge runtime support for auth routes
- ✅ Create, edit, and delete code snippets
- ✅ Advanced code editor with CodeMirror 6
- ✅ Multiple language support with syntax highlighting
- ✅ Folder organization system
- ✅ Tag-based categorization
- ✅ Public/Private visibility controls
- ✅ Snippet forking capability
- ✅ Snippet embedding system
- ✅ Favorites and pinned snippets
- ✅ Analytics tracking
- ✅ Comment system with likes
- ✅ User feed with activity updates
- ✅ Follow/Unfollow system
- ✅ User profiles with customization
- ✅ Leaderboard system
- ✅ Real-time notifications
- ✅ Comment threads and discussions
- ✅ Like system for snippets and comments
- ✅ Dynamic achievement tracking
- ✅ Multiple achievement categories
- ✅ Real-time progress updates
- ✅ Achievement notifications
- ✅ Daily streak tracking
- ✅ User analytics integration
- ✅ Responsive design with Tailwind CSS
- ✅ Dark/Light theme switching
- ✅ Toast notification system
- ✅ Loading states and animations
- ✅ Real-time updates with SSE
- ✅ Mobile-friendly interface
- ✅ Command palette for quick actions
- ✅ Breadcrumb navigation
-
Frontend:
- Next.js 15.1.7
- TypeScript 5
- Tailwind CSS 3.4
- Shadcn UI Components
- CodeMirror 6
- Framer Motion 12.4
-
Backend:
- Next.js API Routes
- MongoDB with Mongoose 8.10
- JWT Authentication
- Server-Sent Events (SSE)
- Edge Runtime Support
- Rate Limiting
-
Features:
- Real-time notifications
- Social interactions
- Achievement system
- Analytics tracking
- File management
- Code embedding
-
Clone the repository
git clone https://github.com/shreejaybhay/snippets.git cd snippets -
Environment Setup Create a
.env.localfile:MONGODB_URL=your_mongodb_connection_string NEXT_PUBLIC_BASE_URL=http://localhost:3000 JWT_KEY=your_jwt_secret CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret
-
Installation
npm install npm run dev
-
Running Development Server
npm run dev
-
Building for Production
npm run build
-
Linting
npm run lint
src/
├── app/
│ ├── api/ # API routes
│ │ ├── achievements/ # Achievement endpoints
│ │ ├── analytics/ # Analytics tracking
│ │ ├── auth/ # Authentication
│ │ ├── feed/ # User feed
│ │ ├── folders/ # Folder management
│ │ ├── leaderboard/ # Leaderboard system
│ │ ├── notifications/ # Real-time notifications
│ │ ├── snippet/ # Snippet operations
│ │ └── users/ # User management
│ ├── dashboard/ # Dashboard pages
│ ├── learn/ # Learning resources
│ ├── login/ # Authentication pages
│ └── signup/ # Registration pages
├── components/
│ ├── ui/ # Reusable UI components
│ └── [feature]/ # Feature-specific components
├── config/ # Configuration files
├── hooks/ # Custom React hooks
├── lib/ # Core utilities
├── models/ # MongoDB schemas
├── services/ # Business logic
├── types/ # TypeScript definitions
└── utils/ # Helper functions
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.