Skip to content

Latest commit

Β 

History

92 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Kavun Logo

Kavun🍈

Welcome to the Kavun project! It is a modern, opinionated, and production-ready starter for Spring Boot projects. It is designed to help developers get started with Spring Boot projects quickly and efficiently. The project includes a wide range of features and tools to help developers build robust and scalable applications. It is built using the latest technologies and best practices to ensure high performance, security, and maintainability.

Meaning of Kavun

It is a melon in Turkish. It is a sweet and juicy fruit that is popular in Turkey and other countries. It is known for its refreshing taste and high nutritional value. The name Kavun is chosen to represent the project's goal of providing a fresh, modern, and healthy start for developers working on Spring Boot projects.

Table of Contents

Built With

Key Features

Development Guide

1. Prerequisites

You can use any IDE of your choice. However, VSCode is recommended for this project. Before running the project, make sure the correct Java version is installed. You can check the Java version using the following command:

java -version

2. Installation

# Move to your workspace
cd <your-workspace>

# Clone this project into your workspace
git clone <repository-url>

# Move to the project root directory
cd backend

# Open the project in your favorite IDE
code . # For Visual Studio Code
idea . # For IntelliJ IDEA

3. Project Setup

# Start required services using Docker Compose
docker-compose up -d

# Run the application using Gradle (Windows / Linux / MacOS)
./gradlew bootRun

# Access the application on http://localhost:8080/
curl http://localhost:8080/
  • Alternatively, you can use the following commands for project setup:
# Run the application
./gradlew bootRun

# Run unit tests
./gradlew test

# Run integration tests
./gradlew integrationTest

# Run all tests
./gradlew testAll

# Rebuild the project
./gradlew clean build

# Run the project continuously (Hot Reload)
./gradlew bootRun --continuous --quiet
./gradlew bootRun -t

# Refresh Gradle Project (If you see "The import XXX cannot be resolved" error)
./gradlew --refresh-dependencies

# Run owasp dependency check
./gradlew dependencyCheckAnalyze --info

# When you add a new dependency, run the following command to refresh the dependencies
./gradlew build --refresh-dependencies

# Refresh dependencies
./gradlew clean build --refresh-dependencies

# Refresh dependencies without tests
./gradlew clean build --refresh-dependencies -x test -x integrationTest
  • Note: Before running the project, make sure to all the dependencies are installed and the project and connected to the databases.

4. Environment Variables

The following environment variables can be customized as necessary:

# Application Configuration
admin.username=${ADMIN_USERNAME:admin}
admin.password=${ADMIN_PASSWORD:password}
admin.email=${ADMIN_EMAIL:admin@kavun.com}
access-token-expiration-in-minutes=${ACCESS_TOKEN_EXPIRATION_IN_MINUTES:60}
login.otp.enabled=${LOGIN_OTP_ENABLED:false}
login.captcha.enabled=${LOGIN_CAPTCHA_ENABLED:false}
app.test-otp-code=${APP_TEST_OTP_CODE:190303}

# AWS S3 Configuration
aws.region=${AWS_REGION:us-east-1}
aws.accessKeyId=${AWS_ACCESS_KEY_ID}
aws.secretAccessKey=${AWS_SECRET_ACCESS_KEY}
aws.s3BucketName=${AWS_S3_BUCKET_NAME:spring-boot-starter}
aws.servicePort=${AWS_SERVICE_PORT:8001}
aws.serviceEndpoint=${AWS_SERVICE_ENDPOINT:http://localhost:${aws.servicePort}}

# Mail Configuration
spring.mail.host=${MAIL_HOST:localhost}
spring.mail.port=${MAIL_PORT:465}
spring.mail.username=${MAIL_USERNAME:noreply@kavun.com}
spring.mail.password=${MAIL_PASSWORD:yourpassword}
spring.mail.protocol=smtp
  • The profiles defined in the application are development, docker, test, and production.
  • By default, the application runs with the development profile.

5. Accessing the Application

H2 Database

If you are not using DBeaver or any other database client, you can access the H2 database using the following steps:

# Open your web browser and go to http://localhost:8080/console

# The H2 database can be accessed using the following credentials:
- Saved Settings: Generic PostgreSQL
- Driver Class: Generic PostgreSQL
- JDBC URL: jdbc:postgresql://localhost:5432/kavun
- User Name: postgres
- Password: postgres

# Click on the Connect button to access the database.

This configuration is used to connect to the H2 database. You can access .properties file to change the database configuration. The H2 database is only used for development and testing purposes. For production, the application uses the PostgreSQL database.

Docker

The application can be run on Docker using the following steps:

# Build the Docker image
docker build -t kavun-backend .

# Run the Docker container
docker-compose up -d
docker run -d -p 8080:8080 --name kavun-backend-container kavun-backend # If not using docker-compose

# Stop the Docker container
docker-compose down
docker stop kavun-backend-container && docker rm kavun-backend-container # If not using docker-compose

# Remove the Docker image
docker-compose down --rmi all
docker rmi kavun-backend # Be sure to stop and remove the container before removing the image

# Delete the Postgres data volume
docker volume rm <volume-name>

Grafana

The application uses Grafana for monitoring and visualization.

# Access Grafana Dashboard on http://localhost:3000/

# Default Grafana Credentials:
- Username: admin
- Password: admin

Architecture

The project is structured in a layered architecture with the following layers:

.
β”œβ”€β”€ config                            # Can hold project level configurations like pmd, checkstyle, etc.
β”œβ”€β”€ docs                              # Holds project documentations. Markdown sections, etc.
β”‚   └── images
β”œβ”€β”€ libs                              # Holds special libraries used by the application.
β”‚   └── newrelic
└── src
    β”œβ”€β”€ integrationTest               # Integration test suites separated from unit tests.
    β”‚   β”œβ”€β”€ java
    β”‚   β”‚   └── com
    β”‚   β”‚       └── kavun
    β”‚   β”‚           β”œβ”€β”€ backend
    β”‚   β”‚           β”œβ”€β”€ task
    β”‚   β”‚           └── web
    β”‚   └── resources
    β”œβ”€β”€ main
    β”‚   β”œβ”€β”€ java
    β”‚   β”‚   └── com
    β”‚   β”‚       └── kavun
    β”‚   β”‚           β”œβ”€β”€ annotation     # All custom annotations used in the application
    β”‚   β”‚           β”œβ”€β”€ backend        # Business Logic and Data Access implementation
    β”‚   β”‚           β”œβ”€β”€ config         # Configuration classes and properties
    β”‚   β”‚           β”œβ”€β”€ constant       # Constants used in the application
    β”‚   β”‚           β”œβ”€β”€ enums          # Enums used in the application
    β”‚   β”‚           β”œβ”€β”€ exception      # Custom exceptions used in the application
    β”‚   β”‚           β”œβ”€β”€ shared         # Resources like dto, utils, etc. used in the application
    β”‚   β”‚           β”œβ”€β”€ task           # Scheduled tasks and cron jobs used in the application
    β”‚   β”‚           └── web            # Web layer implementation
    β”‚   β”œβ”€β”€ resources
    β”‚   β”‚   β”œβ”€β”€ i18n                   # I18n property files, comes with 'en', 'fr', 'es' and 'zn_CN'
    β”‚   β”‚   β”œβ”€β”€ static
    β”‚   β”‚   β”‚   β”œβ”€β”€ css
    β”‚   β”‚   β”‚   β”œβ”€β”€ fonts
    β”‚   β”‚   β”‚   β”œβ”€β”€ images
    β”‚   β”‚   β”‚   └── js
    β”‚   β”‚   β”‚       └── form-validation
    β”‚   β”‚   └── templates
    β”‚   β”‚       β”œβ”€β”€ common
    β”‚   β”‚       β”‚   └── email
    β”‚   β”‚       β”œβ”€β”€ email
    β”‚   β”‚       β”œβ”€β”€ error
    β”‚   β”‚       └── user
    β”‚   └── scripts                     # Scripts used in the application as part of docker build, etc.
    └── test
        β”œβ”€β”€ java
        β”‚   └── com
        β”‚       └── kavun
        β”‚           β”œβ”€β”€ backend
        β”‚           β”œβ”€β”€ config
        β”‚           β”œβ”€β”€ shared
        β”‚           └── web
        └── resources

Database Schema

img.png

Note: In Permission entity, the entityId field represents the ID of either a Role or a User, depending on the EntityType. This design allows for flexible permission assignments, enabling both role-based and user-specific permissions within the system.

Roadmap

Please refer to the Roadmap for the project roadmap and future plans.

Contributing

In the Kavun project, we follow a structured development workflow to ensure efficient collaboration and code management. This workflow includes the following key components: branching strategy, versioning, and commit message conventions. By following these guidelines, we aim to maintain a clean and organized codebase that is easy to manage and contribute to. For more information, please refer to the Contributing Guide document.

Contact

Thanks to the following people who have contributed to this project:

About

Template for Spring Boot projects, designed to be production-ready and efficient 🍈

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

16 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages