API: overview
The API is the keeper of the data: it stores the products in PostgreSQL and exposes them as JSON to the web front end.
At a glance
| Topic | Detail |
|---|---|
| Folder | api/ |
| Language | Python 3.11 |
| Framework | 4.2 + |
| Prod server | , 3 workers |
| Database | 17 (dev and prod), for tests and locally |
| Live address | https://api.trinity.jostud.com (prod), https://api.dev.trinity.jostud.com (dev) |
| Clients | the web front end |
| Tests | 7 tests (pytest-django) |
| Owner | Patrice |
What the part does
Its architecture
urls.pymaps each address to a view.ProductViewSetprovides the five operations without writing them one by one.ProductSerializerturns a product into JSON, and checks the JSON received.Productdescribes the table; Django's writes the SQL.
Before you start
If Django, a serializer or a migration mean nothing to you, read The basics first.
Going further
| You want to… | Read |
|---|---|
| run the API on your machine | Run the project |
| know the product table | Database |
| know what the API accepts and refuses | Products |
| read the real code explained | In depth |
| the list of endpoints | Reference |
| add a route | Add a route |