Skip to content

hmaach/lets-play

Repository files navigation

LET'S PLAY

A Java backend project using Hexagonal Architecture, integrated with MongoDB, and containerized using Docker. Follows clean architecture principles with clear separation of concerns between domain logic, application logic, and infrastructure.


Project Structure

src/main/java/com/letsplay/
├── LetsPlayApplication.java
├── domain/            # Core business logic
│   ├── model/
│   ├── port/
│   │   ├── in/       # Input ports (use cases)
│   │   └── out/      # Output ports (interfaces)
│   └── service/      # Domain services
├── infrastructure/   # External concerns
│   ├── config/
│   ├── persistence/  # Database adapters
│   └── security/
└── application/      # Application layer
    ├── controller/   # REST controllers
    ├── dto/          # Request & Response DTOs
    └── exception/    # Global exception handling

Other files:
├── .env-example      # Example environment variables
├── compose.yaml      # Docker Compose config
├── pom.xml           # Maven config
└── setup.sh          # Setup environment script

Endpoints

Method Endpoint Auth Roles Description
POST /auth/register - Register a new user
POST /auth/login - User login
GET /users Admin List all users
GET /users/{id} Admin/User Get user by ID
GET /users/me Any Get current user profile
POST /users Admin Create user
PATCH /users/{id} Admin/User Update user details
DELETE /users/{id} Admin/User Delete user
GET /products - List all products
GET /products/{id} - Get product by ID
POST /products Admin Create a product
PATCH /products/{id} Admin Update product
DELETE /products/{id} Admin Delete product

Database Design

classDiagram
User "1" -- "n" Product : Owns
User : +String id
User : +String name
User : +String email
User : +String password
User : +String role
Product : +String id
Product : +String name
Product : +String description
Product : +Double price
Product : +String userId
Loading

Getting Started

1. Clone the Repo

git clone https://github.com/hmaach/lets-play.git
cd lets-play

2. Set Up Environment

cp .env-example .env

Update .env with your MongoDB credentials:

# Database config
MONGO_INITDB_ROOT_USERNAME=username
MONGO_INITDB_ROOT_PASSWORD=password
MONGO_INITDB_DATABASE=lets-play-db

# JWT config
JWT_SECRET=secret-key

# SSL config
CERT_PASSWORD=password
CERT_ALIAS=letsplay
CERT_DNAME=CN=localhost,OU=Dev,O=LetsPlay,L=Oujda,ST=Oriental,C=MA

3. Setup Environment

source ./setup.sh

This will:

  • Install Docker rootless if missing
  • Create Docker volume for persistent data

4. Connect to MongoDB

mongosh "mongodb://localhost:27017"

5. Stop MongoDB

docker compose down

Requirements

  • Java 17+
  • Maven
  • MongoDB (Dockerized)
  • Docker (Rootless compatible)
  • Docker Compose v2
  • mongosh (optional, for testing)
  • Angular (for frontend integration)

About

Let's Play is a basic CRUD API using Spring Boot with MongoDB to manage users and products

Topics

Resources

Stars

Watchers

Forks