A production-ready, enterprise-grade backend for a personal journaling application with JWT authentication, MongoDB, Redis caching, and AWS cloud deployment.
Live API: https://journalapilav.tech
Swagger UI: https://journalapilav/swagger-ui.html
Author: Lav Kumar Dixit | GitHub: @lovekumardixit
- JWT-based Authentication with refresh tokens and role-based access (USER / ADMIN)
- Secure User Registration with strict validation (username, password, email)
- User Profile Management with profile photo upload/update/delete (AWS S3 storage)
- Complete Journal CRUD Operations with partial update support
- Sentiment Tracking (HAPPY, SAD, ANGRY, NEUTRAL) with filtering
- Weather API Integration for personalized greetings
- Email (SMTP) & Kafka Integration for event-driven architecture
- OpenAPI/Swagger auto-generated documentation with Bearer Authentication
- Redis Caching for improved performance
- HTTPS/SSL Secured with Let's Encrypt
- Production-Ready Deployment on AWS EC2 with Docker & Nginx
- Java 17 with Spring Boot 3.x
- Spring Security with JWT Authentication
- Spring Data MongoDB for persistence
- Spring Data Redis for caching
- Spring Kafka for event streaming
- OAuth2 (Google Login support)
- REST APIs with comprehensive documentation
- MongoDB Atlas for scalable NoSQL database
- Redis Cache for session & query caching
- Apache Kafka with Zookeeper
- Event-Driven Architecture for asynchronous processing
- AWS EC2 (Ubuntu Server) for hosting
- AWS S3 for profile image storage
- Docker & Docker Compose for containerization
- Nginx Reverse Proxy for load balancing
- HTTPS/SSL with Let's Encrypt certificate
- GitHub Actions for CI/CD automation
- JWT-based authentication with secure token management
- Role-based access control (RBAC)
- OAuth2 authentication (Google Login)
- Environment-based configuration (dev, staging, prod)
- Secure HTTPS/TLS encryption
- Protected AWS credentials and sensitive data
- Java 17+
- Maven 3.x
- Docker & Docker Compose (optional)
- Linux/Unix environment for production
- Clone the repository
git clone https://github.com/lovekumardixit/Journal-Backend-API.git
cd Journal-Backend-API- Configure environment variables
export MONGO_URI='mongodb+srv://<user>:<pass>@cluster.mongodb.net/userdb'
export JWT_SECRET='your-strong-secret-key-here'
export SERVER_PORT=8081
export WEATHER_API_KEY='your-api-key'
export MAIL_USERNAME='your-email@gmail.com'
export MAIL_PASSWORD='your-app-password'
export KAFKA_BOOTSTRAP_SERVERS='localhost:9092'
export AWS_ACCESS_KEY_ID='your-aws-key'
export AWS_SECRET_ACCESS_KEY='your-aws-secret'
export AWS_S3_BUCKET='your-bucket-name'- Build & Run
# With Maven (dev profile)
mvn clean package
mvn -Dspring-boot.run.profiles=dev spring-boot:run
# With Java
java -jar target/Backend-0.0.1-SNAPSHOT.jar --spring.profiles.active=devLocal server: http://localhost:8081
# Build Docker image
docker build -t journal-backend-api:latest .
# Run container
docker run -p 8081:8081 \
-e MONGO_URI='<your-mongodb-uri>' \
-e JWT_SECRET='<your-secret>' \
-e AWS_ACCESS_KEY_ID='<your-key>' \
-e AWS_SECRET_ACCESS_KEY='<your-secret>' \
journal-backend-api:latest
# With Docker Compose
docker-compose up -d- Base URL: https://your-api-url.com
- OpenAPI JSON: https://your-api-url.com/v3/api-docs
- Swagger UI: https://your-api-url.com/swagger-ui.html
Authentication
POST /auth/registerβ Register new userPOST /auth/loginβ Login and receive JWT tokensPOST /auth/refreshβ Refresh access tokenPOST /auth/logoutβ Logout user
User Profile
GET /user/meβ Get current user profileGET /user/profileβ Get profile with photo URLGET /user/get/{city}β Get weather greetingPOST /user/profile-photo/uploadβ Upload profile photo (multipart)DELETE /user/profile-photoβ Delete profile photo
Journal Entries
POST /entryβ Create new entryGET /entry/{id}β Get entry by IDPUT /entry/{id}β Update entryPATCH /entry/{id}β Partial updateDELETE /entry/{id}β Delete entryGET /entry/user/{userId}β Get user's entries
Filters & Analytics
GET /sentimentβ Filter entries by sentimentGET /sentiment/statsβ Get sentiment statistics
For complete API details, visit: Swagger UI
- Click the "Authorize" button in Swagger UI
- Enter your token in the format:
Bearer YOUR_JWT_TOKEN - Execute requests directly from the UI
src/main/java/com/love/Backend/
βββ controller/ # REST endpoints (Auth, User, Entry, Sentiment)
βββ service/ # Business logic & core services
βββ repository/ # Spring Data repositories
βββ entity/ # JPA domain models
βββ dto/ # Request/Response DTOs
βββ config/ # Spring config (Security, Swagger, Redis, AWS S3)
βββ kafka/ # Event producers & consumers
βββ exception/ # Custom exceptions & error handlers
βββ util/ # Utility classes & helpers
βββ BackendApplication.java
Run all tests with Maven:
mvn testValidation Tests: Comprehensive test cases for user registration, authentication, and input validation.
See related documentation:
- VALIDATION_RULES.md β User validation rules & best practices
- TEST_VALIDATION.md β Step-by-step test scenarios
- OS: Ubuntu 20.04+ LTS
- Java 17 installed
- MongoDB Atlas for managed database
- Redis for caching layer
- Nginx reverse proxy with SSL
- Let's Encrypt for HTTPS/TLS
- Push Docker image to registry
docker tag journal-backend-api:latest your-registry/journal-backend-api:latest
docker push your-registry/journal-backend-api:latest- Deploy on EC2
ssh ec2-user@your-ec2-ip
cd /opt/journal-api
docker pull your-registry/journal-backend-api:latest
docker-compose up -d- Configure Nginx
server {
listen 443 ssl http2;
server_name your-api-url.com;
ssl_certificate /etc/letsencrypt/live/your-api-url.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-api-url.com/privkey.pem;
location / {
proxy_pass http://localhost:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Production uses profile-based configuration. Set environment variables:
export SPRING_PROFILES_ACTIVE=prod
export MONGO_URI='mongodb+srv://user:pass@cluster.mongodb.net/journal'
export JWT_SECRET='<strong-production-secret>'
export AWS_S3_BUCKET='journal-profile-photos'β
JWT Secret: Strong, random, environment-specific
β
HTTPS/TLS: Let's Encrypt SSL certificates
β
Database: MongoDB Atlas with authentication & IP whitelist
β
AWS Credentials: Stored in EC2 IAM roles (not hardcoded)
β
Environment Variables: Profile-based, never committed to VCS
β
CORS: Configured for trusted domains only
β
Rate Limiting: Implemented on authentication endpoints
- VALIDATION_RULES.md β Comprehensive validation standards
- TEST_VALIDATION.md β Test case scenarios
- KAFKA_GUIDE.md β Event streaming setup
- EC2_S3_DEPLOYMENT.md β AWS deployment guide
- QUICK_START.md β 5-minute quick setup
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
This project is licensed under the MIT License β see LICENSE file for details.
Love Dixit
- GitHub: @lovekumardixit
- LinkedIn: Love Dixit
- Email: cyber.lavdixit@gmail.com
Last Updated: May 20, 2026 | Status: Production Ready β