How to work without a direct database connection
mainBy default, AdminForth connects directly to databases like PostgreSQL, MySQL, ClickHouse, or MongoDB. However, you can decouple AdminForth from your database by routing all read and write operations through an external API layer (such as REST, GraphQL, or JSON-RPC).
Why use an API-backed approach?
- Enforced Constraints: Your API can enforce custom validation rules that exist outside the database schema.
- Advanced Auditing: While AdminForth has a built-in
AuditLogfor data modifications, using an API allows you to log all operations, including read operations, via your own logging systems. - Complex Logic: You can trigger distributed workflows or complex business logic during data mutations that the database layer alone cannot handle.
- Unsupported Databases: If you need to use a database not natively supported by AdminForth, you can implement a custom adapter.
Implementation Strategy
To implement this, you must extend the AdminForth data connector class and implement the specific methods responsible for data access (reads) and mutations (writes). This effectively turns AdminForth into a consumer of your API rather than a direct database client.