Documentation
Home

Database Support

Flexible database layer supporting MongoDB, PostgreSQL, and SQLite.

The Repository Pattern

fe uses a repository pattern to decouple the application logic from the database implementation. This allows you to switch databases with minimal code changes.

The core interfaces are defined in src/lib/database/repositories.

Supported Databases

MongoDBSupabase (PostgreSQL)SQLite

MongoDB

Great for rapid prototyping and flexible data schemas.

env
DATABASE_TYPE=mongodb

Supabase (PostgreSQL)

Robust relational database with built-in auth and realtime capabilities.

env
DATABASE_TYPE=supabase

SQLite

Perfect for local development and small-scale deployments.

env
DATABASE_TYPE=sqlite

Adding a New Repository

To add a new data model (e.g., `Products`), you need to:

  1. Define the interface in src/lib/database/repositories/product-repository.ts.
  2. Implement the adapter for your chosen database (e.g., in src/lib/database/adapters/mongodb/repositories/product-repository.ts).
  3. Register the repository in the main database adapter.