How ngtruong624/backendshop_go works
Project type and purpose
• This is a backend‐only RESTful API service written in Go, using the Gin web framework and PostgreSQL as its data store.
• Its main responsibilities are user authentication (JWT), role‐based access control, and CRUD operations on products with pagination and filtering.
File structure
• cmd/api/main.go: entry point that initializes Gin, loads environment variables, connects to PostgreSQL, wires up middleware, routes, and starts the HTTP server.
• internal/handlers/: HTTP “controllers” (auth_handler.go, product_handler.go) that parse requests, call into the repository layer, and return responses.
• internal/middleware/auth.go: JWT authentication and role‐based access checks applied to protected routes.
• internal/repository/: data access layer (product_repo.go) that encapsulates SQL queries or ORM operations against PostgreSQL.
• internal/utils/response.go: standard response formatting (error/success wrappers).
• .github/workflows/go.yml: CI pipeline for Go (linting, testing, building).
• go.mod / go.sum: dependency management.
Extract additional architecture hints from the README
• The system uses environment variables to configure DB connection and JWT secrets.
• Postgres is the only external dependency at runtime.
• Service is single‐process, layered application (no microservices).