How kappy713/sports_backend works
Project Context and Overview
• This backend service is part of a full-stack application aimed at helping users record their daily exercise for visual analysis and habit formation.
• The README specifies that it interacts with a separate frontend (hosted in a different repository) and uses Go as its backend language, PostgreSQL for data persistence, and Docker for containerization.
• The system supports typical RESTful interactions via HTTP, with clearly separated layers for domain logic, interfaces (controllers), and infrastructure (e.g., database, router, middleware).
Main Components
a. Client (Frontend)
– Although not part of this repository, note its role and external communication with the backend API.
b. API Gateway / Entry Point
– The “main.go” file is the entry point of the backend.
– This component initializes the application, sets up routing, and integrates middleware.
c. Domain Layer
– Located in the “domain” directory.
– Contains core business logic and domain models (e.g., posts.go, relationships.go, users.go).
d. Infrastructure Layer
– Contains modules for database connectivity (“infrastructure/db/db.go”), middleware (“infrastructure/middleware/middleware.go”), and routing (“infrastructure/router/router.go”).
– This layer is responsible for handling cross-cutting concerns like request processing and establishing database connections.
e. Interfaces Layer
– Found in “interfaces/controller” with various controllers (e.g., bookmark.go, get_post.go, mypage.go, post.go, user_controller.go).
– These controllers expose the API endpoints and serve as the bridge between HTTP requests and the underlying domain logic.
f. External Services and Dockerization
– Docker configuration files (Dockerfile and docker-compose.yml) signify that the app is containerized.
– PostgreSQL is used as the DB (as indicated by documentation instructions) and is set up via docker-compose alongside the backend container.
– External integrations include environmental configurations through a .env file and JWT secret configuration for security.
Architectural Patterns & Design Principles
• Layered Architecture / Hexagonal: Notice the clear separation between domain (business rules), interfaces (delivery mechanism), and infrastructure (external integrations).
• Separation of Concerns: Each directory provides a dedicated role (business logic in “domain”, data access/middleware in “infrastructure”, presentation/HTTP in “interfaces”).
• Containerization & DevOps Integration: Docker and docker-compose indicate a containerized deployment with isolated components (backend service and DB).