Example Commerce System
- Docker
- make
- Build the server:
make build - Start the server build on
localhost:8080:make run - Start api doc server on localhost:8081:
make redoc
COUPON_DEFAULT_LIFETIME: The default lifetime when creating a coupon and no expires at date is given. Use values like10s,2.5mor1h30mto express a duration. Defaults to10s.
- There is a built-in administration account with the credentials
admin:admin. - Use the enclosed postman collection and environment to create coupons using the administration account.
- Run the dev frontend on localhost:3000:
make frontend
+--------------------------------------------+ +---------------------------------------------+
| SPA Frontend (Vue) | | RESTful Backend (Go) |
| | | |
| +---------------------------+ +---------+--+ +--+--+ +---------------+--------------------+ |
| | App Logic | | API Client | | API +--> Registration | Controllers | |
| | | | +----> | +---------------+ | |
| | | | | | +--> Login | | |
| | +---> +----> | +---------------+ | |
| | | | | | +--> Store Cart | | |
| +---+-----------------------+ | +----> | +---------------+ | |
| | | | | +--> ... | | |
| | +-----------------+ Auth | | | +---------------+ | |
| | | | | | | | | |
| | | +------> | | | +------------+ | | |
| | | | | | | +---> Basic Auth | | | |
| | | | +---------+--+ +--+--+ +----------+-+ +-------+-+-+--------+ |
| | | | | | | | | | |
| +---v---------v---+ +---+------------+ | | +--------------------------v-v-v--------+ |
| | Persistence | | Server-side | | | | Models | | |
| | | | | | | | | | |
| +-------+-+-+-----+ | +------+ +---+ | | | | +------+ +-v----+ +-------+ +---+ | |
| | | | | | Cart | |...| | | | | | Cart | | User | | Order | |...| | |
| | | +--------> +------+ +---+ | | | | +------+ +------+ +-------+ +---+ | |
| | | | | | | | | |
| | | +----------------+ | | +---------------+-+-+-------------------+ |
| | | | | | | | |
| | +-------------------+ | | +---------------v-v-v-------------------+ |
| | | | | | Persistence | |
| +-------v---------+ +--------v-------+ | | | | |
| | Session Storage | | Local Storage | | | +-----+-------------+-------------+-----+ |
| | | | | | | | | | |
| | +-------------+ | | +------+ +---+ | | | +-----v----+ +-----v-----+ +----v-----+ |
| | | Credentials | | | | Cart | |...| | | | | Database | | In-memory | | ... | |
| | +-------------+ | | +------+ +---+ | | | | | | | | | |
| | | | | | | | | | | | | |
| +-----------------+ +----------------+ | | +----------+ +-----------+ +----------+ |
| | | |
+--------------------------------------------+ +---------------------------------------------+
Guest orders a product:
+----------------------+ +----------------------+ +----------------------+
| User | | Frontend | | Backend |
+----------------------+ +----------------------+ +----------------------+
| | | | | |
| adds product to cart +-----> stores cart in local | | |
| | | storage | | |
| | | | | |
| goes to checkout +-----> requires login | | |
| | | | | |
| <-----+ show login | | |
| | | | | |
| want to create acc +-----> | | |
| | | | | |
| <-----+ show register | | |
| | | | | |
| register +----------------------------------> create user |
| | | | | |
| | | store user creds <-----+ |
| | | | | |
| | | store cart on server +-----> apply discounts & |
| | | | | store cart |
| | | | | |
| | | update local cart <-----+ |
| | | | | |
| <-----+ show checkout | | |
| | | | | |
| enter coupon +------- add cart info ------------> validate order |
| | | | | |
| <-----+ show order details <-----+ order details |
| | | | | |
| submit payment info +------- add cart info ------------> lock cart, validate |
| | | | | and store order |
| | | | | |
| | | clear cart <-----+ order details |
| | | | | |
| <-----+ show order details | | |
| | | | | |
+----------------------+ +----------------------+ +----------------------+
Images used:
- Orange by Marcos Ramírez on Unsplash
- Pear by Amirul Islam on Unsplash
- Apple by Louis Hansel @shotsoflouis on Unsplash
- Banana by Mike Dorner on Unsplash