How quanganh247-qa/golang-pet-care works
Project Type and Purpose
• This is a backend service written in Go that supports a React Native mobile application for pet clinics and pet owners. It offers functionalities like user management, pet management, medical record tracking, appointment scheduling, e-commerce (shopping cart, products, payment), location services, and AI-powered chatbot assistance.
• Its design leverages standard RESTful APIs, layered architecture (controllers, services, models), middleware for authentication/logging, and uses Docker for deployment.
Main Components to Highlight
a. API Server (Backend):
• Components in the “app/api” directory, such as endpoints for appointments, cart, chatbot, device_token, disease, doctor, invoice, location, medical records, medications, payment, pet, pet_schedule, products, rooms, search, service, test, user, vaccination.
• You note that the API layer uses Gin Web Framework, handling HTTP routing and controller logic.
b. Business Logic / Service Layer:
• Under “app/service”, include modules such as Elasticsearch integration, LLM (likely for chatbot and intelligent responses), mail sending, MinIO for object storage, Redis for caching and queue management, token (JWT management), websocket for real-time notification, and worker tasks.
c. Middleware:
d. Database & Data Access:
• The “app/db” directory contains migration scripts, SQL query files, and SQLC-generated Go code that abstracts database interactions. The primary database is PostgreSQL.
e. External Services Integration:
• External integrations provided by 3rd-party services such as:
• JWT for authentication.
• Goong Maps (location services).
• Gmail for email notifications.
• VietQR for payment integration.
• Google Gemini for chatbot enhancements.
• OpenFDA for drug and medical information.
f. Utility and Configuration:
• Components in “app/util” that handle configuration, custom responses, logging, error handling, validations, and connection initialization.
g. Docker & Deployment:
• Dockerfiles, docker-compose files, and Makefile targets indicate a containerized environment. These should be shown as part of the overall deployment environment.
Relationships and Interactions
• How the mobile client (React Native application) interacts with the API Gateway (the Gin server).
• That the API server routes HTTP requests through middleware before reaching the controller logic.
• The controllers in turn invoke services which handle the business logic and interact with the database (PostgreSQL) via SQLC code.
• Some services (like caching, queue/worker, file storage) interact with Redis, MinIO, and external services.
Architectural Patterns and Design Principles
• Layered architecture separating the API, business logic (services), and data access layers.
• Use of middleware for cross-cutting concerns (authentication, authorization, logging).
• Containerization using Docker, promoting microservice-like deployment even if it is a monolithic Go application.
• Integration of external microservices/APIs for maps, payment, and AI functionalities.
• Worker pattern for background tasks.