Skip to content

Framework Architecture

Shashank Patil edited this page Jul 26, 2026 · 1 revision

Framework Architecture

The Generic SQL API Framework follows a modular architecture where each component has a single responsibility. This design makes the framework easy to maintain, extend, and debug.


Architecture Overview

                Client Application
                       │
                 HTTP Request
                       │
                       ▼
                API Entry Point
                       │
                       ▼
             Request Validation
                       │
                       ▼
           Configuration Manager
                       │
                       ▼
              Query Loader Engine
                       │
                       ▼
           Parameter Binding Engine
                       │
                       ▼
           SQL Execution Engine
                       │
                       ▼
             Response Generator
                       │
                       ▼
               JSON Response

Core Components

API Entry Point

The entry point receives incoming HTTP requests and routes them to the appropriate handler.

Responsibilities:

  • Receive HTTP requests
  • Parse JSON payloads
  • Forward requests for validation

Validation Engine

The Validation Engine ensures that every request is valid before execution.

Responsibilities:

  • Validate JSON
  • Check required fields
  • Validate parameters
  • Verify query existence

Configuration Manager

The Configuration Manager loads application settings.

Responsibilities:

  • Read database configuration
  • Load framework settings
  • Initialize database connection

Query Loader

The Query Loader locates and loads SQL files.

Example:

queries/customers.sql

Responsibilities:

  • Locate SQL files
  • Read SQL content
  • Handle missing files

Parameter Binding Engine

The Parameter Binding Engine safely injects request parameters into SQL queries.

Responsibilities:

  • Bind parameters
  • Prevent SQL injection
  • Validate parameter values

SQL Execution Engine

The SQL Execution Engine communicates with SQL Server.

Responsibilities:

  • Open database connection
  • Execute SQL queries
  • Return result sets
  • Handle execution errors

Response Generator

The Response Generator converts database results into a standard JSON response.

Example:

{
    "success": true,
    "data": []
}

Responsibilities:

  • Format responses
  • Include metadata
  • Handle error responses

Request Lifecycle

A typical request follows these steps:

  1. Client sends a JSON request.
  2. API receives the request.
  3. Validation Engine validates the request.
  4. Configuration Manager loads database settings.
  5. Query Loader reads the SQL file.
  6. Parameter Binding Engine binds input parameters.
  7. SQL Execution Engine runs the query.
  8. Response Generator formats the output.
  9. JSON response is returned to the client.

Project Structure

Generic_SQL_API_Framework/

├── api/
├── config/
├── queries/
├── docs/
├── logs/
├── public/
├── assets/
├── index.php
└── README.md

Design Principles

The framework is built around the following principles:

  • Modular architecture
  • Separation of concerns
  • Configuration over hardcoding
  • Secure by default
  • Reusable SQL files
  • Consistent JSON responses

Extending the Framework

The modular design allows new functionality to be added without affecting existing components.

Examples:

  • Support for additional databases
  • Authentication modules
  • Query caching
  • Custom validators
  • Logging providers
  • Report generation
  • Plugin system

Benefits

The architecture provides:

  • Clean separation of responsibilities
  • Easier maintenance
  • Better scalability
  • Improved testability
  • Simplified debugging
  • Reusable components

Next Steps

Explore the remaining documentation:

  • Contributing
  • Troubleshooting
  • Frequently Asked Questions
  • Roadmap
  • Changelog

Clone this wiki locally