https://github.com/hmaach/lets-play
Let's Play is a basic CRUD API using Spring Boot with MongoDB to manage users and products
https://github.com/hmaach/lets-play
api java mongodb spring-boot
Last synced: 2 months ago
JSON representation
Let's Play is a basic CRUD API using Spring Boot with MongoDB to manage users and products
- Host: GitHub
- URL: https://github.com/hmaach/lets-play
- Owner: hmaach
- Created: 2025-08-16T10:54:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2026-01-16T16:09:07.000Z (6 months ago)
- Last Synced: 2026-01-17T05:12:58.444Z (6 months ago)
- Topics: api, java, mongodb, spring-boot
- Language: Java
- Homepage:
- Size: 105 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Roadmap: docs/roadmap.md
Awesome Lists containing this project
README
# 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
```text
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
```mermaid
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
```
---
## Getting Started
### 1. Clone the Repo
```bash
git clone https://github.com/hmaach/lets-play.git
cd lets-play
```
### 2. Set Up Environment
```bash
cp .env-example .env
```
Update `.env` with your MongoDB credentials:
```env
# 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
```bash
source ./setup.sh
```
This will:
* Install Docker rootless if missing
* Create Docker volume for persistent data
### 4. Connect to MongoDB
```bash
mongosh "mongodb://@username:password@localhost:27017/letsplay?authSource=admin"
```
### 5. Stop MongoDB
```bash
docker compose down
```
---
## Requirements
* Java 17+
* Maven
* MongoDB (Dockerized)
* Docker (Rootless compatible)
* Docker Compose v2
* `mongosh` (optional, for testing)
* Angular (for frontend integration)