Database Design
Tarasol employs a multi-database strategy with tenant isolation at the database level. The system uses five distinct data stores, each optimized for its specific use case.
Database Technologies
| Technology | Purpose | Services |
|---|---|---|
| Microsoft SQL Server | Primary relational database | Most services |
| MongoDB | Document store | Identity, Post Office, Session Manager |
| Redis | Cache & session store | All services |
| Elasticsearch | Search indexing & logging | Search, Monitoring |
| File System | Media storage | Media Service |
Multi-Tenant Architecture
Multi-Tenant Database Architecture
Loading diagram...
Key Databases
| Database | Purpose |
|---|---|
Tarasol.MultiTenancy | Central tenant configuration and provisioning |
Tarasol.Administration | Users, permissions, organizational hierarchy |
Tarasol.[TenantName] | Tenant-specific business data (isolated) |
Connection Pooling
| Name | Type | Default | Description |
|---|---|---|---|
| max | number | 10 | Maximum connections per pool |
| min | number | 5 | Minimum connections per pool |
| idle | number | 10000 | Idle timeout in milliseconds |
| acquire | number | 30000 | Acquire timeout in milliseconds |
MongoDB Usage
MongoDB is used for services that require flexible document schemas:
- Identity Service — User accounts, credentials, device tokens
- Post Office — External mail records with variable metadata
- Session Manager — Active session tracking with TTL
The ODM layer is Mongoose with schema validation.
Redis Caching Strategy
Redis serves multiple roles across the platform:
| Use Case | TTL | Service |
|---|---|---|
| User profiles | 5 min | Profile Service |
| User preferences | 10 min | Profile Service |
| Avatar URLs | 1 hour | Profile Service |
| Session data | Variable | Gateway, Identity |
| Tenant config | 5 min | All services |
| Token blacklist | Token expiry | Identity |
✓Tip
Redis connections are configured via REDIS_HOST and REDIS_PORT environment variables. The default port is 6379.
ORM Layer
| ORM | Database | Usage |
|---|---|---|
| Sequelize | MSSQL | Primary ORM for all NestJS services |
| Mongoose | MongoDB | ODM for Identity and related services |
All Sequelize models use TypeScript decorators for schema definition, with migrations managed per-tenant.