Skip to content

Zubayear/hamlet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hexagonal Architecture Template

πŸ“Œ Overview

This repository is a Kotlin + Spring Boot backend template built using Hexagonal Architecture (Ports & Adapters).

It is designed to be used as a GitHub Template, so you can quickly bootstrap new backend services with a clean, scalable structure.


πŸš€ Getting Started (Using This Template)

1. Create a New Repository

Click "Use this template" on GitHub and create your new project.


2. Run Setup Script

After cloning your new repository:

chmod +x scripts/setup.sh
./scripts/setup.sh

3. Provide Required Inputs

The script will ask for:

  • Project name (e.g. order-service)
  • Base package (e.g. com.yourcompany.orderservice)

4. What the Script Does

βœ… Renames:

  • Project (hamlet β†’ your project name)

βœ… Updates:

  • pom.xml (artifactId, name)
  • README.md
  • Kotlin package declarations

βœ… Refactors:

  • Package structure (com.lucienvirecourt.hamlet β†’ your package)

βœ… Cleans:

  • Removes template setup script after execution

5. Next Steps

./mvnw clean install -DskipTests -U
docker-compose -f bootstrap/src/main/resources/docker/docker-compose.dev.yml up
./mvnw spring-boot:run -pl bootstrap

🧱 Architecture

This project follows Hexagonal Architecture:

          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚        Adapter           β”‚
          β”‚ (GraphQL / REST / JPA)   β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚      Application         β”‚
          β”‚   (Use Cases / Ports)    β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚        Domain            β”‚
          β”‚   (Pure Business Logic)  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‚ Modules

model (Domain Layer)

  • Core business models
  • Framework-independent

application (Use Cases)

  • Business logic

  • Ports:

    • port.in (use cases)
    • port.out (interfaces)

adapter (Infrastructure)

  • Inbound:

    • GraphQL
    • REST
  • Outbound:

    • JPA (database)

bootstrap (Entry Point)

  • Spring Boot startup
  • Configuration
  • Flyway migrations
  • Docker setup

πŸ”„ Example Flow

Create User:

  1. Request β†’ GraphQL/REST (adapter)
  2. β†’ CreateUserUseCase
  3. β†’ CreateUserService
  4. β†’ UserRepository
  5. β†’ JPA Adapter
  6. β†’ Response

πŸ—ƒοΈ Database & Migrations

Uses Flyway.

Location:

bootstrap/src/main/resources/db.migration

🐳 Running Locally

Start Database

docker-compose -f bootstrap/src/main/resources/docker/docker-compose.dev.yml up

Run Application

./mvnw spring-boot:run -pl bootstrap

βš™οΈ Configuration

Profiles:

  • dev
  • staging
  • prod

Files:

application.yml
application-dev.yml
application-staging.yml
application-prod.yml

πŸ§ͺ Testing

./mvnw test

🎯 Why This Template?

  • βœ… Clean Architecture (Hexagonal)
  • βœ… Scalable for microservices
  • βœ… Framework-independent domain
  • βœ… Easy to test
  • βœ… Ready-to-use Flyway + Docker setup

πŸ› οΈ Customization Notes

  • Default package:

    com.lucienvirecourt.hamlet
    
  • This will be replaced by the setup script


⚠️ Notes

  • macOS & Linux are supported
  • If script fails, check sed compatibility
  • Always review changes before committing

πŸš€ Future Improvements

  • GitHub Actions CI
  • Authentication module
  • Observability (metrics + logging)
  • Event-driven support

πŸ‘¨β€πŸ’» Author

Template built for scalable backend systems using Kotlin & Spring Boot.

About

Hexagonal architecture bootstrapping template

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors