Core Concepts
import { Card, CardGrid } from ‘@astrojs/starlight/components’;
MiniGateway is built around a few core concepts that make it flexible and powerful.
Architecture Overview
Section titled “Architecture Overview”MiniGateway follows a modular architecture with three main components:
Routing
Section titled “Routing”Routes define how incoming requests are matched and forwarded to target services.
Route Matching
Section titled “Route Matching”Routes are matched using path patterns with support for:
- Exact matching:
/api/usersmatches exactly that path - Wildcard matching:
/api/*matches any path starting with/api/ - Parameter matching:
/api/users/:idextractsidas a parameter
Route Configuration
Section titled “Route Configuration”Each route can be configured with:
| Property | Description |
|---|---|
path | The incoming path pattern to match |
target | The destination URL to proxy to |
methods | HTTP methods to allow (GET, POST, etc.) |
plugins | Plugins to apply for this route |
timeout | Request timeout in milliseconds |
Plugins
Section titled “Plugins”Plugins extend MiniGateway’s functionality. They can be applied globally or to specific routes.
Built-in Plugins
Section titled “Built-in Plugins”| Plugin | Purpose |
|---|---|
auth | Authentication and authorization |
rate-limit | Request rate limiting |
transform | Request/response transformation |
cache | Response caching |
logger | Request logging |
Custom Plugins
Section titled “Custom Plugins”You can create custom plugins by implementing the Plugin interface:
interface Plugin { name: string; onRequest?: (context: RequestContext) => Promise<void>; onResponse?: (context: ResponseContext) => Promise<void>;}Storage
Section titled “Storage”MiniGateway uses a database for storing configuration and runtime data.
Supported Databases
Section titled “Supported Databases”- SQLite: Local development and small deployments
- LibSQL: Turso/LibSQL for distributed edge deployments
- PostgreSQL: Enterprise deployments (planned)
Schema
Section titled “Schema”The core schema includes:
routes: Route definitionsplugins: Plugin configurationslogs: Request/response logsmetrics: Performance metrics