How dubjay18/ecom-api works
Main Components
A. External Layer (Client Interface)
• REST API Endpoints (Swagger documented)
• Authentication/Authorization Gateway
• Middleware Layer (logging, auth, admin checks)
B. Application Core
• Handlers (presentation layer)
• Services (business logic layer)
• Repositories (data access layer)
• Domain Models (business entities)
C. Infrastructure
• Database (SQL with migrations)
• JWT Authentication
• File Upload System
• Configuration Management
Component Relationships
a) Top Level (External Interface):
• HTTP clients connecting to the API
• Middleware chain (logger → auth → admin)
• To Swagger documentation
b) Core Architecture (Clean Architecture layers):
• Handler Layer: Show separate handlers for Users, Products, and Orders
• Service Layer: Connect corresponding services to handlers
• Repository Layer: Link repositories to services
• Domain Layer: Place domain models at the center
c) Infrastructure Components:
• Database connection handling
• JWT token management
• Image upload functionality
• Configuration management
Specific Elements
[Client] → [Middleware] → [Handlers] → [Services] → [Repositories] → [Database]
• ↑ ↑ ↑ ↑
• [Auth/JWT] [Validators] [Domain Models] [Migrations]
Important Architectural Patterns to Highlight
• Clean Architecture pattern (showing clear separation of concerns)
• Repository pattern for data access
• Middleware chain pattern
• Domain-driven design elements
Technical Details
• Gin framework as the HTTP router
• GORM as the ORM layer
• JWT for authentication
• SQL migrations system
• Configuration management via environment variables