Skip to content

LingoLM-9#30

Open
OuiHui wants to merge 1 commit into
developmentfrom
LingoLM-9
Open

LingoLM-9#30
OuiHui wants to merge 1 commit into
developmentfrom
LingoLM-9

Conversation

@OuiHui

@OuiHui OuiHui commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR implements a production-ready card templating and persistence system for LingoLM. The system provides a clean architecture for creating language learning cards from AI-generated linguistic data and storing them in user profiles.

Key Components:

  • Type System - Comprehensive TypeScript interfaces for BaseCardInput and BaseCard
  • Templating Service - Pure functions that convert raw linguistic data into structured JSON cards
  • Storage Abstraction - Database-agnostic interface with in-memory implementation
  • RESTful API - Complete CRUD endpoints for card management
  • Input Validation - Robust validation with descriptive error messages

Architecture Highlights:

  • Clean separation of concerns (templating, storage, API)
  • Storage provider pattern for easy database swapping
  • Immutable card design with versioning support
  • Type-safe throughout with full TypeScript support

Type of change

  • New feature
  • Bug fix
  • Breaking change
  • Documentation update

Files Added

Core Services

  • app/lib/types/card.types.ts - TypeScript interfaces for cards and user profiles
  • app/lib/services/cardTemplating.ts - Card creation and validation functions
  • app/lib/services/cardStorage.ts - Storage abstraction and in-memory implementation
  • app/lib/services/README.md - Service documentation

API Endpoints

  • app/app/api/cards/route.ts - POST (create), GET (list all)
  • app/app/api/cards/[cardId]/route.ts - GET (retrieve), PUT (update), DELETE (remove)

Configuration

  • app/.env.example - Environment configuration template

API Endpoints

POST   /api/cards          - Create new card
GET    /api/cards          - Get all user's cards  
GET    /api/cards/:id      - Get specific card
PUT    /api/cards/:id      - Update card (versioned)
DELETE /api/cards/:id      - Delete card

Example Usage

import { createBaseCard } from "@/lib/services/cardTemplating";
import { getCardStorage } from "@/lib/services/cardStorage";

// Create a card from AI-generated data
const card = createBaseCard({
  language: "Spanish",
  lemma: "hablar",
  partOfSpeech: "verb",
  definitions: [{ definition: "to speak, to talk" }],
  examples: [{ sentence: "Ella habla tres idiomas." }],
  ipa: "aˈβlaɾ"
});

// Save to user profile
const storage = getCardStorage();
await storage.saveCard("user-123", card);

Manual Testing Needed:

  • Test POST /api/cards with sample data
  • Test GET /api/cards retrieval
  • Test PUT /api/cards/:id update with versioning
  • Test DELETE /api/cards/:id removal
  • Verify in-memory storage persists across requests (within session)

@OuiHui OuiHui changed the title type shi LingoLM-9 Feb 7, 2026
@OuiHui OuiHui linked an issue Feb 7, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create doc templating function in Lambda for generating cards

1 participant