Skip to content

Secure Spring Boot backend for managing personal journals with JWT authentication, MongoDB, and Swagger API docs.

Notifications You must be signed in to change notification settings

smitkachhadiya/JournalEntryAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📓 Journal App – Backend API

A secure and scalable backend for managing personal journal entries

Java Spring Boot MongoDB JWT


📖 Overview

The Journal App Backend is a secure digital platform that enables users to create, manage, and maintain personal journal entries.
It provides RESTful APIs for:

  • User Registration & Authentication (JWT)
  • CRUD operations for journal entries
  • Weekly email updates

This backend ensures data security, scalability, and maintainability for personal journaling applications.


📂 Project Structure

JournalApp/

├── config/ # Security & application configurations

├── controller/ # REST API controllers

├── model/ # Entity models

├── repository/ # MongoDB repositories

├── service/ # Business logic services

├── dto/ # Data transfer objects

├── utils/ # Utility/helper classes

└── resources/ # application.properties and static files


✨ Features 🌟

  • JWT Authentication & Authorization – Secure login and role-based access control
  • User Management – Register, update profile, delete account
  • Journal Entry Management – Create, read, update, and delete journal entries
  • Admin Features – Manage users and their roles
  • Weekly Email Updates – Automated summaries for users
  • API Documentation – Swagger UI integration
  • Code Quality – Static analysis with SonarCloud

🛠 Tech Stack 💻

  • Language: Java
  • Framework: Spring Boot (2.7.15)
  • Database: MongoDB
  • Authentication: JWT
  • API Documentation: Swagger (Springdoc OpenAPI)
  • Logging: SLF4J with Logback
  • Testing Tools: Postman, SonarCloud
  • Email Service: SMTP
  • Build Tool: Maven / Gradle

🚀 How to Start Your Project ▶️

  1. Clone the repository
git clone https://github.com/your-username/JournalEntryAPI.git
cd JournalEntryAPI
  1. Configure Environment Variables
    Create a .env file in the root directory with the following keys:
MAIL_USERNAME=your_email@example.com
MAIL_PASSWORD=your_email_password
MONGO_USERNAME=your_mongo_username
MONGO_PASSWORD=your_mongo_password
MONGO_CLUSTER_HOST=your_mongo_cluster_host
MONGO_APP_NAME=Cluster1

Note: These values will be injected into your Spring Boot application via environment variables.

  1. Update application.yml or application-dev.yml
    Configure your MongoDB and mail settings using the environment variables:
spring:
  data:
    mongodb:
      uri: mongodb+srv://${MONGO_USERNAME}:${MONGO_PASSWORD}@${MONGO_CLUSTER_HOST}/${MONGO_APP_NAME}?retryWrites=true&w=majority
  mail:
    username: ${MAIL_USERNAME}
    password: ${MAIL_PASSWORD}
    host: smtp.gmail.com
    port: 587
    properties:
      mail:
        smtp:
          auth: true
          starttls:
            enable: true
  1. Build & Run the project
mvn clean install
mvn spring-boot:run
  1. Access API documentation
    Swagger UI : http://localhost:8080/swagger-ui/index.html

👥 User Roles 🧑‍🤝‍🧑

1. User

  • Register and log in
  • Create, update, and delete personal journal entries
  • View and manage profile
  • Receive weekly email updates

2. Admin

  • All user permissions
  • View all journal entries
  • Manage user accounts and roles

🔑 Environment Variables 🔒

You must set the following in a .env file before running the project:

MAIL_USERNAME=your_email@example.com
MAIL_PASSWORD=your_email_password
MONGO_USERNAME=your_mongo_username
MONGO_PASSWORD=your_mongo_password
MONGO_CLUSTER_HOST=your_mongo_cluster_host
MONGO_APP_NAME=Cluster1
  • MAIL_USERNAME → Your email for sending updates
  • MAIL_PASSWORD → Email password or App Password (for Gmail)
  • MONGO_USERNAME → MongoDB Atlas username
  • MONGO_PASSWORD → MongoDB Atlas password
  • MONGO_CLUSTER_HOST → MongoDB cluster host URL (without protocol)
  • MONGO_APP_NAME → Name of your MongoDB database/cluster

🧪 Testing

Static Code Analysis – SonarCloud

  • Tool: SonarCloud
  • Integrated with CI pipeline for quality checks
  • Detects code smells, bugs, and vulnerabilities before merge

API Testing – Postman

  • Positive and negative test scenarios
  • JWT authentication flows validated
  • Comprehensive Postman Collection covering all endpoints

📜 References


About

Secure Spring Boot backend for managing personal journals with JWT authentication, MongoDB, and Swagger API docs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages