How kma-score/kma_score_api works
Main Components
• Client/Consumer: Represent external clients (web/mobile applications) that send HTTP requests.
• API Gateway/Entry Point: The main.go file acts as the entry point to the Go application. Represent this as the “API Server.”
• Business Logic / Models: Include the “models” (Student, Score, Subject, ApiKey, etc) that encapsulate the domain entities.
• Database Access: Add a block for the “database” package, which contains the database connection logic (database.go) that connects to MariaDB/MySQL.
• Cron Jobs & Integration Tasks: Represent the “cron” component (with files like init.go and update_meilisearch.go) which schedule and execute tasks (such as updating Meilisearch indices).
• Configuration & Utilities: Create a section for “config” (for Meilisearch configuration) and “utils”, where functionalities like JWT management, AES encryption, file handling, and Meilisearch integration are implemented.
• External Services:
• Database Server: MariaDB/MySQL as the persistent store.
• Meilisearch: Represent this external search service which the API interacts with.
• Deployment/Containerization:
• Docker & Docker Compose: Indicate that the system is containerized. This can be represented by a container symbol around the API and its related components, with additional references to deployment automation (GitHub workflows).
Relationships and Interactions
• That requests pass through the Middlewares (API checker, CORS, rate limiter, logging) before reaching the Handlers.
• The Database component (showing CRUD operations).
• The Meilisearch service (for search functionality, via utilities and cron tasks).
Architectural Patterns and Design Principles
• Modularity: Emphasize separation of concerns, with distinct packages for handlers, middlewares, models, utilities, database access, and cron jobs.
• Layered Architecture: Illustrate layers from presentation (HTTP handlers) to business logic (models and utils) and data access (database).
• Containerization: Indicate Docker-based deployment as a separate layer for operational management.
• Integration with External Services: Clearly separate external dependencies such as the database and external search service, noting that while the API service is monolithic, it relies on clearly defined external services.
Relevant Technologies
• Mention Docker in the deployment section along with docker-compose orchestration.