You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
loveyourstack edited this page Apr 17, 2024
·
3 revisions
(work in progress)
Let's say we work for a car dealership and we need to get car data from the Ford Motors API and store it in the database.
Database
The database is straightforward: a schema called "ford" and a table called "ford.car".
Application
Firstly, I would define the namespaces in advance, something like:
fordapi - client code to access the Ford API
fordcar - the store package (database access) for the table "ford.car"
ford - core processes related to Ford
Then some notes about each in turn:
fordapi
This package could be in /internal/apiclients/fordapi
This is where I would keep all client code accessing the Ford API, and structs which model the results exactly.
fordcar
This package could be in /internal/stores/ford/fordcar
This store would contain all database access code for the ford.car table. I would also put business logic here if it relates directly to a Ford car.
ford
This package could be in /internal/processes/ford
This would be the main business logic package for Ford, except logic directly related to an entity. It might contain functions for billing and reporting.