From 811458427593a4172a2cd535cc768db375350dca Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 6 Dec 2025 17:05:21 +0900 Subject: feat(dev): change architecture and directory structure --- src/server/types/index.ts | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 src/server/types/index.ts (limited to 'src/server/types/index.ts') diff --git a/src/server/types/index.ts b/src/server/types/index.ts new file mode 100644 index 0000000..bfba06f --- /dev/null +++ b/src/server/types/index.ts @@ -0,0 +1,79 @@ +// Card states for FSRS algorithm +export const CardState = { + New: 0, + Learning: 1, + Review: 2, + Relearning: 3, +} as const; + +export type CardState = (typeof CardState)[keyof typeof CardState]; + +// Rating values for reviews +export const Rating = { + Again: 1, + Hard: 2, + Good: 3, + Easy: 4, +} as const; + +export type Rating = (typeof Rating)[keyof typeof Rating]; + +// User +export interface User { + id: string; + username: string; + passwordHash: string; + createdAt: Date; + updatedAt: Date; +} + +// Deck +export interface Deck { + id: string; + userId: string; + name: string; + description: string | null; + newCardsPerDay: number; + createdAt: Date; + updatedAt: Date; + deletedAt: Date | null; + syncVersion: number; +} + +// Card with FSRS fields +export interface Card { + id: string; + deckId: string; + front: string; + back: string; + + // FSRS fields + state: CardState; + due: Date; + stability: number; + difficulty: number; + elapsedDays: number; + scheduledDays: number; + reps: number; + lapses: number; + lastReview: Date | null; + + createdAt: Date; + updatedAt: Date; + deletedAt: Date | null; + syncVersion: number; +} + +// ReviewLog (append-only) +export interface ReviewLog { + id: string; + cardId: string; + userId: string; + rating: Rating; + state: CardState; + scheduledDays: number; + elapsedDays: number; + reviewedAt: Date; + durationMs: number | null; + syncVersion: number; +} -- cgit v1.2.3-70-g09d2