-
Notifications
You must be signed in to change notification settings - Fork 0
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.
Client Application
│
HTTP Request
│
▼
API Entry Point
│
▼
Request Validation
│
▼
Configuration Manager
│
▼
Query Loader Engine
│
▼
Parameter Binding Engine
│
▼
SQL Execution Engine
│
▼
Response Generator
│
▼
JSON Response
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
The Validation Engine ensures that every request is valid before execution.
Responsibilities:
- Validate JSON
- Check required fields
- Validate parameters
- Verify query existence
The Configuration Manager loads application settings.
Responsibilities:
- Read database configuration
- Load framework settings
- Initialize database connection
The Query Loader locates and loads SQL files.
Example:
queries/customers.sql
Responsibilities:
- Locate SQL files
- Read SQL content
- Handle missing files
The Parameter Binding Engine safely injects request parameters into SQL queries.
Responsibilities:
- Bind parameters
- Prevent SQL injection
- Validate parameter values
The SQL Execution Engine communicates with SQL Server.
Responsibilities:
- Open database connection
- Execute SQL queries
- Return result sets
- Handle execution errors
The Response Generator converts database results into a standard JSON response.
Example:
{
"success": true,
"data": []
}Responsibilities:
- Format responses
- Include metadata
- Handle error responses
A typical request follows these steps:
- Client sends a JSON request.
- API receives the request.
- Validation Engine validates the request.
- Configuration Manager loads database settings.
- Query Loader reads the SQL file.
- Parameter Binding Engine binds input parameters.
- SQL Execution Engine runs the query.
- Response Generator formats the output.
- JSON response is returned to the client.
Generic_SQL_API_Framework/
├── api/
├── config/
├── queries/
├── docs/
├── logs/
├── public/
├── assets/
├── index.php
└── README.md
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
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
The architecture provides:
- Clean separation of responsibilities
- Easier maintenance
- Better scalability
- Improved testability
- Simplified debugging
- Reusable components
Explore the remaining documentation:
- Contributing
- Troubleshooting
- Frequently Asked Questions
- Roadmap
- Changelog