Skip to content

Commit 41e3758

Browse files
authored
Initial commit
0 parents  commit 41e3758

File tree

314 files changed

+9613
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+9613
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.java]
10+
indent_size = 4
11+
indent_style = tab

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# See apps/main/resources/.env

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: 🐳 Start all the environment
18+
run: make start
19+
20+
- name: 🔦 Lint
21+
run: make lint
22+
23+
- name: 🦭 Wait for the environment to get up
24+
run: |
25+
while ! make ping-mysql &>/dev/null; do
26+
echo "Waiting for database connection..."
27+
sleep 2
28+
done
29+
30+
- name: ✅ Run the tests
31+
run: make test

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Gradle
2+
.gradle
3+
build/
4+
5+
# Ignore Gradle GUI config
6+
gradle-app.setting
7+
8+
/var/log/*
9+
!/var/log/.gitkeep
10+
11+
.env.local
12+
.env.*.local

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM openjdk:21-slim-buster
2+
WORKDIR /app
3+
4+
RUN apt update && apt install -y curl git
5+
6+
ENV NVM_DIR /usr/local/nvm
7+
ENV NODE_VERSION 18.0.0
8+
9+
RUN mkdir -p $NVM_DIR
10+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
11+
12+
RUN . $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm alias default $NODE_VERSION && nvm use default
13+
14+
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
15+
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
all: build
2+
3+
start:
4+
@docker compose -f docker-compose.ci.yml up -d
5+
6+
build:
7+
@./gradlew build --warning-mode all
8+
9+
lint:
10+
@docker exec codely-java_ddd_example-test_server ./gradlew spotlessCheck
11+
12+
run-tests:
13+
@./gradlew test --warning-mode all
14+
15+
test:
16+
@docker exec codely-java_ddd_example-test_server ./gradlew test --warning-mode all
17+
18+
run:
19+
@./gradlew :run
20+
21+
ping-mysql:
22+
@docker exec codely-java_ddd_example-mysql mysqladmin --user=root --password= --host "127.0.0.1" ping --silent
23+
24+
# Start the app
25+
start-mooc_backend:
26+
@./gradlew bootRun --args='mooc_backend server'
27+
28+
start-backoffice_frontend:
29+
@./gradlew bootRun --args='backoffice_frontend server'

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<p align="center">
2+
<a href="https://codely.com">
3+
<picture>
4+
<source media="(prefers-color-scheme: dark)" srcset="https://codely.com/logo/codely_logo-dark.svg">
5+
<source media="(prefers-color-scheme: light)" srcset="https://codely.com/logo/codely_logo-light.svg">
6+
<img alt="Codely logo" src="https://codely.com/logo/codely_logo.svg">
7+
</picture>
8+
</a>
9+
</p>
10+
11+
<h1 align="center">
12+
☕🚀 Java DDD example: Save the boilerplate in your new projects
13+
</h1>
14+
15+
<p align="center">
16+
<a href="https://github.com/CodelyTV"><img src="https://img.shields.io/badge/Codely-OS-green.svg?style=flat-square" alt="Codely Open Source projects"/></a>
17+
<a href="https://pro.codely.com"><img src="https://img.shields.io/badge/Codely-Pro-black.svg?style=flat-square" alt="Codely Pro courses"/></a>
18+
<a href="https://github.com/CodelyTV/java-ddd-example/actions"><img src="https://github.com/CodelyTV/java-ddd-example/workflows/CI/badge.svg" alt="CI pipeline status"></a>
19+
</p>
20+
21+
> ⚡ Start your Java projects as fast as possible
22+
23+
## ℹ️ Introduction
24+
25+
This is a repository intended to serve as a starting point if you want to bootstrap a Java project with JUnit and Gradle.
26+
27+
Here you have the [course on CodelyTV Pro where we explain step by step all this](https://pro.codely.tv/library/ddd-en-java/about/?utm_source=github&utm_medium=social&utm_campaign=readme) (Spanish)
28+
29+
## 🏁 How To Start
30+
31+
1. Install Java 11: `brew cask install corretto`
32+
2. Set it as your default JVM: `export JAVA_HOME='/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home'`
33+
3. Clone this repository: `git clone https://github.com/CodelyTV/java-ddd-example`.
34+
4. Bring up the Docker environment: `make up`.
35+
5. Execute some [Gradle lifecycle tasks](https://docs.gradle.org/current/userguide/java_plugin.html#lifecycle_tasks) in order to check everything is OK:
36+
1. Create [the project JAR](https://docs.gradle.org/current/userguide/java_plugin.html#sec:jar): `make build`
37+
2. Run the tests and plugins verification tasks: `make test`
38+
6. Start developing!
39+
40+
## ☝️ How to update dependencies
41+
42+
* Gradle ([releases](https://gradle.org/releases/)): `./gradlew wrapper --gradle-version=WANTED_VERSION --distribution-type=bin`
43+
44+
## 💡 Related repositories
45+
46+
### ☕ Java
47+
48+
* 📂 [Java Basic example](https://github.com/CodelyTV/java-basic-example)
49+
*[Java OOP Examples](https://github.com/CodelyTV/java-oop-examples)
50+
* 🧱 [Java SOLID Examples](https://github.com/CodelyTV/java-solid-examples)
51+
* 🥦 [Java DDD Example](https://github.com/CodelyTV/java-ddd-example)
52+
53+
### 🐘 PHP
54+
55+
* 📂 [PHP Basic example](https://github.com/CodelyTV/php-basic-example)
56+
* 🎩 [PHP DDD example](https://github.com/CodelyTV/php-ddd-example)
57+
* 🥦 [PHP DDD Example](https://github.com/CodelyTV/php-ddd-example)
58+
59+
### 🧬 Scala
60+
61+
* 📂 [Scala Basic example](https://github.com/CodelyTV/scala-basic-example)
62+
*[Scala Basic example (g8 template)](https://github.com/CodelyTV/scala-basic-example.g8)
63+
*[Scala Examples](https://github.com/CodelyTV/scala-examples)
64+
* 🥦 [Scala DDD Example](https://github.com/CodelyTV/scala-ddd-example)

apps/main/resources/.env

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# MOOC #
2+
#--------------------------------#
3+
MOOC_BACKEND_SERVER_PORT=8030
4+
# MySql
5+
MOOC_DATABASE_HOST=codely-java_ddd_example-mysql
6+
MOOC_DATABASE_PORT=3306
7+
MOOC_DATABASE_NAME=mooc
8+
MOOC_DATABASE_USER=root
9+
MOOC_DATABASE_PASSWORD=
10+
11+
# BACKOFFICE #
12+
#--------------------------------#
13+
BACKOFFICE_BACKEND_SERVER_PORT=8040
14+
BACKOFFICE_FRONTEND_SERVER_PORT=8041
15+
# MySql
16+
BACKOFFICE_DATABASE_HOST=codely-java_ddd_example-mysql
17+
BACKOFFICE_DATABASE_PORT=3306
18+
BACKOFFICE_DATABASE_NAME=backoffice
19+
BACKOFFICE_DATABASE_USER=root
20+
BACKOFFICE_DATABASE_PASSWORD=
21+
# Elasticsearch
22+
BACKOFFICE_ELASTICSEARCH_HOST=codely-java_ddd_example-elasticsearch
23+
BACKOFFICE_ELASTICSEARCH_PORT=9200
24+
BACKOFFICE_ELASTICSEARCH_INDEX_PREFIX=backoffice
25+
26+
# COMMON #
27+
#--------------------------------#
28+
# RabbitMQ
29+
RABBITMQ_HOST=codely-java_ddd_example-rabbitmq
30+
RABBITMQ_PORT=5672
31+
RABBITMQ_LOGIN=codely
32+
RABBITMQ_PASSWORD=c0d3ly
33+
RABBITMQ_EXCHANGE=domain_events
34+
RABBITMQ_MAX_RETRIES=5
4.09 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<#import "spring.ftl" as spring />
2+
3+
<!doctype html>
4+
<html lang="en">
5+
<head>
6+
<meta charset="UTF-8">
7+
<meta name="viewport"
8+
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
10+
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
11+
12+
<title>${title}</title>
13+
<title>${description}</title>
14+
</head>
15+
<body>
16+
<#include "partials/header.ftl">
17+
18+
<div class="container mx-auto px-4 p-5">
19+
<h1 class="font-sans text-gray-800 text-center text-5xl mb-10"><@page_title/></h1>
20+
<@main/>
21+
</div>
22+
23+
<div class="clearfix"></div>
24+
25+
<#include "partials/footer.ftl">
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)