How pt-sinan-akbar/split-bills-be works
Project type and purpose
• This is a standalone, back-end RESTful API service (written in Go) that provides bill-splitting functionality among friends.
• There’s no bundled frontend here; the repo exposes HTTP endpoints (and a Swagger UI) for any client (web, mobile, etc.) to interact with.
File structure
• Top-level files:
• main.go – application entrypoint
• Dockerfile, .dockerignore – containerization
• deploy/*.yaml – Kubernetes Deployment, Service, Ingress
• .env.example, initializers/loadEnv.go – environment config
• Core code directories (layered architecture):
• routes/ → route definitions, URL→controller mappings
• controllers/ → HTTP handlers (BillController.go, BillDataController.go, etc.)
• manager/ → business logic layer (BillManager.go, BillDataManager.go, …)
• models/ → data models / ORM definitions
• dto/ → request/response structs for data transfer
• initializers/ → DB connection (connectDB.go), environment loading
• migration/, seeder/ → one-off DB migration & seed scripts
• docs/ → auto-generated Swagger definitions (swagger.json, swagger.yaml)
README for additional insights
• Supports live-reload via Air, Docker build/run, Kubernetes deployment.
• Exposes API docs at /swagger/index.html.
Components
a. Main components
1. Clients (Web UI, Mobile App, CLI, etc.)
2. Ingress / API Gateway (Kubernetes Ingress)
3. split-bill-service (the Go application)
• Router layer
• Controller layer
• Manager (Service) layer
• Models / ORM + Migration/Seeder
4. Database (e.g., PostgreSQL/MySQL)
5. External services (optional: logging, monitoring, Swagger UI)
b. Relationships & interactions
• Clients → Ingress → HTTP request → Router
• Router → Controller → Manager → Model → Database
• Manager returns business data back up to Controller → Router → Response to Client
• Migration & Seeder run at startup or as a separate job against the Database
c. Architectural patterns
• Layered (Router → Controller → Service/Manager → Data Access)
• MVC-style separation of concerns (controllers manage HTTP, managers handle logic, models map to DB)
• Twelve-factor app principles (env config, stateless service, containerized, separate dev & prod)
d. Key technologies
• Go modules (go.mod)
• Gin / Gorilla Mux (presumed HTTP router)
• GORM / sqlx (assumed ORM layer)
• Docker & Kubernetes for containerization & orchestration
• Swagger for API docs
Detailed capture of essential elements
• Break out each major controller (Bill, BillItem, BillMember, BillOwner) as sub-components if desired.
• Migration and seeder processes as separate jobs/tools that run against the same database.