A production-grade NestJS backend with TypeORM multi-database support, Firebase authentication, and offline-first sync capabilities.
- Multi-Database Support: PostgreSQL, MySQL, MariaDB, MSSQL, SQLite, Oracle, CockroachDB
- Firebase Authentication: JWT token validation with automatic user creation
- Multi-Tenancy: Workspace-based isolation with role-based access control
- Offline-First Sync: Conflict resolution with version vectors
- File Management: MinIO S3-compatible storage with image thumbnails
- Real-time Sync: Push/pull synchronization endpoints
- Production Ready: Docker, migrations, comprehensive error handling
- Node.js 18+
- Docker and Docker Compose
- Firebase project with Admin SDK credentials
-
Clone the repository
-
Copy environment variables:
cp .env.example .env
-
Configure your
.env
file with:- Database credentials
- Firebase Admin SDK credentials
- MinIO settings
-
Start with Docker Compose:
docker-compose up -d
-
Run migrations:
npm run migration:run
-
Seed the database:
npm run seed
# Install dependencies
npm install
# Start development server
npm run start:dev
# Run tests
npm run test
# Run e2e tests
npm run test:e2e
Once running, visit http://localhost:3000/api/docs
for Swagger documentation.
- User: Firebase UID mapping to internal user
- Workspace: Multi-tenant isolation
- TableSchema: Dynamic table definitions
- FieldSchema: Field definitions with validation
- DataRow: Actual data with versioning
- SyncLog: Change tracking for sync
The offline-first sync system uses:
- Version Vectors: Track changes per client
- Conflict Resolution: Configurable merge strategies
- Change Log: Append-only sync history
- MinIO: S3-compatible object storage
- Thumbnails: Automatic image thumbnail generation
- Presigned URLs: Secure direct uploads
Configure via DB_TYPE
environment variable:
postgres
- PostgreSQLmysql
- MySQLmariadb
- MariaDBmssql
- Microsoft SQL Serversqlite
- SQLiteoracle
- Oracle Databasecockroachdb
- CockroachDB
# Build and run
docker-compose up -d
# Scale services
docker-compose up -d --scale app=3
Key configuration options:
# Database
DB_TYPE=postgres
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASS=password
DB_NAME=nestjs_backend
# Firebase
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..."
FIREBASE_CLIENT_EMAIL=firebase-adminsdk-...@your-project.iam.gserviceaccount.com
# MinIO
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
GET /auth/me
- Get current user
GET /workspaces
- List workspacesPOST /workspaces
- Create workspaceGET /workspaces/:id
- Get workspacePATCH /workspaces/:id
- Update workspaceDELETE /workspaces/:id
- Delete workspace
GET /workspaces/:id/tables
- List tablesPOST /workspaces/:id/tables
- Create tableGET /workspaces/:id/tables/:tableId/fields
- List fieldsPOST /workspaces/:id/tables/:tableId/fields
- Create field
GET /workspaces/:id/tables/:tableId/rows
- List data rowsPOST /workspaces/:id/tables/:tableId/rows
- Create data rowPATCH /workspaces/:id/tables/:tableId/rows/:rowId
- Update data row
POST /sync/push
- Push local changesGET /sync/pull
- Pull server changes
GET /files/upload-url
- Get presigned upload URL
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE file for details.