- β¨ Features
- ποΈ Architecture
- π οΈ Tech Stack
- π Quick Start
- π‘ API Documentation
- π¨ UI Components
- π Authentication
- π Deployment
- π€ Contributing
- π License
- π Snippet Management: Create, edit, and organize code snippets with syntax highlighting
- π Advanced Search: Search snippets by title, tags, language, or content
- β Community Engagement: Upvote/downvote system for quality content curation
- πΎ Personal Collections: Save and organize favorite snippets
- π₯ User Profiles: Comprehensive profiles with activity tracking and statistics
- π Analytics Dashboard: Personal dashboard with detailed statistics and insights
- π·οΈ Smart Tagging: Organize snippets with custom tags for easy discovery
- π± Responsive Design: Fully responsive UI that works on all devices
- π Dark/Light Theme: Built-in theme switcher with system preference detection
- β‘ Real-time Updates: Live updates for votes and interactions
- π Secure Authentication: GitHub OAuth integration with JWT tokens
- π Activity Tracking: Track snippet creation, upvotes, and community engagement
- π Language Statistics: Visual breakdown of programming languages used
- π Achievement System: Display total upvotes, followers, and contribution metrics
- π Social Links: Integration with GitHub, Twitter, and personal websites
- πΈ Custom Avatars: Cloudinary-powered image uploads for profile pictures
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Next.js 15 β β Express.js β β MongoDB β
β Frontend βββββΊβ Backend βββββΊβ Database β
β β β β β β
β β’ React 19 β β β’ JWT Auth β β β’ User Model β
β β’ TypeScript β β β’ GitHub OAuth β β β’ Snippet Model β
β β’ Tailwind CSS β β β’ Rate Limiting β β β’ Relationships β
β β’ Shadcn/ui β β β’ Validation β β β’ Indexing β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Cloudinary β β Vercel β β Render β
β Image Storage β β Frontend β β Backend β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
snippetCove/
βββ client/ # Next.js Frontend
β βββ src/
β β βββ app/ # App Router (Next.js 13+)
β β β βββ (auth)/ # Auth route group
β β β βββ dashboard/ # User dashboard
β β β βββ snippets/ # Snippet pages
β β β βββ submit/ # Snippet submission
β β β βββ users/ # User profiles
β β βββ components/ # Reusable components
β β β βββ ui/ # Shadcn/ui components
β β β βββ profile/ # Profile components
β β β βββ public-profile/ # Public profile views
β β βββ lib/ # Utilities and configurations
β β βββ types/ # TypeScript type definitions
β βββ public/ # Static assets
βββ server/ # Express.js Backend
βββ controllers/ # Business logic
βββ models/ # MongoDB schemas
βββ routes/ # API endpoints
βββ middlewares/ # Custom middleware
βββ config/ # Database configuration
- Framework: Next.js 15.3.2 with App Router
- Language: TypeScript 5
- Styling: Tailwind CSS 4 + Shadcn/ui components
- State Management: React Context API
- Icons: Lucide React
- Animations: Tailwind CSS animations
- Deployment: Vercel
- Runtime: Node.js with Express.js 5
- Language: JavaScript (ES6+ modules)
- Database: MongoDB with Mongoose ODM
- Authentication: JWT + Passport.js (GitHub OAuth)
- File Upload: Multer + Cloudinary
- Security: bcryptjs, express-rate-limit, sanitize-html
- Deployment: Render
{
"@radix-ui/react-*": "Latest", // Accessible UI primitives
"@vercel/analytics": "^1.5.0", // Analytics tracking
"react-syntax-highlighter": "^15.6.1", // Code highlighting
"react-hot-toast": "^2.5.2", // Toast notifications
"next-themes": "^0.4.6", // Theme management
"class-variance-authority": "^0.7.1" // Component variants
}{
"mongoose": "^8.15.0", // MongoDB ODM
"jsonwebtoken": "^9.0.2", // JWT authentication
"passport-github2": "^0.1.12", // GitHub OAuth
"cloudinary": "^2.7.0", // Image management
"express-validator": "^7.2.1", // Input validation
"express-rate-limit": "^7.5.0" // Rate limiting
}- Node.js 18+ and npm/yarn
- MongoDB database (local or cloud)
- GitHub OAuth App credentials
- Cloudinary account (for image uploads)
git clone https://github.com/drockparashar/snippetCove.git
cd snippetCovecd server
npm installCreate .env file in server directory:
# Database
MONGO_URI=mongodb://localhost:27017/snippetcove
# JWT
JWT_SECRET=your_super_secret_jwt_key
# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_CALLBACK_URL=http://localhost:5000/api/auth/github/callback
# Cloudinary
CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
# Frontend URL
FRONTEND_URL=http://localhost:3000
# Server Port
PORT=5000Start the backend server:
npm startcd ../client
npm installCreate .env.local file in client directory:
NEXT_PUBLIC_BACKEND_URL=http://localhost:5000Start the development server:
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
POST /api/auth/signup # User registration
POST /api/auth/login # User login
GET /api/auth/me # Get current user
GET /api/auth/github # GitHub OAuth login
GET /api/auth/github/callback # GitHub OAuth callback
GET /api/auth/check # Check auth status
POST /api/auth/save-snippet # Save snippet to user
POST /api/auth/unsave-snippet # Remove saved snippet
PUT /api/auth/update-profile # Update user profileGET /api/snippets # Get all snippets (paginated)
POST /api/snippets # Create new snippet (auth required)
GET /api/snippets/:id # Get snippet by ID
GET /api/snippets/search?q=query # Search snippets
GET /api/snippets/user/:id/upvotes # Get user's total upvotes
POST /api/snippets/upvote # Upvote a snippet
POST /api/snippets/upvote/remove # Remove upvoteGET /api/users/id/:id # Get user profile by ID
POST /api/users/follow # Follow a user
POST /api/users/unfollow # Unfollow a user
POST /api/users/upload # Upload avatarPOST /api/snippets
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"title": "React useEffect Hook",
"code": "useEffect(() => {\n // Effect logic\n}, [dependencies]);",
"language": "javascript",
"tags": ["react", "hooks", "useEffect"]
}GET /api/snippets/search?q=react
Response:
[
{
"_id": "64f...",
"title": "React useState Hook",
"code": "const [state, setState] = useState(initialValue);",
"language": "javascript",
"tags": ["react", "hooks"],
"author": {
"_id": "64e...",
"name": "John Doe"
},
"upvotes": 15,
"createdAt": "2024-01-15T10:30:00Z"
}
]Built with Shadcn/ui components and Tailwind CSS for consistent, accessible design:
- π¨ Theme System: Automatic dark/light mode switching
- π± Responsive Design: Mobile-first approach with breakpoint utilities
- βΏ Accessibility: ARIA labels, keyboard navigation, screen reader support
- π Component Library: Pre-built, customizable components
- CodeBlock: Syntax-highlighted code display with copy functionality
- SnippetCard: Reusable snippet preview cards
- ProfileSection: User profile information and statistics
- DashboardHeader: Navigation and user controls
- SearchBar: Advanced search with filters
- ThemeToggle: Dark/light theme switcher
/* Custom animations in globals.css */
.animate-float {
animation: float 6s ease-in-out infinite;
}
.glow {
box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}- User clicks "Login with GitHub"
- Redirect to GitHub OAuth
- GitHub redirects to callback
- Server generates JWT token
- Frontend receives token
- Token stored in localStorage
- User authenticated for API calls
{
"id": "user_mongodb_id",
"email": "[email protected]",
"iat": 1640995200,
"exp": 1641600000
}- Frontend:
/dashboard,/submit,/settings - Backend: All POST/PUT/DELETE operations
- Rate Limiting: 10 snippets per hour per IP
- Input Sanitization: HTML sanitization for all user inputs
- JWT Expiration: 7-day token expiry
- CORS Configuration: Restricted to allowed origins
# Automatic deployment from GitHub
# Environment variables required:
NEXT_PUBLIC_BACKEND_URL=https://your-backend-url.com# Build command: npm install
# Start command: npm start
# Environment variables: (see .env example above)- Database: MongoDB Atlas cloud database
- Connection: Secure connection string with authentication
- Indexing: Optimized indexes for search and queries
- Create Cloudinary account
- Get cloud name, API key, and secret
- Configure environment variables
- Images automatically optimized and delivered via CDN
We welcome contributions! Here's how to get started:
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
- Frontend: ESLint + TypeScript strict mode
- Backend: ES6+ modules with consistent formatting
- Commits: Conventional commit messages
- Testing: Write tests for new features
- π Bug fixes and performance improvements
- β¨ New features (snippet sharing, code execution, etc.)
- π Documentation improvements
- π¨ UI/UX enhancements
- π§ͺ Test coverage expansion
- ποΈ Architecture: Full-stack TypeScript application
- π¦ Components: 25+ reusable UI components
- π‘οΈ Security: JWT authentication with OAuth integration
- π± Responsive: Mobile-first design approach
- β‘ Performance: Optimized with Next.js 15 and modern React
- π Global: CDN-delivered assets via Vercel and Cloudinary
- Shadcn/ui for the beautiful component library
- Vercel for seamless frontend deployment
- Render for reliable backend hosting
- MongoDB Atlas for cloud database
- Cloudinary for image management
This project is licensed under the MIT License - see the LICENSE file for details.
Pranshu Parashar - @drockparashar
- π Portfolio: Pranshu Parashar
- π§ Email: [[email protected]]
- π¦ Twitter: [@PranshuParasha4]