How roshanrajan427-code/msbackend works
Mini Shop Backend is an HTTP API for seller-managed shops and products and customer orders. Customers verify a phone number, register or authenticate, browse shops/products, then place and track orders; sellers manage shops and inventory, review orders, and accept or reject them. The sampled handlers delegate persistence to repositories backed by PostgreSQL; product image uploads also use S3. Routes and wiring are visible in main.go. Some repository files and handler sections were not sampled, so those links are omitted where call evidence is unavailable.
Main entry points: main.go HTTP routes · product_handler.go Product catalog · auth_handler.go Authentication · shop_repository.go Shop records
Components 17
HTTP API
- HTTP routes
main.go - Local image files
main.go
Identity
- JWT middleware
auth/middleware.go - JWT tokens
auth/jwt.go - Authentication
handlers/auth_handler.go
Commerce
- Shop management
handlers/shop_handler.go - Product catalog
handlers/product_handler.go - Order workflow
handlers/order_handler.go
Persistence and media
- User records
repository/user_repository.go - Shop records
repository/shop_repository.go - Product records
repository/product_repository.go - Order records
repository/order_repository.go - Database pool
database/db.go
Other components
- Customer
- Seller
- PostgreSQL
- S3 image storage
Connections 21
- Customer → HTTP routes: uses API
main.go - Seller → HTTP routes: uses API
main.go - HTTP routes → Authentication: routes auth
main.go - HTTP routes → Shop management: routes shops
main.go - HTTP routes → Product catalog: routes products
main.go - HTTP routes → Order workflow: routes orders
main.go - HTTP routes → JWT middleware: protects routes
main.go - Authentication → User records: looks up users
handlers/auth_handler.go - Authentication → JWT tokens: issues tokens
handlers/auth_handler.go - JWT middleware → JWT tokens: validates tokens
- Shop management → Shop records: manages shops
handlers/shop_handler.go - Product catalog → Shop records: checks ownership
handlers/product_handler.go - Product catalog → Product records: manages products
handlers/product_handler.go - Order workflow → Order records: places and tracks
handlers/order_handler.go - Database pool → PostgreSQL: opens connection
database/db.go - Shop records → PostgreSQL: reads and writes
- Product records → PostgreSQL: reads and writes
- Order records → PostgreSQL: reserves stock
- User records → PostgreSQL: reads and writes
- Product catalog → S3 image storage: uploads images
- HTTP routes → Local image files: serves files
main.go