Welcome to the repository for "Software Architecture with Spring 6"! This book is a practical guide for software engineers, architects, and developers looking to master modern software architecture principles, especially in the context of Java and Spring Framework.
This book explores the journey of building robust, scalable, and maintainable applications using a structured approach. It covers a wide range of architectural styles and design principles, equipping readers with insights and strategies for architecting resilient systems. From monolithic applications to microservices, this guide walks through key concepts and provides actionable examples to enhance your software architecture skills.
The book provides sample code for each major chapter, allowing readers to experiment and implement concepts in real-world scenarios. Please check each chapter's directory for related code snippets and explanations.
-
The examples provided delve into fundamental architectural concepts, such as high and low coupling, cohesion, and the SOLID principles.
- ch1:
- 01-high-coupling-shopping-application
- 02-low-coupling-shopping-application
- 03-low-cohesion-usermanagement-application
- 04-high-cohesion-usermanagement-application
- 05-solid-srp-library-application
- 06-open-closed-library-application
- 07-liskov-substitution-library-application
- 08-interface-segregation-library-application
- 09-dependency-inversion-library-application
- ch1:
-
- ch4:
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- .env -> PostgreSQL credentials
- docker-compose.yml -> Run an image of PostgreSQL and populate it with data.
- postgresql/
- onlineauction/
- docker/
- Java 21 - Docker and Docker Compose - Maven 3.9.9
- Go the docker ch4/docker folder
- Execute the command:
docker-compose up -d
- Go to the project's folder: onlineauction
- Execute the command:
mvn clean package
- To run the project execute the command:
mvn spring-boot:run
- To connect to the PostgreSQL:
- Url: jdbc:postgresql://localhost:5432/auction_db
- User: auction_app
- Password: auction123
- Database: auction_db
- Access the URL at http://localhost:8080
- Click at login menu
- Enter with the credencial:
- Administrator
- Username: admin
- Password: test123
- User
- Username: user
- Password: test123
- Administrator
- ch4:
-
- ch5:
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- .env -> PostgreSQL credentials
- docker-compose.yml -> Run an image of PostgreSQL and populate it with data.
- postgresql/
- onlineauction/ -> Server application
- onlineauction-client-mobile -> Mobile application (Client)
- onlineauction-client-web -> Web application (Client)
- docker/
- Java 21 - Docker and Docker Compose - Maven 3.9.9 - Node.js and npm - React - React Native - Expo Go App
- Go the docker ch5/docker folder
- Execute the command:
docker-compose up -d
- Go to the project's folder: onlineauction
- Execute the command:
mvn clean package
- To run the project execute the command:
mvn spring-boot:run
- To connect to the PostgreSQL:
- Url: jdbc:postgresql://localhost:5432/auction_db
- User: auction_app
- Password: auction123
- Database: auction_db
- OpenAPI documentation can be accessed at http://localhost:8080/swagger-ui/index.html.
- Go to the project's folder: onlineauctiononlineauction-client-web
- Execute the command:
npm install
- Execute the command:
npm start
- Access the URL at http://localhost:3000/
- Enter with the credencial:
- Administrator
- Username: admin
- Password: test123
- User
- Username: user
- Password: test123
- Administrator
- Go to the project's folder: onlineauctiononlineauction-client-mobile
- Execute the command:
npm install -g expo-cli
- Execute the command:
npm install
- Execute the command:
expo doctor --fix-dependencies
- Execute the command:
npx expo-doctor
- Execute the command:
npx expo install --check
- Execute the command:
npm install expo@latest
- Execute the command:
npx expo install @expo/metro-runtime
- Execute the command:
npx expo start
- To see the application in the web browser, press w
- To see the application on the Expo Go app, install Expo Go on your mobile device and scan the QR code.
- Enter with the credencial:
- Administrator
- Username: admin
- Password: test123
- User
- Username: user
- Password: test123
- Administrator
PS: Some commands may not be necessary, but following these steps will allow you to run the application and view it through Expo Go. You may update the dependencies with the command
expo install <dependency>
. In this case, nothing is better than asking our friend to chat GTP or something else to provide us with the command. ;) - ch5:
-
- ch6:
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- postman
- ch6.postman_collection.json -> Postman collection for chapter 6 to request the services.
- authentication-services -> Code to authentication services.
- user-services -> Code to authentication services.
- product-services -> Code to authentication services.
- docker/
- Java 21 - Docker and Docker Compose - Maven 3.9.9
- Go the docker ch6/docker folder
- Execute the command:
docker-compose up -d
- Go to the project's folder: postman and import the collection
- Now, execute the request for the desired service.
- To connect to the PostgreSQL:
- Url user database: jdbc:postgresql://localhost:5432/user_db
- Url product database: jdbc:postgresql://localhost:5432/product_db
- User: auction_app
- Password: auction123
- To connect to the MongoDB: mongodb://auction_app:auction123@localhost:27017/
authentication_db?authSource=admin
- User: auction_app
- Password: auction123
- Go the docker ch6/docker-resources folder
- Execute the command:
docker-compose up -d
- Open the microservices into your favorite IDE
- For each microservices execute the command:
mvn clean package
and thenmvn spring-boot:run
- Go to the project's folder: postman and import the collection
- Now, execute the request for the desired service.
- To connect to the PostgreSQL:
- Url user database: jdbc:postgresql://localhost:5432/user_db
- Url product database: jdbc:postgresql://localhost:5432/product_db
- User: auction_app
- Password: auction123
- To connect to the MongoDB: mongodb://auction_app:auction123@localhost:27017/
authentication_db?authSource=admin
- User: auction_app
- Password: auction123
- ch6:
-
Run the services in the order they appear for each folder. Generally, it is :
- configuration-services
- service-discovery-services
- gateway-services
- Other services such as authentication, user, and product services.
Please wait up to 30 seconds after starting the services before making requests. Eureka requires this time to register all services and synchronize its registry due to default heartbeat and cache update intervals. Reducing this delay is possible but expected in the default configuration.
- ch7:
-
- 01-Service-Discovery/
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- service-discovery-services -> Service discovery (Eureka Server) code.
- authentication-services -> Authentication services code.
- user-services -> User services code.
- product-services -> Product services code.
- docker/
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- 01-Service-Discovery/
-
- 02-Load-Balancer
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- service-discovery-services -> Service discovery (Eureka Server) code.
- authentication-services -> Authentication services code.
- user-services -> User services code.
- product-services -> Product services code.
- docker/
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- 02-Load-Balancer
-
- 03-Gateway/
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- service-discovery-services -> Service discovery (Eureka Server) code.
- gateway-services -> Gateway services code.
- authentication-services -> Authentication services code.
- user-services -> User services code.
- product-services -> Product services code.
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- postman
- ch7.postman_collection.json -> Postman collection for chapter 7 to request the services.
-
- 04-Configuration-Server/
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- online-auction-configuration -> Applications properties saved on GitHub
- service-discovery-services -> Service discovery (Eureka Server) code.
- configuration-services -> Configuration service's code.
- gateway-services -> Gateway services code.
- authentication-services -> Authentication services code.
- user-services -> User services code.
- product-services -> Product services code.
-
- 04-Configuration-Server/
- docker/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Run an image of PostgreSQL and MongoDB, populate them with data, and run all microservices.
- postgresql/
- service-discovery-services -> Service discovery (Eureka Server) code.
- configuration-services -> Configuration service's code.
- gateway-services -> Gateway services code.
- authentication-services -> Authentication services code.
- user-services -> User services code.
- product-services -> Product services code.
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- postman
- ch7.postman_collection.json -> Postman collection for chapter 7 to request the services.
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- mongo-init/
- init.js -> Create database, collection and insert data.
- .env -> PostgreSQL and MongoDB credentials
- docker-compose.yml -> Create the databases PostgreSQL and MongoDB and populate them with data. This is useful to run the code in an IDE.
- postgresql/
- postman
- ch7.postman_collection.json -> Postman collection for chapter 7 to request the services.
-
- Java 21 - Docker and Docker Compose - Maven 3.9.9
- Go the docker ch7/[01-Service-Discovery | 02-Load-Balancer | 03-Gateway | 04-Configuration-Server - 05-Resiliency]/docker folder
- Execute the command:
docker-compose up -d
- Go to the project's folder: postman and import the collection
- Now, execute the request for the desired service.
- To connect to the PostgreSQL:
- Url user database: jdbc:postgresql://localhost:5432/user_db
- Url product database: jdbc:postgresql://localhost:5432/product_db
- User: auction_app
- Password: auction123
- To connect to the MongoDB: mongodb://auction_app:auction123@localhost:27017/
authentication_db?authSource=admin
- User: auction_app
- Password: auction123
- Go the docker ch7/docker-resources folder
- Execute the command:
docker-compose up -d
- Open the microservices into your favorite IDE
- RUN THE SERVICES IN THE FOLLOWING ORDER:
- Configuration Services
- Discovery Services
- Gateway Services
- RUN THE SERVICES IN THE FOLLOWING ORDER:
- Go to ch7/[01-Service-Discovery | 02-Load-Balancer | 03-Gateway | 04-Configuration-Server - 05-Resiliency] folder and for each microservices execute the command:
mvn clean package
and thenmvn spring-boot:run
- To run more than one service instance, use the command:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=<port_number>"
- To run more than one service instance, use the command:
- Go to the project's folder: postman and import the collection
- Now, execute the request for the desired service.
- To connect to the PostgreSQL:
- Url user database: jdbc:postgresql://localhost:5432/user_db
- Url product database: jdbc:postgresql://localhost:5432/product_db
- User: auction_app
- Password: auction123
- To connect to the MongoDB: mongodb://auction_app:auction123@localhost:27017/
authentication_db?authSource=admin
- User: auction_app
- Password: auction123
-
- ch9:
- docker-resources/
- postgresql/
- init.sql -> SQL DDL and DML
- .env -> PostgreSQL credentials
- docker-compose.yml -> Run an image of PostgreSQL and populate it. Run Kafka.
- postgresql/
- postman
- ch9.postman_collection.json -> Postman collection for chapter 9 to request the services.
- data-files/ -> CSV files that are to be processed and their data inserted into the database.
- Users.csv -> User's CSV file that contains data from user's database.
- Products.csv -> Product's CSV file that contains data from product's database.
- Bids.csv -> Bid's CSV file that contains data from bid's database.
- Auctions.csv -> Auction's CSV file that contains data from auction's database.
- etl-batch-process/ -> Code to process the data files and save them to database. (Pipe and Filter architecture code)
- alerting-faas -> Code to send alerts to Slack channel (group) informing when the batch process is completed. (Serverless architecture)
- docker-resources/
- Java 21 - Docker and Docker Compose - Maven 3.9.9
- Go the docker ch9/docker-resources folder
- Execute the command:
docker-compose up -d
- Open the etl-batch-process application into your favorite IDE
- For each microservices execute the command:
mvn clean package
and thenmvn spring-boot:run
- Now, execute the request for the desired service.
- To check the data inserted into tables, connect to the PostgreSQL:
- Url: jdbc:postgresql://localhost:5432/report_db
- User: auction_app
- Password: auction123
- Open the alerting-faas application into your favorite IDE
- Execute the command:
mvn clean package
and thenmvn spring-boot:run
- Go to the project's folder: postman and import the collection
- Now, execute the request for the desired service.
- ch9:
- Software architects looking to deepen their knowledge of Spring-based architecture.
- Developers and engineers involved in designing, implementing, or evolving software systems.
- Technical leads aiming to improve scalability, performance, and security in distributed systems.
The author, Wanderson Xesquevixos, is a seasoned software engineer and architect with over 20 years of experience in Java, Spring, and cloud-native technologies. Wanderson brings practical insights from extensive experience across diverse projects in microservices, cloud computing, and software design.
Your feedback is invaluable! Feel free to contact us about issues, suggest improvements, or share your thoughts. This repository will be updated with any errata and additional resources to accompany the book.
Thank you for embarking on this journey in software architecture! Happy coding and architecting!