How mbeka02/lyra_backend works
Main Components
• Entry Point: Represent the cmd/server as the primary executable, which bootstraps the entire service.
• The HTTP handler layer (found in internal/server/handler) managing routes for appointments, availability, doctors, patients, payments, and users.
• Middleware for authentication (internal/server/middleware/auth).
• Routing setup (internal/server/routes.go) that maps endpoints to handlers.
• Service Layer: Include a distinct component for the internal/server/service where business logic is implemented for each major domain (appointments, availability, doctor, patient, payment, and user services).
• Repository Layer: Add a component for the internal/server/repository where data access logic resides. This layer interacts with the database models and executes queries.
• Database Layer: Emphasize the internal/database and associated SQL queries (in sql/queries and sql/schema). Note that this layer handles data models, migrations, and SQL generation (through tools like sqlc as inferred from sqlc.yaml).
• External Integrations:
• Object Storage: Represent the internal/objstore component handling storage (likely leveraging Google Cloud based on “gcloud.go”).
• Mailer: Include the internal/mailer module as the service sending out emails.
• Configuration: Include the configuration module (config/viper.go) that reads environment variables and provides settings across the system.
Relationships and Data Flow
• How the service layer calls the repository layer to interact with the Database.
• Interactions between the authentication module and both the API and service layers.
• Interactions from services to external integrations like the Mailer, Payment Gateway, and Object Storage.
• Optionally, indicate the flow between configuration and all major components that rely on environment setups (e.g., initialization routines in the main function).
Architectural Patterns and Design Principles
• Separation of Concerns: Emphasize three main layers—API/Handler layer, Service/Business Logic layer, and Repository/Data Access layer.
• Clean/Hexagonal Architecture: Indicate that components like authentication, payment, and mailer, though external to the main service logic, are injected into the core functionality, supporting modularity and testability.