Repository for the FIAP Tech Challenge 1, focused on developing a monolith backend system for managing orders in a fast-food restaurant.
Tech Challenge 1 specifications can be found here.
- Customer (actor): Actor responsible for initiating the purchasing process
- Cook (actor): Actor responsible for preparing the customer's order
- Attendant (actor): Actor responsible for interacting with the customer, providing support for the order
- Identification method: Format in which the customer is identified on the platform: via CPF or anonymous.
- Identification: Customer identification on the platform
- Authorization: Grants permission to the customer to perform operations on the platform, such as placing an order, changing registration information
- Order: Represents all items selected by the customer in the store
- Order Status: Represents the stage of order preparation after payment is confirmed.
Full Event Storming Board can be found here.
DBML file can be found here.
.
├── bin
├── cmd
│ └── http
├── docs
└── internal
├── adapter
│ ├── handler
│ │ └── http
│ ├── repository
│ └── postgres
│ └── migrations
└── core
├── domain
├── port
├── service
└── util
Project Structure Explanation
bin: directory to store compiled executable binary.docs: directory to store project's documentation, such as swagger static files.cmd: directory for main entry points or commands of the application. The http sub-directory holds the main HTTP server entry point.internal: directory for containing application code that should not exposed to external packages.core: directory that contains the central business logic of the application. Inside it there are 4 sub-directories.domain: directory that contains domain models/entities representing core business concepts.port: directory that contains defined interfaces or contracts that adapters must follow.service: directory that contains the business logic or services of the application.util: directory that contains utility functions that reused in the service package.adapters: directory for containing external services that will interact with the core of application. There are 4 external services used in this application.handler/http: directory that contains HTTP request and response handler.repository/postgres: directory that contains database adapters for PostgreSQL.
- Language: We chose Go as the programming language for its performance, simplicity, and concurrency features.
- Framework: We chose the Gin framework for its simplicity and performance.
- Database: We chose PostgreSQL as the database for its performance, scalability, and reliability.
- Dockerfile: small image with multi-stage docker build, and independent of the host environment
- Makefile: to simplify the build and run commands
- Hexagonal architecture
- PostgreSQL database
- Conventional commits
- Unit tests
- Code coverage
- Swagger documentation
- Postman collection
- Feature branch workflow
- Air to run go
- Pagination
- Health Check
- Lint
- Vulnerability check
Note
You need to have Go (> 1.18) installed in your machine to build, run and test the application locally
git clone https://github.com/FIAP-SOAT-G20/FIAP-TechChallenge-Fase1.gitcd FIAP-TechChallenge-Fase1[Optional] Set the environment variables
cp .env.example .envNote
If you want to run the application locally, you need to set the environment variables in the .env file
If you want to run the application using Docker, you don't need to set the environment variables because they are already set in the .env.local file used by Docker Compose
make compose-buildThe binary will be created in the
binfolder
make compose-runNote
To stop the application, run compose-stop
To remove the application, run compose-clean
POST /api/v1/customers - Create a customer (2.b: i.Cadastro do Cliente)
POST /api/v1/staffs - Create a staff
2.b: iii. Criar, editar e remover produtos;
POST /api/v1/payments/callback - Update a payment on a order
POST /api/v1/payments/{order_id}/checkout - Create a checkout on a order
GET /api/v1/products - List products
POST /api/v1/products - Create a product
GET /api/v1/products/{id} - Get a product (2.b: iv. Buscar produtos por categoria;)
PUT /api/v1/products/{id} - Update a product
DELETE /api/v1/products/{id} - Delete a product
2.b: v. Fake checkout
POST /api/v1/payments/callback - Update a payment on a order
POST /api/v1/payments/{order_id}/checkout - Create a checkout on a order
2.b: ii. Identificação do Cliente via CPF
POST /api/v1/sign-in - Sign in a customer
GET /api/v1/categories - List categories
POST /api/v1/categories - Create a new category
GET /api/v1/categories/{id} - Get a category
PUT /api/v1/categories/{id} - Update a category
DELETE /api/v1/categories/{id} - Delete a category
GET /api/v1/customers - List customers
POST /api/v1/customers - Create a customer
GET /api/v1/customers/{id} - Get a customer
PUT /api/v1/customers/{id} - Update a customer
DELETE /api/v1/customers/{id} - Delete a customer
GET /api/v1/orders - List orders (2.b: vi. Listar os pedidos.)
POST /api/v1/orders - Create an order
GET /api/v1/orders/products/{order_id}/{product_id} - Get an order product
PUT /api/v1/orders/products/{order_id}/{product_id} - Update an order product
POST /api/v1/orders/products/{order_id}/{product_id} - Create an order product
DELETE /api/v1/orders/products/{order_id}/{product_id} - Delete an order product
PUT /api/v1/orders/status/{id} - Update an order status
GET /api/v1/orders/{id} - Get an order
DELETE /api/v1/orders/{id} - Delete an order
GET /api/v1/orders/histories - List order histories
GET /api/v1/orders/histories/{id} - Get an order history
GET /api/v1/orders/products - List order products
GET /api/v1/staffs - List staffs
POST /api/v1/staffs - Create a staff
GET /api/v1/staffs/{id} - Get a staff
PUT /api/v1/staffs/{id} - Update a staff
DELETE /api/v1/staffs/{id} - Delete a staff
GET /health - Application HealthCheck
Follows the Health Check Response Format for HTTP APIs
Note
You can check the application swagger documentation at http://localhost:8080/docs/index.html
Alternatively, a postman collection is available at here
- Install Go: https://golang.org/doc/install
- Clone this repository:
git clone https://github.com/FIAP-SOAT-G20/FIAP-TechChallenge-Fase1 - Change to the project directory:
cd FIAP-TechChallenge-Fase1 - Set the environment variables:
cp .env.example .env - Install dependencies by running
make build - Run the application by running
make run-airormake run - Access the application at
http://localhost:8080 - Dont forget to run the tests by running
make test - Check the coverage report by running
make coverage - Check the lint by running
make lint - Update the swagger documentation by running
make docs-swag
Note
make run will run the application locally, and will build and run PostgreSQL container using Docker Compose
Alternatively, you can run make run-air to run the application using Air (live reload)
make testNote
It will run the unit tests and generate the coverage report as coverage.out
You can check the coverage report by running make coverage
- Hexagonal Architecture, Ports and Adapters in Go
- Building RESTful API with Hexagonal Architecture in Go
- Hexagonal Architecture in Go
- DBML
- Health Check Response Format for HTTP APIs
- Event Storming
- Swagger
- Conventional Commits
- Shields.io
- Alistair in the "Hexagone" 1/3
![]() Alice Tomaz | ![]() Filipe Leuch Bonfim | ![]() Hugo Kishi | ![]() Marcos Santos | ![]() Vitor Parras |







