Repository navigation
Schema Design
- Introduction
- Multi-Database Architecture
- PostgreSQL Schema (Primary)
- MongoDB Schema (Specialized)
- Cassandra Schema (Messaging)
- Schema Evolution & Migration
- Conclusion
PersonalLearningPro uses a multi-database strategy to handle diverse workloads: relational business logic (PostgreSQL), flexible document storage (MongoDB), and high-throughput messaging (Cassandra).
| Storage | Purpose | Tech Stack |
|---|---|---|
| PostgreSQL | Transactions, Tenancy, Sessions, Billing | SQL / Drizzle-style Relational |
| MongoDB | Tests, Questions, Analytics, State | NoSQL Document Store |
| Cassandra | Real-time Chat, Activity Streams | Time-series Wide Column |
The source of truth for all "Identity" and "Tenancy" data.
Relational user data replacing the legacy Firebase-only model.
-
id:bigserial -
email:citext(Hashed/Indexed) -
password_hash:text(Bcrypt) -
email_verified:boolean
Containers for organizational data.
-
id:bigserial -
slug:text(Unique, indexed for URL lookup) -
owner_id:bigint(FK tousers.id)
Maps users to workspaces with roles (owner, admin, member).
Server-side session tracking for secure logout and token rotation.
Used for data that is deeply nested or requires frequent schema updates without migrations.
-
Tests: Contains metadata about an assessment. -
Questions: Stores rich content (MCQs, text, rubrics). -
Analytics: Stores complex JSON insights from AI evaluations.
Optimized for "Write-once, Read-often" chat data.
-
messages: Partitioned bychannel_id, clustered bymessage_id(Snowflake). -
read_by: Tracked via set/list column types for high concurrency.
-
PostgreSQL: Managed via
scripts/pg-schema.sqlandpg-migrate.ts. - MongoDB: Schema-less but validated via Zod at the application layer.
-
Cassandra: Evolution via
ALTER TABLEcommands in the deployment pipeline.
By segregating data into three distinct layers, PersonalLearningPro ensures that identity management is robustly relational, content is flexible and document-oriented, and communication is highly performant and scalable.