How ecoscanai/ecoscan-an-eco-friendly-product-scanner-golang works
Project type and purpose
• This is a Go-based backend REST API service. It exposes user and product endpoints, applies business logic (e.g. scoring), persists data in a relational database (via raw SQL in db_queries), and integrates with two external AI APIs (Gemini and Hface).
File structure
• cmd/serve.go & main.go: application entrypoints
• config/: configuration loader
• rest/: HTTP layer
• handlers/…: per-resource handler implementations
• middlewares/: cross-cutting concerns (auth, CORS, logging)
• logic/: core business rules (e.g. scoring.go)
• repo/: data access layer (user, product, score)
• db_queries/: SQL scripts
• utils/: JWT issuance, token validation
README
• Minimal content; no architecture section—so deduce layers/directions from code layout.
• Blue = HTTP & Routing
• Green = Business Logic
• Orange = Data Access
• Gray = External Services
Essential details to capture
• Configuration loading at startup (config/config.go)
• Middleware sequence (auth → cors → logger → manager)
• Handler grouping by resource (user vs. product)
• Logic layer’s scoring component
• Repository layer’s SQL scripts and DB interactions
• Two external AI integrations