Skip to content

sidneyaquino/fiappostech-techchallenge-fastfood-springboot

Repository files navigation

STATUS: 🚧 Man At Work...

About💻 Features🚀 Built WithRequirementsStarting📝 License📬 ContactAcknowledgments

Table of Contents Detail
  1. About The Project
  2. 💻 Features
  3. 🚀 Built With
  4. Requirements
  5. Getting Started
  6. 📝 License
  7. 📬 Contact
  8. Acknowledgments

(back to top)

About The Project

An order control system for a fast food restaurant, which will manage orders and stock.


FIRST SPRINT / phase1 branch

(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 and dessert);
  • (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.

SECOND SPRINT / phase2 branch

(1) A backend application (monolithic):

  • Update the application developed in phase1 by refactoring the code to follow Clean Code and Clean 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 or HPA of the application with at least 2 Pods.
  • 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?

(back to top)

Prerequisites

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.

(back to top)

💻 Features

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.

1. Interface Adapters Layer (adapter)

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.

2. Application Bussines Rules Layer (application)

  • application/usecase: this is where all our interactors (implementing usecases) are.

3. Enterprise Bussines Rules Layer (domain)

  • domain/entity: this is where all domains are.
  • domain/valueobject: this is where all value objects are.
  • domain/dto: this is where our abstraction 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.

4. Frameworks & Drives Layer (infrastructure)

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.

Disclaimer

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).

Similarities between hexagonal architecture (ports and adapters) and clean architecture

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!!". ;-)

(back to top)

🚀 Built With

This project was developed with the following technology:

Springboot Java Maven Swagger flyway Postgresql K6 Podman kubernetes openshift

Spring (spring.io)

See the file: pom.xml

Utility Software

(back to top)

Requirements

For run this project, you will need:

  • docker v24 && docker-compose v2.20 ||
  • docker v24 && minikube v1.30 && kubectl v1.27

(back to top)

Getting Start

To get a local copy and run the project with Docker, follow these simple steps.

🛠️ Installation Steps

  1. Clone the repository
git clone [email protected]:sidneyaquino/fiappostech-techchallenge-fastfood-springboot.git
  1. Go into the project folder

⚡ Runnig...

1.1. Docker - smart choice! o/

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

1.2. Kubernetes - best choice! \o/

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


2. API access using Postman

You can fork the "Public Postman Workspace" here: Fastfood WorkSpace

It is also possible to import a copy or fork each collection individually:

Customers Collection Orders Collection Payment Collection Products Collection

(back to top)

📝 License

This project is under the MIT license. See the file LICENSE for more details.

(back to top)

📬 Contact

Made by Sidney Aquino, get in Touch! LinkedIn

(back to top)

Acknowledgments

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.

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages