A secure, feature-rich journal application built with Spring Boot that enables users to create, manage, and analyze their journal entries with sentiment tracking, weather integration, and automated insights.
Journal App is a RESTful API backend service that provides users with a private journaling platform. The application supports user authentication via JWT tokens and Google OAuth 2.0, offers sentiment analysis on journal entries, integrates real-time weather data, and delivers weekly email summaries to help users understand their emotional patterns over time.
- User registration and authentication with secure password hashing (BCrypt)
- JWT-based stateless authentication with configurable expiration
- Google OAuth 2.0 integration for seamless sign-in
- Role-based access control (USER and ADMIN roles)
- Profile management including username and password updates
- Account deletion capability
- Full CRUD operations for journal entries
- Automatic timestamp recording for each entry
- Sentiment tagging support (HAPPY, SAD, ANGRY, ANXIOUS)
- User-specific entry isolation ensuring privacy
- Opt-in weekly sentiment analysis feature
- Automated analysis of journal entries from the past 7 days
- Email notifications with sentiment summaries sent every Sunday
- Kafka-based asynchronous processing with email fallback
- Real-time weather data integration via Weather API
- Redis caching for optimized API performance (5-minute TTL)
- Weather information displayed alongside user greetings
- View all registered users
- Create administrator accounts
- Clear application cache on demand
- Weekly sentiment analysis and email delivery (Sunday 9 AM)
- Periodic cache clearing (every 20 minutes)
- Spring Boot 2.7.16
- Java 8
- Maven
- MongoDB (primary data store with transaction support)
- Redis (caching layer)
- Spring Security
- JWT (JJWT 0.12.5)
- BCrypt password encoding
- Google OAuth 2.0
- Apache Kafka (event streaming)
- Spring Kafka
- Weather API (weatherapi.com)
- Swagger/OpenAPI 3.0
- Spring Actuator
- Lombok (boilerplate reduction)
- Logback (structured logging with file rotation)
The application provides Swagger UI for interactive API documentation. Once the application is running, access the documentation at:
http://localhost:8080/swagger-ui.html
| Method | Endpoint | Description |
|---|---|---|
| POST | /public/signup |
Register a new user account |
| POST | /public/login |
Authenticate and receive JWT token |
| GET | /public/health-check |
Check application health status |
| Method | Endpoint | Description |
|---|---|---|
| GET | /auth/google/callback |
Google OAuth callback handler |
| Method | Endpoint | Description |
|---|---|---|
| GET | /user |
Get user greeting with current weather |
| PUT | /user |
Update user profile |
| DELETE | /user |
Delete user account |
| Method | Endpoint | Description |
|---|---|---|
| GET | /journal |
Retrieve all journal entries |
| POST | /journal |
Create a new journal entry |
| GET | /journal/id/{id} |
Retrieve a specific journal entry |
| PUT | /journal/id/{id} |
Update a journal entry |
| DELETE | /journal/id/{id} |
Delete a journal entry |
| Method | Endpoint | Description |
|---|---|---|
| GET | /admin/all-users |
Retrieve all users |
| POST | /admin/create-admin-user |
Create an admin user |
| GET | /admin/clear-app-cache |
Clear application cache |
Before running the application, ensure you have the following installed and configured:
- Java 8 or higher
- Maven 3.6+
- MongoDB instance
- Redis instance
- Apache Kafka broker (optional, for sentiment analysis)
The application uses Spring profiles for environment-specific configuration:
dev- Development environmentprod- Production environment
Configure the following in your application.yml or application-{profile}.yml:
spring:
data:
mongodb:
uri: your-mongodb-uri
database: journaldb
redis:
host: localhost
port: 6379
kafka:
bootstrap-servers: localhost:9092
weather:
api:
key: your-weather-api-key
google:
client:
id: your-google-client-id
secret: your-google-client-secretThe application enforces the following security rules:
/public/**and/auth/**- Publicly accessible/journal/**and/user/**- Require authentication/admin/**- Require ADMIN role- CSRF protection is disabled (appropriate for stateless REST APIs)
- Session management is stateless
mvn spring-boot:run -Dspring-boot.run.profiles=devmvn spring-boot:run -Dspring-boot.run.profiles=prodmvn clean package
java -jar target/journalApp-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod- Register a new account via
/public/signupwith username, email, and password - Authenticate via
/public/loginto receive a JWT token - Include the JWT token in the
Authorizationheader for subsequent requests:Authorization: Bearer <your-jwt-token> - Tokens expire after 1 hour and require re-authentication
Alternatively, users can authenticate using Google OAuth 2.0 for a streamlined sign-in experience.
The application implements a multi-level caching strategy:
- Weather Data: Cached in Redis with a 5-minute TTL to reduce external API calls
- Application Configuration: Loaded into memory at startup and refreshed periodically
- Cache Clearing: Automated every 20 minutes via scheduled task, with manual clearing available for admins
The application uses Logback for structured logging with the following configuration:
- Console output for development
- File-based logging with rotation
- Maximum file size: 10MB
- Log retention: 10 days
- Log format includes timestamp, thread name, log level, logger name, and message
Spring Actuator provides health checks and monitoring endpoints. Access the health endpoint at:
http://localhost:8080/actuator/health