Generic SQL API Framework is a PHP backend framework for building database APIs without creating a separate backend implementation for every query.
The framework accepts structured JSON requests, validates the request, builds SQL dynamically, executes the query through the database layer, and returns a JSON response.
The current implementation is focused on Microsoft SQL Server through ODBC.
In a traditional application, adding a new query often means:
- Write the SQL query.
- Create a backend endpoint.
- Add request validation.
- Add database execution code.
- Format the response.
- Repeat the same process for the next query.
As the number of queries increases, this creates repeated backend code.
This framework moves the common query work into a reusable backend engine.
Instead of creating a new backend endpoint for every SELECT query, an application can send a structured JSON request describing the required data.
A request describes the required query using JSON.
Example:
{
"controller": "Query",
"action": "select",
"table": "CustomerTable",
"columns": [
"Cust_Name",
"Phone"
]
}The backend processes the request and generates the required SQL.
Client
|
v
JSON Request
|
v
API Controller
|
v
Validation
|
v
Query Repository
|
v
Query Engine
|
v
Database
|
v
JSON Response
This repository provides the backend API and database layer.
It is responsible for:
- API request handling
- Request validation
- SQL generation
- Database connectivity
- Query execution
- Database metadata access
- Query logging
- Query statistics
- Database-specific connectivity
The frontend is a separate project.
This repository does not provide:
- Dashboard UI
- Chart components
- Report screens
- Frontend routing
- Frontend state management
- Website design
Applications can consume this API from any frontend or client application capable of making HTTP requests.
The current database implementation targets:
Microsoft SQL Server
Database connectivity is handled through:
ODBC
The database layer is kept separate from the query-building layer so additional database providers can be introduced later.
The project is designed to:
- Reduce repeated backend query code.
- Keep database access centralized.
- Provide a consistent JSON request structure.
- Validate requests before database execution.
- Use prepared SQL execution where applicable.
- Keep database-specific logic isolated.
- Make the backend reusable across different applications.
The API can be used as a backend for:
- ERP systems
- POS systems
- Inventory applications
- Accounting applications
- Courier and logistics applications
- Internal business applications
- MIS applications
- Web applications
- Mobile applications
The consuming application remains responsible for its own user interface.
The repository includes a prebuilt Windows PHP runtime.
When using the bundled runtime, PHP does not need to be installed separately on the system.
Start the API from the project root:
start-windows.batThe startup script checks the runtime, ODBC extension, database connection, required directories, and available port before starting the API.
See Hosting.
| Document | Purpose |
|---|---|
| Architecture | Internal framework structure and request flow |
| API | HTTP API and endpoint usage |
| JSON Request Reference | JSON request fields and structure |
| Query Examples | Practical query examples |
| Database Configuration | Database and ODBC configuration |
| Hosting | Running and deploying the backend |
| Roadmap | Planned backend versions |
| Contributing | Development and contribution guidelines |
| Changelog | Release history |
To understand how the framework is structured internally, see Architecture.