How elyseemb/ecommercewithgolang works
Project type and purpose
• This is a backend service for an e-commerce application written in Go.
• It exposes RESTful HTTP endpoints for managing items and taxonomies (categories).
• It supports two database modes (SQLite by default, optional Postgres via Docker Compose).
• It uses a Clean/Hexagonal architecture (layers: domain, application, infrastructure, interfaces).
File structure
• cmd/main.go: starts the HTTP server
• cmd/migrate/main.go: runs DB migrations
• internal/interfaces/router.go + api handlers: HTTP entry points
• internal/application: service (use-case) layer
• internal/domain: core entities and repository interfaces
• internal/infrastructure: concrete implementations for DB connections and persistence
• compose/: Docker Compose setup for Postgres
• pkg/constants: shared constants
README
• Confirms Go and SQLite as primary technologies
• Mentions “Ecommerce Application” with item and taxonomy management
a. Main components
• HTTP Server (Gin/Chi or built-in net/http) – entry point
• Router & API Handlers – maps HTTP routes to application services
• Application Services – item_app, taxonomy_app use-cases
• Domain Layer – entities (Item, Taxonomy, Promotion) and repository interfaces
• Persistence Layer – concrete repos (SQLite/Postgres) implementing the interfaces
• Database – SQLite file or Postgres container
• CLI Migration Tool – runs SQL migrations before startup
b. Relationships & data flow
1. Client → HTTP Server → Router
2. Router → Handler (ItemHandler/TaxonomyHandler)
3. Handler → Application Service (e.g. CreateItem)
4. Service → Domain Entity / Repository Interface
5. Repository Interface → Persistence Implementation (item_repository)
6. Persistence → Database (exec SQL queries)
7. Database → Persistence → returns data back up the chain → HTTP Response
c. Architectural patterns & design principles
• Dependency inversion: application layer depends on domain interfaces, not concrete DB code
• Separation of concerns: clear layers (interfaces/controllers, services, domain, infrastructure)
• Single Responsibility: each package focuses on one role
• CLI command isolation: migrations separated from main server
d. Key technologies & frameworks
• Go modules (go.mod)
• net/http or a router library (defined in internal/interfaces/router.go)
• SQLite (default) and Postgres (infrastructure/database/pg.go)
• SQL migrations under internal/infrastructure/database/migrations