A production-ready code snippet sharing platform built with Spring Boot, React, Docker, and Kubernetes. Share, discover, and manage code snippets with Markdown support and syntax highlighting.
- Secure Authentication - JWT-based authentication with refresh tokens
- Markdown Support - Rich text editing with live Markdown preview
- Syntax Highlighting - Support for 20+ programming languages via Prism.js
- Search & Filter - Full-text search with language and tag filtering
- User Dashboard - Manage snippets with statistics and activity tracking
- Public/Private Snippets - Control snippet visibility
- Responsive Design - Mobile-friendly interface
- Containerized - Docker and Docker Compose ready
- Kubernetes Ready - Production-grade K8s manifests
- CI/CD Pipeline - Automated testing and deployment with GitHub Actions
- Framework: Spring Boot 3.2.0
- Language: Java 17
- Database: MySQL 8.0
- Security: Spring Security + JWT
- ORM: Spring Data JPA + Hibernate
- Migration: Flyway
- Testing: JUnit 5, Mockito
- Build: Maven
- Framework: React 18
- Routing: React Router v6
- HTTP Client: Axios
- Styling: CSS Modules
- Markdown: React-Markdown
- Syntax Highlighting: Prism.js
- Build: Create React App
- Containerization: Docker, Docker Compose
- Orchestration: Kubernetes
- CI/CD: GitHub Actions
- Monitoring: Spring Boot Actuator, Prometheus
- Web Server: Nginx (frontend)
- Java 17+
- Node.js 18+
- MySQL 8.0+
- Docker & Docker Compose (optional)
- kubectl & Minikube/K8s cluster (optional)
git clone https://github.com/username/snipper.git
cd snipperdocker run -d \
--name snipper-mysql \
-e MYSQL_ROOT_PASSWORD=rootpassword \
-e MYSQL_DATABASE=snipper \
-e MYSQL_USER=snipper_user \
-e MYSQL_PASSWORD=snipper_password \
-p 3306:3306 \
mysql:8.0cd backend
mvn spring-boot:runBackend will start on http://localhost:9090
cd frontend
npm install
npm startFrontend will start on http://localhost:3000
# Build and start all services
docker-compose up --build
# Access the application
# Frontend: http://localhost:3000
# Backend: http://localhost:9090
# MySQL: localhost:3306See DOCKER_SETUP.md for detailed Docker instructions.
# Apply all manifests
kubectl apply -f k8s/
# Check deployment status
kubectl get pods -n snipper
# Access the application
kubectl get svc frontend-service -n snipperSee KUBERNETES_SETUP.md for detailed Kubernetes instructions.
snipper/
├── backend/ # Spring Boot backend
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/com/snipper/
│ │ │ │ ├── config/ # Configuration classes
│ │ │ │ ├── controller/ # REST controllers
│ │ │ │ ├── dto/ # Data Transfer Objects
│ │ │ │ ├── exception/ # Exception handling
│ │ │ │ ├── health/ # Health indicators
│ │ │ │ ├── model/ # JPA entities
│ │ │ │ ├── repository/ # Data repositories
│ │ │ │ ├── security/ # Security configuration
│ │ │ │ └── service/ # Business logic
│ │ │ └── resources/
│ │ │ ├── db/migration/ # Flyway migrations
│ │ │ └── application*.yml # Configuration files
│ │ └── test/ # Unit & integration tests
│ ├── Dockerfile
│ └── pom.xml
│
├── frontend/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ │ ├── auth/ # Authentication components
│ │ │ ├── common/ # Shared components
│ │ │ ├── layout/ # Layout components
│ │ │ └── snippet/ # Snippet components
│ │ ├── contexts/ # React contexts
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ └── App.js
│ ├── Dockerfile
│ ├── nginx.conf
│ └── package.json
│
├── k8s/ # Kubernetes manifests
│ ├── namespace.yaml
│ ├── configmap.yaml
│ ├── secret.yaml
│ ├── mysql-*.yaml
│ ├── backend-deployment.yaml
│ ├── frontend-deployment.yaml
│ └── hpa.yaml
│
├── .github/workflows/ # CI/CD pipelines
│ ├── backend-ci.yml
│ ├── frontend-ci.yml
│ ├── docker-build.yml
│ └── deploy.yml
│
├── docker-compose.yml
└── README.md
POST /api/auth/register - Register new user
POST /api/auth/login - Login user
POST /api/auth/refresh - Refresh JWT token
GET /api/snippets - Get all snippets (paginated)
GET /api/snippets/{id} - Get snippet by ID
POST /api/snippets - Create new snippet
PUT /api/snippets/{id} - Update snippet
DELETE /api/snippets/{id} - Delete snippet
GET /api/snippets/search - Search snippets
GET /api/users/profile - Get current user profile
PUT /api/users/profile - Update user profile
GET /api/users/{username}/snippets - Get user's snippets
GET /actuator/health - Application health status
GET /actuator/health/liveness - Liveness probe
GET /actuator/health/readiness - Readiness probe
GET /actuator/metrics - Application metrics
GET /actuator/prometheus - Prometheus metrics
Edit backend/src/main/resources/application-dev.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/snipper
username: snipper_user
password: snipper_password
security:
jwt:
secret: your-secret-key-min-256-bits
expiration: 86400000 # 24 hoursEdit frontend/package.json:
{
"proxy": "http://localhost:9090"
}Or set environment variable:
REACT_APP_API_URL=http://localhost:9090cd backend
# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=UserServiceTest
# Run with coverage
mvn test jacoco:reportcd frontend
# Run all tests
npm test
# Run with coverage
npm test -- --coverage
# Run specific test
npm test -- SnippetEditor.test.jsSee DOCKER_SETUP.md for complete Docker deployment guide.
See KUBERNETES_SETUP.md for complete Kubernetes deployment guide.
See CI_CD_GUIDE.md for CI/CD pipeline documentation.
# Backend health
curl http://localhost:9090/actuator/health
# Frontend health
curl http://localhost:3000/# Application metrics
curl http://localhost:9090/actuator/metrics
# Prometheus metrics
curl http://localhost:9090/actuator/prometheusSee MONITORING_GUIDE.md for complete monitoring setup.
cd backend
# Run in development mode
mvn spring-boot:run
# Run with specific profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev
# Build JAR
mvn clean package
# Skip tests
mvn clean package -DskipTestscd frontend
# Install dependencies
npm install
# Start development server
npm start
# Build for production
npm run build
# Run linter
npm run lint
# Fix linting issues
npm run lint:fixFlyway migrations are in backend/src/main/resources/db/migration/
# Migrations run automatically on startup
# To create a new migration:
# 1. Create file: V{version}__Description.sql
# 2. Example: V4__Add_user_avatar.sqlPort already in use:
# Find process using port 9090
lsof -i :9090 # macOS/Linux
netstat -ano | findstr :9090 # Windows
# Kill the process
kill -9 <PID> # macOS/Linux
taskkill /PID <PID> /F # WindowsDatabase connection failed:
# Check MySQL is running
docker ps | grep mysql
# Check connection
mysql -h localhost -u snipper_user -pModule not found:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm installBuild fails:
# Clear build cache
rm -rf build
npm run buildContainer won't start:
# Check logs
docker logs snipper-backend
docker logs snipper-frontend
docker logs snipper-mysql
# Restart containers
docker-compose restart- 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
- Backend: Follow Java code conventions, use Spring Boot best practices
- Frontend: Follow Airbnb React/JavaScript style guide
- Commits: Use conventional commits format
- Update documentation for any new features
- Add tests for new functionality
- Ensure all tests pass
- Update the README if needed
- Request review from maintainers
This project is licensed under the MIT License - see the LICENSE file for details.
- Spring Boot team for the excellent framework
- React team for the amazing library
- Prism.js for syntax highlighting
- React-Markdown for Markdown rendering
- All contributors and users of this project
- Email: support@snipper.example.com
- Issues: GitHub Issues
- Documentation: Wiki
- Discussions: GitHub Discussions
- Code collaboration features
- Snippet versioning
- Comments and discussions
- Snippet collections/folders
- API rate limiting
- OAuth2 social login
- Dark mode
- Mobile app
- VS Code extension
- CLI tool
- ANIRUDHAN - Initial work - YourGitHub