A fashion e-commerce backend powered by a Golang using MySQL as database and Redis cache for querying and filtering.
The android repository is hosted .
The code is divided into following packages and files:
- apis
- Contains packages for home, filter & product endpoints. Each package holds a handler.go that is invoked for the respctive endpoint by the router
- Contains apiCommons which holds easy logging for API error logs from all the layers from dbRead, cache misses to curation problems.
- assets
- Holds the images this backend supplies for all products
- config
- Holds the configuration for database and server
- dataLayer
- cacheDaos - holds the redis cache daos
- databaseDaos - holds the mysql database daos
- dbModels - holds the mysql database models
- uiModels - holds the atomic models and snippets model this backend can send
- main.go
- The entry point to this monolith. It sets up the database, re-populates the redis cache with new values and starts the router.****
- ginRouter
- Actual router with it's middlewares lives here
- validator
- Holds the logic for custom validations on struct tags like productId, categoryId etc.
Each API is divided into following
- handler.go
- Handles the incoming request and transforms it into the request model (if needed)
- Creates the daos (cache and database as needed)
- Reads the data from DB using dbRead.go
- Invokes the logic in sections go files
- Finally forms the API response
- models folder
- Holds different modles like API request, API response and it's sub-models.
- Input validation using struct tags is driven by a custom written validator
- Sections folder 1. Each API response is curated by converting different sections into snippets 2. This folder holds each section logic separately, combining db read models with dao reads or previous section results.
- dbRead.go
- Handles the initial read of all the data required from the database
- Uses one or more DAO’s for the db tasks