This repository is a template for running a multi-tenant application with SvelteKit, leveraging a landlord-tenant architecture where each tenant has its own isolated database. This approach ensures data security and separation for each client.
Warning
This template is still in development, this readme is more so a place holder for later.
- Clone the Repository
git clone <repository-url>
cd <repository-folder>
- Start the Database
Navigate to the
./docker/
folder and run the following command to spin up the database using Docker Compose:
docker-compose up -d
- Generate your first migration In order for the database to have the current schema run:
# Generate a initial migration
bun run landlord:migration
# Seed the database with utility functions and stuff
bun run landlord:seed
# Apply all or the current migration
# NOTE: You can pass any of drizzles arguments to migrate (e.g: --name "xyz")
bun run landlord:migrate
- Run the Development Server Start the development server with Bun:
bun run dev
-
Run Database Migrations
After the database is running, apply migrations for the landlord database:
bun run landlord:migrate
-
Seed the Landlord Database
Seed the landlord database with initial data:
bun run landlord:seed
After setting up the landlord, you can create tenants, and each tenant will run on its own database. Ensure that tenant migrations are applied appropriately using Drizzle ORM.
- Start Tenant-Specific Database: Once a tenant is created, use tenant-specific migration commands similar to the landlord.
- Run in Production: Use
bun run build
for building the project and start it withbun run start
.
- Bun: A modern runtime for running JavaScript and TypeScript applications.
- SvelteKit: Reactive framework for building web applications.
- Tailwind CSS: Utility-first CSS for styling.
- ShadCN UI: UI component library for modern design.
- Drizzle ORM: Manage database schemas and migrations.
- Be sure to run the Docker containers to set up the database correctly before starting the server.
- Migrations and seeds are essential to configure the landlord's database before onboarding tenants.
Enjoy building your multi-tenant SvelteKit application with this template!