A comprehensive note-taking application backend built with Spring Boot microservices architecture, supporting rich text formatting, code snippets, and real-time saving functionality.
- User Management: Simple username-based authentication
- Note Management: Create, edit, delete notes with rich text and code formatting
- Real-time Saving: WebSocket-based auto-save functionality
- Search & Filtering: Advanced search capabilities with language filtering
- Public Notes: Unauthenticated access to public notes
- Microservices Architecture: Scalable and maintainable design
- High Performance: Redis caching and optimized database queries
- Security: Input validation, rate limiting, and data sanitization
-
User Service (Port 8081)
- User creation and validation
- Username uniqueness checks
- User activity tracking
-
Note Service (Port 8082)
- Note CRUD operations
- Rich text and code formatting
- WebSocket real-time saving
- Redis caching
-
Search Service (Port 8083)
- Advanced search and filtering
- Full-text search capabilities
- Language-based filtering
- Cached search results
-
Gateway Service (Port 8080)
- API routing and load balancing
- Rate limiting
- Cross-origin resource sharing
- Backend: Spring Boot 3.2.0, Java 17
- Database: PostgreSQL 15
- Caching: Redis 7
- Message Broker: WebSocket (STOMP)
- Containerization: Docker
- Orchestration: Kubernetes
- Monitoring: Prometheus, Grafana
- Logging: ELK Stack (Elasticsearch, Logstash, Kibana)
- Java 17+
- Maven 3.8+
- Docker & Docker Compose
- PostgreSQL 15
- Redis 7
-
Clone the repository
git clone <repository-url> cd scrib-backend
-
Start all services
docker-compose up -d
-
Access the application
- API Gateway: http://localhost:9200
- User Service: http://localhost:9201
- Note Service: http://localhost:9202
- Search Service: http://localhost:9203
-
Start PostgreSQL and Redis
# PostgreSQL docker run -d --name postgres -e POSTGRES_DB=scrib_db -e POSTGRES_USER=scrib_user -e POSTGRES_PASSWORD=scrib_password -p 5432:5432 postgres:15 # Redis docker run -d --name redis -p 6379:6379 redis:7-alpine
-
Build and run services
# Build all modules mvn clean install # Run User Service cd user-service && mvn spring-boot:run # Run Note Service (in another terminal) cd note-service && mvn spring-boot:run # Run Search Service (in another terminal) cd search-service && mvn spring-boot:run # Run Gateway Service (in another terminal) cd gateway-service && mvn spring-boot:run
POST /api/users
- Create a new userGET /api/users/{username}/exists
- Check if username existsGET /api/users/{username}
- Get user by usernamePUT /api/users/{username}/activity
- Update last activity
POST /api/notes
- Create a new notePUT /api/notes/{id}
- Update a noteDELETE /api/notes/{id}
- Delete a noteGET /api/notes/{id}
- Get a note by IDGET /api/notes
- List notes with filteringGET /api/notes/search
- Search notesGET /api/notes/languages
- Get available code languages
/ws
- WebSocket connection endpoint/app/note.save
- Save note changes/app/note.auto-save
- Auto-save note changes/topic/note.saved
- Note saved confirmation/queue/note.saved
- User-specific note saved notification
GET /api/search/notes
- Search notesGET /api/search/notes/user/{userId}
- Search user notesGET /api/search/notes/public
- Get public notesGET /api/search/notes/user/{userId}/all
- Get all user notesGET /api/search/notes/language/{language}
- Get notes by languageGET /api/search/languages
- Get available languages
CREATE TABLE users (
id UUID PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
created_at TIMESTAMP NOT NULL,
last_activity_at TIMESTAMP
);
CREATE TABLE notes (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
title VARCHAR(255),
content TEXT,
visibility ENUM('PUBLIC', 'PRIVATE') NOT NULL,
code_language VARCHAR(50),
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
deleted_at TIMESTAMP
);
SPRING_DATASOURCE_URL
: Database connection URLSPRING_DATASOURCE_USERNAME
: Database usernameSPRING_DATASOURCE_PASSWORD
: Database passwordSPRING_REDIS_HOST
: Redis hostSPRING_REDIS_PORT
: Redis port
Each service has its own application.yml
file with specific configurations for:
- Server ports
- Database connections
- Redis settings
- Logging levels
- Cache configurations
-
Create namespace
kubectl apply -f k8s/namespace.yaml
-
Deploy database and cache
kubectl apply -f k8s/postgres-deployment.yaml kubectl apply -f k8s/redis-deployment.yaml
-
Deploy microservices
kubectl apply -f k8s/user-service-deployment.yaml kubectl apply -f k8s/note-service-deployment.yaml kubectl apply -f k8s/search-service-deployment.yaml kubectl apply -f k8s/gateway-service-deployment.yaml
-
Build Docker images
docker build -t scrib/user-service:latest user-service/ docker build -t scrib/note-service:latest note-service/ docker build -t scrib/search-service:latest search-service/ docker build -t scrib/gateway-service:latest gateway-service/
-
Deploy with Docker Compose
docker-compose up -d
- HTTP request metrics
- JVM memory usage
- Database connection metrics
- Cache hit/miss ratios
- WebSocket connection metrics
- Service health monitoring
- Performance metrics
- Error rate tracking
- Resource utilization
- Input validation and sanitization
- Rate limiting (100 requests/minute per IP)
- SQL injection prevention
- XSS protection
- CORS configuration
- Data encryption at rest
mvn test
mvn verify
# Using Apache Bench
ab -n 1000 -c 10 http://localhost:9200/api/notes
- Target: 10,000 concurrent users
- Response Time: <500ms for API calls
- Real-time Saving: <100ms for WebSocket updates
- Availability: 99.9% uptime target
- Scalability: Horizontal scaling support
- Connection:
/ws
endpoint with SockJS support - Auto-save: Debounced saving every 500ms
- Live Updates: Real-time note synchronization
- Error Handling: Graceful error recovery
- Python, Java, JavaScript, C++, SQL
- HTML, CSS, TypeScript, Go, Rust
- And many more with syntax highlighting
scrib-backend/
βββ common/ # Shared DTOs and utilities
βββ user-service/ # User management service
βββ note-service/ # Note management with WebSocket
βββ search-service/ # Search and filtering service
βββ gateway-service/ # API Gateway
βββ k8s/ # Kubernetes configurations
βββ monitoring/ # Prometheus and Grafana configs
βββ docker-compose.yml # Local development setup
- Linting: Checkstyle, SpotBugs
- Testing: JUnit 5, TestContainers
- Documentation: OpenAPI/Swagger
- Code Coverage: JaCoCo
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
For support and questions, please open an issue in the repository or contact the development team.
Scrib Backend - Enterprise-grade note-taking application with real-time collaboration and rich formatting support.