About • 💻 Features • 🚀 Built With • Requirements • Starting • 📝 License • 📬 Contact • Acknowledgments
Table of Contents Detail
An order control system for a fast food restaurant, which will manage orders and stock.
(1) A backend application (monolithic
):
- Application should be developed using
Ports and Adapters Architecture
(Hexagonal Architecture).
The APIs should have the following capabilities:
- Customer registration;
- Customer identification by Personal ID;
- Insert, update and delete Products;
- Find Products by Category (
burger
,drink
,side
anddessert
); - (fake) Order Checkout: send the order to the queue
received
after the checkout( successfully_), initially we will use queues in any database.
Order Tracking (queries):
-
received
: Payment made successfully; preparing
: In progress in the kitchen;ready
: Available for pickup by the customer;finished
: Delivered to the customer.
(2) The application must be delivered with Dockerfile
and docker-compose
configured to run correctly. For validation we will have the following infra restrictions:
- 1 instance to run the
application
; - 1 instance for
database
.
(1) A backend application (monolithic
):
- Update the application developed in phase1 by refactoring the code to follow
Clean Code
andClean Architecture
standards.
The APIs should have the following capabilities:
- Order Checkout: which should receive the Products Ordered and return the Order ID;
- Check Order Payment Status: Payment has been approved or not;
-
Webhook
to receive confirmation: Approved Payment or Declined Payment; - Order List should return Orders with their descriptions, sorted by Tracking with the following priority:
undelivered :
ready
>preparation
>received
NOTE: finalized
tracking should NOT appear in the list;
- Update the Order Tracking.
Order Tracking (queries):
received
: Payment made successfully;-
preparing
: In progress in the kitchen; -
ready
: Available for pickup by the customer; -
finished
: Delivered to the customer.
(2) The application must be delivered with k8s files
configured to run correctly.
-
Deployment
orHPA
of the application with at least 2Pods
. - Service for
LoadBalancer
; - Configuration of the database credential via
Secret
.
For validation we will have the following infra restrictions:
- 2 instances minimal to run the application;
- 1 instance for
database
.
Let's do it?
For this project you should to have basic konwledgement about:
- Java, Spring Boot and Spring Framework;
- Http verbs, status codes, request and response;
- Request's parameters;
- SQL language fundation;
- Containers and Kubernetes;
- Git, Github and Linux.
Project summary diagram:
+-----------------+
| 1. Interface | Contains communication components:
| Adapters Layer | controllers, presenters and gateways.
| |
| - Presenter | Receives and returns data to internal api (user interface).
| (Controller) |
| - Gateway | It's a middleware for external dependencies,
| (Repository) | when communicating with the database.
+-----------------+
│
v
+-----------------+
| 2. Application/ | Responsible for implementing
| Use Cases Layer | the application's business logic.
| |
| - Interactor / | Interactor is the component that implements a UseCase,
| UseCase | contains the business logic that coordinates the flow.
| - Exception | Error handling for business rules.
+-----------------+
│
v
+-----------------+
| 3. Domain / |
| Entities Layer | Enterprise Business Rules.
| - Entity |
| - Value Object |
| - DTO | Anemic entities used outside the domain.
| (Data Transfer) | (protects business rules)
+-----------------+
^
│
+-----------------+
| 4. Frameworks & | It is responsible for communicating with external systems.
| Drives Layer | that provide concrete implementations of the interfaces.
| |
| - Web Framework |
| (API) | Presenter handles HTTP requests and returns HTTP responses
| - Database |
| (Repository) | Persistence
+-----------------+
The project's structure is as follows::
:
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── fiappostech
│ │ │ └── fastfood
│ │ │ ├── adapter
│ │ │ │ ├── gateway
│ │ │ │ │ ├── ..
│ │ │ │ │ :
│ │ │ │ └── presenter
│ │ │ │ ├── ..
│ │ │ │ :
│ │ │ ├── application
│ │ │ │ ├── exception
│ │ │ │ └── usecase
│ │ │ │ ├── ..
│ │ │ │ :
│ │ │ ├── domain
│ │ │ │ ├── entity
│ │ │ │ ├── valueobject
│ │ │ │ └── dto
│ │ │ │ ├── ..
│ │ │ │ :
│ │ │ └── infrastructure
│ │ │ ├── api
│ │ │ │ ├── ..
│ │ │ │ :
│ │ │ ├── config
│ │ │ │ ├── ..
│ │ │ │ :
│ │ │ ├── exception
│ │ │ └── persistence
│ │ │ ├── ..
│ │ │ :
│ │ └── resources
│ │ └── db
│ │ └── migration
: :
Here we have the packages with all our classes that DON'T have any dependencies
, including libraries and the framework dependencies.
Broker for external dependencies.
adapter/presenter
: this is where all our controllers (user interface) are.adapter/gateway
: this is where all our repositories (database persistence) are.
application/usecase
: this is where all our interactors (implementing usecases) are.
domain/entity
: this is where all domains are.domain/valueobject
: this is where all value objects are.domain/dto
: this is where ourabstraction
entity, that represents entities outside the domain (protects business rules).
Now we have the packages with all our classes that HAVE library and/or framework dependencies
, such as web, ui, devices, datababe and external interfaces.
Implementation of external integration dependencies.
infrastructure/api
: this is where all our api controllers (user interface) are located.infrastructure/persistence
: this is where our entire persistence repository (database) is located.
This is only an way of how to implement the structure of the Clean Architecture.
The main focus should be on making good use of the concepts of separation of concerns, independence from frameworks and libraries, testability, dependency inversion, outer layers depend on inner layers (as per the direction of the arrows) and domain-centred design. It's important to respect the fact that the domain, application and adapter layers can't have any external dependencies (including with the focus on the framework).
The idea is that your business rule is fully protected from these external factors, understand the architectures, their similarities, adapt them to your needs and "Go Horse!!". ;-)
This project was developed with the following technology:
Spring (spring.io)
See the file: pom.xml
- Editor: Visual Studio Code
- API Client: Postman or RESTClient for VSCode
- Markdown: Obsidian or Markdown Preview Enhanced
- Database Manager: DbGate
- Container Tool: Podman or Docker
- Kubernetes: Minikube and k9s
- Terminal emulator: Alacritty
- Command Line: asdf, git, helm, kubectl, oc, stern, dive, grype, trivy and others...
For run this project, you will need:
docker v24
&&docker-compose v2.20
||docker v24
&&minikube v1.30
&&kubectl v1.27
To get a local copy and run the project with Docker
, follow these simple steps.
- Clone the repository
git clone [email protected]:sidneyaquino/fiappostech-techchallenge-fastfood-springboot.git
- Go into the project folder
In the projet folder execute the commands:
docker-compose up # download the app and database images and then run them.
or
docker-compose build # build app image.
docker-compose up # download only the database image and then run them.
Then it's now possible to access the project here: http://localhost:8080/swagger-ui/index.html
or
In the projet folder execute the commands:
minikube start --container-runtime=containerd
minikube addons enable csi-hostpath-driver
minikube addons enable volumesnapshots
minikube addons enable metrics-server
kubectl apply -f k8s/infra/data-pvc.yaml
kubectl apply -f k8s/data
kubectl apply -f k8s/app
minikube tunnel --bind-address='localhost'
Then it's now possible to access the project here: http://localhost:8080/swagger-ui/index.html
You can fork the "Public Postman Workspace" here:
It is also possible to import a copy or fork each collection individually:
This project is under the MIT license. See the file LICENSE for more details.
Made by Sidney Aquino, get in Touch!
FIAP POSTECH - Postgraduate Diploma in Software Architecture (360 hours in 1 year)
Master
practical knowledge of software development
and architecture
to work on projects with high levels of complexity using microservices
, containers
, serverless applications
, secure development
and more. Expand your technical knowledge
, incorporate the latest skills and prepare for the next phase of your software development
career.