-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9b6ca4a
Showing
130 changed files
with
3,739 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*.bat | ||
*.dockerignore | ||
*.editorconfig | ||
*.gitattributes | ||
*.gitignore | ||
*.iml | ||
*.md | ||
*.yml | ||
.git/ | ||
.github/ | ||
.idea/ | ||
.vscode/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
# docker compose up --detach --build --force-recreate --remove-orphans | ||
|
||
name: java | ||
services: | ||
application: | ||
image: application | ||
container_name: application | ||
depends_on: | ||
- elk-elasticsearch | ||
- elk-kibana | ||
- kafka | ||
- localstack | ||
- mongo | ||
- postgres | ||
build: | ||
context: .. | ||
dockerfile: .docker/dockerfile | ||
ports: | ||
- "8090:8080" | ||
environment: | ||
SPRING_PROFILES_ACTIVE: local | ||
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/database | ||
SPRING_DATASOURCE_USERNAME: admin | ||
SPRING_DATASOURCE_PASSWORD: password | ||
SPRING_DATA_MONGODB_URI: mongodb://admin:password@mongo:27017/database?authSource=admin | ||
SPRING_KAFKA: kafka:9094 | ||
AWS_ENDPOINT: http://localstack:4566 | ||
AWS_REGION: us-east-1 | ||
AWS_ACCESS_KEY_ID: test | ||
AWS_SECRET_ACCESS_KEY: test | ||
SPRING_CLOUD_AWS_S3_BUCKET: bucket | ||
SPRING_CLOUD_AWS_SQS_QUEUE: queue | ||
elk-elasticsearch: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.2 | ||
container_name: elk-elasticsearch | ||
ports: | ||
- "9200:9200" | ||
- "9300:9300" | ||
volumes: | ||
- elk-elasticsearch:/usr/share/elasticsearch/data | ||
environment: | ||
discovery.type: single-node | ||
xpack.security.enabled: false | ||
xpack.security.enrollment.enabled: false | ||
ES_JAVA_OPTS: -Xms512m -Xmx512m | ||
elk-kibana: | ||
image: docker.elastic.co/kibana/kibana:8.15.2 | ||
container_name: elk-kibana | ||
depends_on: | ||
- elk-elasticsearch | ||
ports: | ||
- "5601:5601" | ||
environment: | ||
ELASTICSEARCH_URL: http://elk-elasticsearch:9200 | ||
ELASTICSEARCH_HOSTS: http://elk-elasticsearch:9200 | ||
kafka: | ||
image: bitnami/kafka | ||
container_name: kafka | ||
ports: | ||
- "9092:9092" | ||
- "9094:9094" | ||
environment: | ||
KAFKA_KRAFT_CLUSTER_ID: 0 | ||
KAFKA_CFG_NODE_ID: 0 | ||
KAFKA_CFG_PROCESS_ROLES: controller,broker | ||
KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true | ||
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093 | ||
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER | ||
KAFKA_CFG_LISTENERS: CONTROLLER://:9093,PLAINTEXT://:9094,EXTERNAL://:9092 | ||
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9094,EXTERNAL://localhost:9092 | ||
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT | ||
kafka-admin: | ||
image: obsidiandynamics/kafdrop | ||
container_name: kafka-admin | ||
depends_on: | ||
- kafka | ||
ports: | ||
- "9000:9000" | ||
environment: | ||
KAFKA_BROKERCONNECT: kafka:9094 | ||
localstack: | ||
image: localstack/localstack | ||
container_name: localstack | ||
ports: | ||
- "4566:4566" | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ./localstack.sh:/etc/localstack/init/ready.d/localstack.sh | ||
environment: | ||
- SERVICES=sqs,sqs-query,s3 | ||
mongo: | ||
image: mongo | ||
container_name: mongo | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- mongo:/data/db | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: admin | ||
MONGO_INITDB_ROOT_PASSWORD: password | ||
mongo-admin: | ||
image: mongo-express | ||
container_name: mongo-admin | ||
depends_on: | ||
- mongo | ||
ports: | ||
- "27018:8081" | ||
environment: | ||
ME_CONFIG_MONGODB_URL: mongodb://admin:password@mongo:27017 | ||
ME_CONFIG_MONGODB_ADMINUSERNAME: admin | ||
ME_CONFIG_MONGODB_ADMINPASSWORD: password | ||
ME_CONFIG_BASICAUTH: false | ||
postgres: | ||
image: postgres | ||
container_name: postgres | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- postgres:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_DB: database | ||
POSTGRES_USER: admin | ||
POSTGRES_PASSWORD: password | ||
postgres-admin: | ||
image: dpage/pgadmin4 | ||
container_name: postgres-admin | ||
depends_on: | ||
- postgres | ||
ports: | ||
- "5433:80" | ||
volumes: | ||
- ./servers.json:/pgadmin4/servers.json | ||
- postgres-admin:/var/lib/pgadmin | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: [email protected] | ||
PGADMIN_DEFAULT_PASSWORD: password | ||
PGADMIN_CONFIG_SERVER_MODE: "False" | ||
PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED: "False" | ||
volumes: | ||
elk-elasticsearch: | ||
mongo: | ||
postgres: | ||
postgres-admin: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM eclipse-temurin:23-jdk-alpine AS build | ||
RUN apk add --no-cache maven | ||
WORKDIR /source | ||
COPY source/pom.xml . | ||
RUN mvn dependency:go-offline | ||
COPY source . | ||
RUN mvn clean package -DskipTests | ||
|
||
FROM eclipse-temurin:23-jre-alpine | ||
WORKDIR /app | ||
COPY --from=build /source/target/*.jar app.jar | ||
EXPOSE 8090 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
localstack status services | ||
awslocal sqs create-queue --queue-name queue | ||
awslocal s3 mb s3://bucket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Servers": { | ||
"Database": { | ||
"Group": "Servers", | ||
"Name": "Docker", | ||
"Host": "postgres", | ||
"Port": 5432, | ||
"MaintenanceDB": "postgres", | ||
"Username": "admin", | ||
"Password": "password", | ||
"SSLMode": "prefer", | ||
"Favorite": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 500 | ||
tab_width = 4 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
*.java diff=java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: build | ||
on: | ||
push: | ||
branches: [main] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Java Setup | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 23 | ||
distribution: temurin | ||
cache: maven | ||
|
||
- name: Java Publish | ||
run: mvn -B clean package --file source/pom.xml | ||
|
||
- name: Artifact Upload | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: app | ||
path: source/target/*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.bat | ||
*.iml | ||
.idea | ||
.vscode | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# JAVA | ||
|
||
![](https://github.com/rafaelfgx/Java/actions/workflows/build.yaml/badge.svg) | ||
|
||
API using Java, Spring Boot, Docker, Testcontainers, PostgreSQL, MongoDB, Kafka, LocalStack, SQS, S3, JWT, Swagger. | ||
|
||
## TECHNOLOGIES | ||
|
||
* [Java](https://dev.java) | ||
* [Spring Boot](https://spring.io/projects/spring-boot) | ||
* [Docker](https://www.docker.com/get-started) | ||
* [Testcontainers](https://testcontainers.com) | ||
* [PostgreSQL](https://www.postgresql.org/) | ||
* [MongoDB](https://www.mongodb.com/docs/manual) | ||
* [Kafka](https://kafka.apache.org) | ||
* [LocalStack](https://localstack.cloud) | ||
* [AWS SQS](https://aws.amazon.com/sqs) | ||
* [AWS S3](https://aws.amazon.com/s3) | ||
* [JWT](https://jwt.io) | ||
* [Swagger](https://swagger.io) | ||
|
||
## RUN | ||
|
||
<details> | ||
<summary>IntelliJ IDEA</summary> | ||
|
||
#### Prerequisites | ||
|
||
* [Docker](https://www.docker.com/get-started) | ||
* [Java JDK](https://www.oracle.com/java/technologies/downloads) | ||
* [IntelliJ IDEA](https://www.jetbrains.com/idea/download) | ||
|
||
#### Steps | ||
|
||
1. Execute **docker compose up --detach --build --force-recreate --remove-orphans** in **docker** directory. | ||
2. Open **source** directory in **IntelliJ IDEA**. | ||
3. Select **Application.java** class. | ||
4. Click **Run** or **Debug**. | ||
5. Open <http://localhost:8080>. | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>Docker</summary> | ||
|
||
#### Prerequisites | ||
|
||
* [Docker](https://www.docker.com/get-started) | ||
|
||
#### Steps | ||
|
||
1. Execute **docker compose up --detach --build --force-recreate --remove-orphans** in **docker** directory. | ||
2. Open <http://localhost:8090>. | ||
|
||
</details> | ||
|
||
## EXAMPLES | ||
|
||
* **AWS:** Amazon Web Services [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/aws) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/aws) | ||
* **Auth:** Authentication and Authorization [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/auth) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/auth) | ||
* **Category:** Cache [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/category) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/category) | ||
* **Game:** Mocks [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/game) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/game) | ||
* **Group:** Groups [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/group) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/group) | ||
* **Invoice:** PostgreSQL [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/invoice) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/invoice) | ||
* **Location:** Flat Object to Nested Object [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/location) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/location) | ||
* **Notification:** Kafka [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/notification) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/notification) | ||
* **Payment:** Strategy Pattern [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/payment) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/payment) | ||
* **Product:** MongoDB [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/product) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/product) | ||
* **User:** Business Rules [Main](https://github.com/rafaelfgx/Java/tree/main/source/src/main/java/com/company/architecture/user) | [Tests](https://github.com/rafaelfgx/Java/tree/main/source/src/test/java/com/company/architecture/user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration name="Application" type="Application" factoryName="Application" nameIsGenerated="true"> | ||
<module name="architecture"/> | ||
<option name="MAIN_CLASS_NAME" value="com.company.architecture.Application"/> | ||
<option name="WORKING_DIRECTORY" value="$MODULE_WORKING_DIR$"/> | ||
<envs> | ||
<env name="SPRING_PROFILES_ACTIVE" value="local" /> | ||
<env name="AWS_ENDPOINT" value="http://localhost:4566" /> | ||
<env name="AWS_REGION" value="us-east-1" /> | ||
<env name="AWS_ACCESS_KEY_ID" value="test" /> | ||
<env name="AWS_SECRET_ACCESS_KEY" value="test" /> | ||
</envs> | ||
<method v="2"> | ||
<option name="Make" enabled="true"/> | ||
</method> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration name="Tests" type="JUnit" factoryName="JUnit"> | ||
<module name="architecture"/> | ||
<method v="2"> | ||
<option name="Make" enabled="true"/> | ||
</method> | ||
<option name="TEST_OBJECT" value="package"/> | ||
<option name="TEST_SEARCH_SCOPE"> | ||
<value defaultName="wholeProject"/> | ||
</option> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
Oops, something went wrong.