How ciceksepetitech/sqlapi works
Main Components
• HTTP API Entry Point: Represent the REST API endpoint that accepts POST requests (e.g., at /sql on port 8033, as specified in the README).
• Command Entry/Server Bootstrap: The main entry point is in the “cmd/sqlapi/main.go” file that sets up the HTTP server.
• Database Abstraction / Query Handler: Within the application logic, there is a routing or handler layer that inspects the incoming JSON, extracts the DB credentials, and determines which internal component should execute the query.
• Database-Specific Modules: There are separate internal packages for each supported database:
• internal/mysql for MySQL
• internal/mssql for MSSQL
• internal/mongodb for MongoDB
• Docker/Deployment: The Dockerfile and GitHub Actions workflows indicate the application is containerized and set up for continuous integration.
Relationships and Data Flow
• The client sends an HTTP POST request with required JSON data (credentials and query).
• The API layer (within the main.go that initializes the server) receives and validates the request.
• A controller/handler layer directs the request to the appropriate database module based on the supplied “type” (e.g., “mysql”, “mssql”, or “mongodb”).
• Each internal module contains the logic to establish a connection with the database using the provided credentials, execute the query, and then return the result.
• The API layer converts the query response into JSON and sends it back to the client.
Architectural Patterns and Design Principles
• Separation of Concerns: The clear division between the HTTP server logic (in the cmd folder) and the database access logic (in the internal folder) keeps each responsibility isolated.
• Modular Architecture: Each database type has its own module, which is beneficial for extensibility and maintenance.
• API Gateway Pattern (simplified): The API acts as the single entry point and determines routing based on input data.
• Containerization: Including a Dockerfile shows that the system is deployed as a containerized service.
Relevant Technologies and Frameworks
• Go as the primary programming language with dependency management via go.mod and go.sum.
• Docker for containerization.
• HTTP based interfaces, likely using Go’s http package or a lightweight web framework.
• Integration with MySQL, MSSQL, and MongoDB, with potential use of driver libraries relevant to each.