Product API
Build a RESTful API for an online store. The API is organized around two core resources: product and order.
flowchart LR
subgraph api [Trusted Layer]
gateway --> account
gateway --> auth
account --> db@{ shape: cyl, label: "Database" }
auth --> account
gateway e5@==> product:::red
gateway e6@==> order
product e2@==> db
order e3@==> db
order e4@==> product
end
internet e1@==>|request| gateway
e1@{ animate: true }
e2@{ animate: true }
e3@{ animate: true }
e4@{ animate: true }
e5@{ animate: true }
e6@{ animate: true }
classDef red fill:#fcc
click product "#product-api" "Product API" Attention
To consume the API, the user must be authenticated.
Product API
The Product API must expose the following endpoints:
POST /products
Create a new product.
GET /products
Get all products.
GET /products/{id}
Get a product by its ID.
Additionals
Additional features are welcome, such as:
- Search products by "like" name;
- Authorization by role (admin, user):
- Admin can create, update, and delete products;
- User can only create orders;
- Input validations;
- Error handling.
Nice to have
- Observability (metrics, logs), see Prometheus and Grafana;
- Database In-Memory (suggestion: Product microservice), see Redis;
- Swagger documentation, see SpringDoc.