-
Notifications
You must be signed in to change notification settings - Fork 0
Repo structure and components
Aman Gupta edited this page Apr 16, 2020
·
1 revision
Welcome to the bookstore_users-api wiki!
Main.go
|
v
+--+-----------+ +--------------+
| Application +------->+ Controller |
+--------------+ +------+-------+
|
v
+------+-------+
| Services +
+--------------+
|
v
+------+-------+ +----+
| Domain +------->+ DB |
+--------------+ +----+
- MVC development is opposite to domain driven developement
- We invoke the application via main.go
- In application we initiate our choice of http router and only initiate only this time throughout the dev process.
- All the routes/url_mappings are also defined in applications
- We define the handler functions for url_mappings inside the controllers.
- In controller we basically process the request body and parameters (ie JSON marshalling/unmarshalling) and send to the functions in SERVICES.
- In services, we define our business logic functions.
- These functions are basically same as controllers, but we define here how we want to deal with data internally, i.e encrypting password or create current time etc.
- This is the main component of our application.
- We define our main object definition here i.e. the type struct in the data_transfer_object (dto).
- We will also have our data_access_object(dao) here, which talks to the database and we define all the database queries here.
- Here we initiate our database and its required go packages, in our case it was database/sql and go-sql-driver/mysql.