How luigiazevedo/public-library works
Project type and purpose
• This is a Go-based backend API for a “Public Library” service, implemented with Hexagonal (Ports & Adapters) architecture.
• Its core domain manages three aggregates: User, Book, and Loan, exposing CRUD and borrow/return operations over HTTP.
File structure
• Top level
• cmd/main.go – application entrypoint and dependency wiring
• config/viper.go – configuration adapter (loads app.env)
• Taskfile.yml – local task runner definitions
• .github/workflows – CI for build & lint
• internal/
• domain/ – core: entity (Book, User, Loan) + usecase interactor implementations
• ports/ – interface definitions (inbound/usecase & outbound/repository)
• delivery/http/ – HTTP adapters (“controllers” or handlers using chi & zerolog)
• database/
– migrations/ – SQL scripts for Postgres schema
– repository/ – repository adapters implementing repository ports via pq
• mock/ – test doubles for ports
• docs/database.dbml – database schema DSL
README for additional insights
• Confirms Hexagonal (Ports & Adapters) pattern, lists dependencies (chi router, zerolog, Viper, pq, bcrypt, sqlmock, gomock).
• Emphasizes loose coupling: core business logic is independent of HTTP, DB, and config details.