🗄️Backend ArchitectureComing Soon
Database Design
MongoDB schema design with Mongoose, virtual fields, and document relationships.
Video coming soon
Add a YouTube video ID to the topics config
Documentation
Overview
Lineup Legends uses MongoDB with Mongoose ODM. The schema design follows a consistent pattern across all models.
Model Pattern
Every model follows this structure:
// 1. API Type — for responses and client-side usage
export interface Player {
id: string;
// ... fields
}
// 2. DB Type — for database operations
export interface PlayerDoc extends Document {
// ... fields (no id)
}
// 3. Schema
const PlayerSchema = new Schema<PlayerDoc>({ ... });
// 4. Virtual id from _id
PlayerSchema.virtual("id").get(function() {
return this._id.toHexString();
});
// 5. Export with hot-reload guard
export const PlayerModel =
mongoose.models.Player ?? mongoose.model("Player", PlayerSchema);
Key Design Decisions
- Dual types — separate API and DB types for type safety across boundaries
- Virtual
id— consistent string ID across all models - Subdocuments — used for embedded data like lineup players and gamble results
- Refs — ObjectId references for relationships (user → lineup, comment → user)
Technical Details
<!-- Add details about indexing strategy, embedding vs referencing decisions, etc. -->Content coming soon — add your video and detailed writeup here.