A multi-tenant, headless booking microservice built with SvelteKit 2.0, Svelte 5, TypeScript, and MySQL. This system provides a RESTful API for managing bookings, resources, and calendar views across multiple tenants.
ā Complete multi-tenant booking system ready for production use!
61d98f73-6746-4700-b388-93bd9de72801.uydigcx8engdm4az6mjhc
[email protected]
/ demo123
# Health check
curl "http://localhost:5173/api/health"
# List resources
curl "http://localhost:5173/api/resources?api_key=61d98f73-6746-4700-b388-93bd9de72801.uydigcx8engdm4az6mjhc"
# Run full API test suite
npm run test:api
Clone and install dependencies:
git clone <repository-url>
cd booking-microservice
npm install
Set up environment variables:
cp .env.example .env
# Edit .env with your database credentials
Set up the database:
# Create database and run migrations
npm run db:migrate
# Seed with demo data
npm run db:seed
Start the development server:
npm run dev
The service will be available at http://localhost:5173
# Start MySQL and the booking service
docker-compose up -d
# The service will be available at http://localhost:3000
X-API-Key: your-tenant-api-key
?api_key=your-tenant-api-key
Authorization: Bearer your-jwt-token
GET /api/bookings # List bookings
POST /api/bookings # Create booking
GET /api/bookings/{id} # Get booking details
PUT /api/bookings/{id} # Update booking
DELETE /api/bookings/{id} # Cancel booking
GET /api/resources # List resources
GET /api/resources/{id}/availability # Check availability
GET /api/calendar # Calendar view
curl -X POST "http://localhost:5173/api/bookings" \\
-H "X-API-Key: your-api-key" \\
-H "Content-Type: application/json" \\
-d '{
"resourceId": "resource-uuid",
"title": "Team Meeting",
"description": "Weekly team standup",
"startTime": "2024-01-15T09:00:00Z",
"endTime": "2024-01-15T10:00:00Z"
}'
curl "http://localhost:5173/api/resources/{resource-id}/availability?start_date=2024-01-15&end_date=2024-01-16&duration=60&api_key=your-api-key"
curl "http://localhost:5173/api/calendar?month=2024-01&api_key=your-api-key"
All data is isolated by tenant_id
. Every query includes tenant filtering to ensure complete data separation.
# Database
DB_HOST=localhost
DB_PORT=3306
DB_USER=booking_user
DB_PASSWORD=secure_password
DB_NAME=booking_microservice
# Security
JWT_SECRET=your-super-secret-jwt-key
# Server
NODE_ENV=development
PORT=5173
src/
lib/
server/
auth.ts # Authentication utilities
booking-service.ts # Core booking logic
database.ts # Database connection
middleware.ts # API middleware
types.ts # TypeScript definitions
routes/
api/
bookings/ # Booking endpoints
resources/ # Resource endpoints
calendar/ # Calendar endpoints
+page.svelte # Demo UI
src/lib/types.ts
src/lib/server/
src/routes/api/
schema.sql
# Run migrations
npm run db:migrate
# Seed demo data
npm run db:seed
JWT_SECRET
# Build and deploy
docker-compose -f docker-compose.yml up -d
MIT License - see LICENSE file for details
After running npm run db:seed
:
[email protected]
/ demo123
Built with ā¤ļø using SvelteKit, Svelte 5, and modern web technologies.