System Architecture & Platform Infrastructure



1. High-Level Topology



Joy-Quest is designed as a high-performance modular monolith, combining a Go backend engine with a SvelteKit 2 (Svelte 5 runes) web frontend, hosted on the Joymify Kubernetes cluster.

flowchart TB
    subgraph Client["Client Tier"]
        Browser["Learner & Admin Browser"]
    end

subgraph Edge["Ingress & Edge Tier"] Ingress["Ingress Nginx (TLS / cert-manager)<br/>joyquest.joymify.com"] end

subgraph WebTier["Frontend Web Tier (SvelteKit 2 + Svelte 5)"] SK["SvelteKit Node Server (adapter-node)<br/>• Session Cookie Management<br/>• SSR & Hydration<br/>• Bauhaus Design System (joy-design)"] end

subgraph ServiceTier["Go Backend Services"] API["Joy-Quest Go API (:8080)<br/>• RESTful Endpoints<br/>• Personalization Engine<br/>• Auth & RBAC Guards<br/>• Diagnostic Grader"] Worker["Joy-Quest Go Worker<br/>• Background Topic Builder<br/>• AI Research & Grounding<br/>• Quiz Generator<br/>• FSRS Review Scheduler"] end

subgraph Persistence["Storage & Persistence"] PG[("PostgreSQL 15 (joyquest)<br/>• Least-privilege roles (joyquest_app / owner)<br/>• ACID job queue (FOR UPDATE SKIP LOCKED)<br/>• FSRS memory states & Knowledge DAGs")] end

subgraph Ecosystem["Joymify Platform Ecosystem"] SSO["Joymify SSO (auth.joymify.com / user-api)<br/>• OAuth2 & Session Exchange"] DataJoymify["data-joymify<br/>• Telemetry & Learning Lakehouse"] AssetStudio["asset-studio<br/>• Generative Concept Diagrams & Badges"] end

Browser -->|HTTPS| Ingress Ingress --> SK SK -->|Login Redirect| SSO SK -->|Exchange Token| SSO SK -->|Internal JSON API with Bearer JWT| API API --> PG Worker -->|Claim Jobs via SKIP LOCKED| PG Worker --> Ecosystem API --> Ecosystem


---

2. Platform Infrastructure Components



2.1 Backend Architecture (Go)

  • Executable Binaries:
  • cmd/api: Exposes REST endpoints on port 8080.
  • cmd/worker: Background engine processing generation and review jobs.
  • cmd/migrate: Goose-based database schema migration runner.
  • cmd/seed: Dev/test fixture seeder (//go:build dev).
  • cmd/ssostub: Local standalone mock SSO provider (//go:build dev).
  • Internal Modules:
  • internal/personalization: Knowledge DAG evaluation, FSRS-v4 spaced repetition scheduler, cognitive load optimizer.
  • internal/grading: Pure deterministic progress, streaks, study minutes, quiz scoring.
  • internal/ai: Multi-provider abstraction (Anthropic Claude 3.5 Sonnet + Google Gemini 2.0 / 1.5 Pro) with automatic fallback.
  • internal/grounding: Source research, URL verification, citation extraction.
  • internal/store/db: Strongly-typed sqlc-generated database queries.


  • 2.2 Frontend Architecture (SvelteKit 2 + Svelte 5 Runes)

  • Language: TypeScript 5.5+ with strict type checking.
  • Reactivity Model: Svelte 5 Runes ($state, $derived, $effect, $props).
  • Design Tokens: Strict Bauhaus visual system (primary crimson #E53935, deep navy #1E3A8A, rich amber #F59E0B, bone background #F8F9FA).
  • Session Layer: Server-side hooks (hooks.server.ts) validate JWTs against the Go API, maintaining HTTP-only joy_session cookies.


  • ---

    3. Database Schema & Domain Entities



    erDiagram
        TOPIC ||--o{ MODULE : contains
        MODULE ||--o{ LESSON : contains
        MODULE ||--o{ QUIZ : assesses
        QUIZ ||--o{ QUESTION : contains
        TOPIC ||--o{ ENROLMENT : has
        MEMBER ||--o{ ENROLMENT : joins
        MEMBER ||--o{ PROGRESS_EVENT : records
        MEMBER ||--o{ ATTEMPT : submits
        MEMBER ||--o{ NOTE : writes
        MEMBER ||--o{ CONCEPT_STATE : tracks
        ATTEMPT ||--o{ ANSWER : includes
        TOPIC ||--o{ BUILD_JOB : produces

    TOPIC { uuid id PK string slug string title string description string visibility uuid author_id timestamp created_at }

    MODULE { uuid id PK uuid topic_id FK int position string title }

    LESSON { uuid id PK uuid module_id FK int position string title text content jsonb sources string status }

    CONCEPT_STATE { uuid id PK uuid member_id FK string concept_key float stability float difficulty int reps int lapses timestamp due_at timestamp last_reviewed_at }


    ---

    4. Ecosystem Integrations



    4.1 Joymify SSO Integration

    Joy-Quest delegates identity to the shared Joymify SSO: 1. Browser hits protected route -> SvelteKit redirects to auth.joymify.com/login?redirect_uri=.... 2. On successful auth, SSO returns auth code/token to /auth/callback. 3. SvelteKit server exchanges token with user-api and mints signed joy_session cookie. 4. SvelteKit forwards verified user context (X-User-ID, X-User-Role, Bearer JWT) to Go API.

    4.2 data-joymify Telemetry Pipeline

  • Learner telemetry events (card flips, answer timings, cognitive friction pauses) are buffered in memory and batched to data-joymify HTTP/Kafka endpoint.
  • Aggregated insights feed back into personal retention models.


  • 4.3 asset-studio Generative Visuals

  • For complex technical algorithms (e.g., Trie search, Raft log compaction), the worker sends an asset generation prompt to asset-studio.
  • Generated SVG diagrams are cached, validated for accessibility, and embedded into lesson markdown.