How febriaricandra/book-shop works
Project Type Analysis
This is a REST API backend service for a book shop, built using Go, following a clean architecture pattern with clear separation of concerns.
Main Components
A. External Layer (Client Interface)
• REST API Endpoints
• Authentication Layer (JWT-based)
B. Application Core Layers (arranged in hierarchical order):
1. Handlers Layer (Controllers)
• Book Handler
• Order Handler
• User Handler
• RajaOngkir Handler (External shipping service integration)
2. Services Layer (Business Logic)
• Book Services
• Order Services
• User Services
3. Repository Layer (Data Access)
• Book Repository
• Order Repository
• User Repository
C. Infrastructure Components:
• Database (indicated by db package)
• R2 Storage (for image storage)
• Docker Container
[Client] → [API Gateway/Router] → [Auth Middleware] → [Handlers] → [Services] → [Repositories] → [Database]
[Login/Register Endpoints] → [Auth Middleware] → [JWT Token Generation] → [Token Validation]
[Book Endpoints] → [Book Handler] → [Book Service] → [Book Repository] → [Database]
• ↘ [R2 Storage] (for cover images)
[Order Endpoints] → [Order Handler] → [Order Service] → [Order Repository] → [Database]
• ↘ [RajaOngkir Service] (for shipping)
Important Details
• Authentication points
• Database relationships
• External service integration points
• Docker container boundary
• API endpoints grouping
• Middleware placement