2 A basic API implementation
This chapter covers
- Reading and understanding the requirements of an API specification
- Structuring our application into a data layer, an application layer, and an interface layer
- Implementing API endpoints using FastAPI
- Implementing data validation models (schemas) using Pydantic
In this chapter, we implement the API for the orders service, which is one of the microservices of the CoffeeMesh website, the project that we introduced in chapter 1. CoffeeMesh is an application that makes and delivers coffee on demand at any time, wherever you are. In this chapter, we’ll implement the API for one of the services in the CoffeeMesh platform: the orders service, which allows customers to place orders. In doing so, you will get an early peek into the concepts and processes that we dissect in more detail throughout this book. In this chapter, I go quickly through the steps and concepts involved in the implementation of a microservice, and build an intuition of the main ideas that we will cover in more detail in later chapters.
The code for this chapter is available under the folder ch02 of the GitHub repository provided with this book.