# genesis-ai-dev/langquest architecture

> Architecture diagram of the GitHub repository genesis-ai-dev/langquest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/genesis-ai-dev/langquest
- Repository: https://github.com/genesis-ai-dev/langquest

## Overview

##### Project type and purpose
- LangQuest is a full-stack, offline-first mobile application (built with Expo/React Native) for collaborative language translation.
- The README describes local development with Docker + Supabase, use of PowerSync for offline sync, Drizzle for schema, and Expo Application Services (EAS) for CI/CD and builds.

##### File structure
- Top-level “app”, “components”, “views”, “navigators”, “contexts”, “hooks”, “providers” directories → client UI, navigation, and state layers.
- “database_services”, “db”, “drizzle”, “supabase” → data access layer, local schema definitions, migration scripts, Supabase backend (Postgres, Edge Functions, RLS).
- “supabase/functions” → Deno-based Edge Functions (clone-worker, send-email, sqltr).
- “.github/workflows”, “eas.json”, “tooling/github” → CI/CD pipelines (GitHub Actions, EAS preview/production deploy).
- “assets”, “supabase/assets” → static assets stored locally and in Supabase storage for audio/images.
- Config files (“app.config.ts”, “drizzle.config.ts”, “supabase/config.yml”) define runtime and sync settings.

##### README for additional insights
- Describes local dev environment orchestration (`npm run env` brings up Supabase/Postgres with Docker Compose).
- PowerSync replicates tables between remote and local DB.
- Supabase migrations and seeds under version control.
- Supabase Auth, Storage, Realtime, Edge Functions are core backend services.
- EAS build process for Android APKs and CI integration points.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        subgraph "Expo App" 
            direction TB
            Layout["_layout.tsx"]:::frontend
            Index["index.tsx"]:::frontend
            ResetPwd["reset-password.tsx"]:::frontend
            Terms["terms.tsx"]:::frontend
        end
        subgraph "Views (screens)" 
            direction TB
            Views["views/*.tsx"]:::frontend
        end
        subgraph "Components" 
            direction TB
            UIComp["components/*.tsx"]:::frontend
            NavComp["TabBarIcon.tsx"]:::frontend
            QuestComp["components/questsComponents"]:::frontend
        end
        subgraph "Navigators"
            AuthNav["AuthNavigator.tsx"]:::frontend
        end
    end

    %% Business Logic & State
    subgraph "Business Logic & State"
        direction TB
        subgraph Contexts
            AuthCtx["AuthContext.tsx"]:::logic
            AudioCtx["AudioContext.tsx"]:::logic
            PHCtx["PostHogProvider.tsx"]:::logic
            StatusCtx["StatusContext.tsx"]:::logic
        end
        subgraph Hooks
            DBHooks["hooks/db/*.ts"]:::logic
            SyncHook["useSyncState.ts"]:::logic
            HybridQ["useHybridQuery.ts"]:::logic
            HSupabase["useHybridSupabaseQuery.ts"]:::logic
        end
        Provider["QueryProvider.tsx"]:::logic
        Services["services"]:::logic
        Store["store"]:::logic
    end

    %% Local Persistence Layer
    subgraph "Local Persistence Layer"
        direction TB
        SQLite["SQLite DB Files"]:::local
        subgraph Drizzle
            SchemaLocal["db/drizzleSchema.ts"]:::local
            SchemaGen["drizzle/schema.ts"]:::local
            Relations["drizzle/relations.ts"]:::local
        end
        subgraph PowerSync
            AbsQueue["AbstractSharedAttachmentQueue.ts"]:::local
            PermQueue["PermAttachmentQueue.ts"]:::local
            TempQueue["TempAttachmentQueue.ts"]:::local
            SysSync["system.ts"]:::local
        end
        subgraph DBServices
            DataSvc["database_services/*.ts"]:::local
            StatusSvc["database_services/status"]:::local
        end
    end

    %% Remote Backend
    subgraph "Remote Backend (Supabase)"
        direction TB
        Configs["supabase/config*.yml & toml"]:::remote
        subgraph Migrations/Seeds
            Migs["migrations/*.sql"]:::remote
            Seeds["seeds/*.sql"]:::remote
            StorageSchema["schemas/storage.sql"]:::remote
        end
        subgraph EdgeFunctions
            CloneWF["clone-worker/index.ts"]:::remote
            SendEmail["send-email/index.ts"]:::remote
            EmailTpl["send-email/_templates"]:::remote
            SQLTR["sqltr/index.ts"]:::remote
        end
        Storage["Storage (audio/images)"]:::remote
        Postgres["Postgres DB"]:::remote
        Realtime["Realtime & PowerSync Pub/Sub"]:::remote
        AuthAPI["Auth & API Endpoints"]:::remote
    end

    %% External Services
    subgraph "External Services"
        direction TB
        PostHog["PostHog Analytics"]:::external
        EAS["Expo Application Services"]:::external
    end

    %% CI/CD & DevOps
    subgraph "CI/CD & DevOps"
        direction TB
        GHActions[".github/workflows"]:::devops
        EASFlows[".eas/workflows"]:::devops
        Tooling["tooling/github"]:::devops
    end

    %% Connections
    Index -->|uses| AuthCtx
    Views -->|renders| UIComp
    UIComp -->|navigates| AuthNav
    AuthCtx -->|provides| Services
    Services -->|CRUD| DataSvc
    DataSvc -->|reads/writes| SQLite
    DataSvc -->|schema| SchemaLocal
    SQLite <-->|sync| Realtime
    Realtime <-->|replicate| Postgres
    SysSync -->|orchestrates| Realtime
    Index -->|calls Edge Functions| CloneWF
    Index -->|uploads/downloads| Storage
    Index -->|tracks| PostHog
    GHActions -->|triggers| EASFlows
    GHActions -->|deploys| Migs
    EASFlows -->|builds| Index

    %% Click Events
    click Layout "https://github.com/genesis-ai-dev/langquest/blob/dev/app/_layout.tsx"
    click Index "https://github.com/genesis-ai-dev/langquest/blob/dev/app/index.tsx"
    click ResetPwd "https://github.com/genesis-ai-dev/langquest/blob/dev/app/reset-password.tsx"
    click Terms "https://github.com/genesis-ai-dev/langquest/blob/dev/app/terms.tsx"
    click Views "https://github.com/genesis-ai-dev/langquest/tree/dev/views"
    click UIComp "https://github.com/genesis-ai-dev/langquest/tree/dev/components"
    click NavComp "https://github.com/genesis-ai-dev/langquest/blob/dev/components/navigation/TabBarIcon.tsx"
    click QuestComp "https://github.com/genesis-ai-dev/langquest/tree/dev/components/questsComponents"
    click AuthNav "https://github.com/genesis-ai-dev/langquest/blob/dev/navigators/AuthNavigator.tsx"
    click AuthCtx "https://github.com/genesis-ai-dev/langquest/blob/dev/contexts/AuthContext.tsx"
    click AudioCtx "https://github.com/genesis-ai-dev/langquest/blob/dev/contexts/AudioContext.tsx"
    click PHCtx "https://github.com/genesis-ai-dev/langquest/blob/dev/contexts/PostHogProvider.tsx"
    click StatusCtx "https://github.com/genesis-ai-dev/langquest/blob/dev/contexts/StatusContext.tsx"
    click DBHooks "https://github.com/genesis-ai-dev/langquest/tree/dev/hooks/db"
    click SyncHook "https://github.com/genesis-ai-dev/langquest/blob/dev/hooks/useSyncState.ts"
    click HybridQ "https://github.com/genesis-ai-dev/langquest/blob/dev/hooks/useHybridQuery.ts"
    click HSupabase "https://github.com/genesis-ai-dev/langquest/blob/dev/hooks/useHybridSupabaseQuery.ts"
    click Provider "https://github.com/genesis-ai-dev/langquest/blob/dev/providers/QueryProvider.tsx"
    click Services "https://github.com/genesis-ai-dev/langquest/tree/dev/services"
    click Store "https://github.com/genesis-ai-dev/langquest/tree/dev/store"
    click SchemaLocal "https://github.com/genesis-ai-dev/langquest/blob/dev/db/drizzleSchema.ts"
    click SchemaGen "https://github.com/genesis-ai-dev/langquest/blob/dev/drizzle/schema.ts"
    click Relations "https://github.com/genesis-ai-dev/langquest/blob/dev/drizzle/relations.ts"
    click AbsQueue "https://github.com/genesis-ai-dev/langquest/blob/dev/db/powersync/AbstractSharedAttachmentQueue.ts"
    click PermQueue "https://github.com/genesis-ai-dev/langquest/blob/dev/db/powersync/PermAttachmentQueue.ts"
    click TempQueue "https://github.com/genesis-ai-dev/langquest/blob/dev/db/powersync/TempAttachmentQueue.ts"
    click SysSync "https://github.com/genesis-ai-dev/langquest/blob/dev/db/powersync/system.ts"
    click DataSvc "https://github.com/genesis-ai-dev/langquest/tree/dev/database_services"
    click StatusSvc "https://github.com/genesis-ai-dev/langquest/tree/dev/database_services/status"
    click Configs "https://github.com/genesis-ai-dev/langquest/tree/dev/supabase/config"
    click Migs "https://github.com/genesis-ai-dev/langquest/tree/dev/supabase/migrations"
    click Seeds "https://github.com/genesis-ai-dev/langquest/tree/dev/supabase/seeds"
    click StorageSchema "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/schemas/storage.sql"
    click CloneWF "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/functions/clone-worker/index.ts"
    click SendEmail "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/functions/send-email/index.ts"
    click EmailTpl "https://github.com/genesis-ai-dev/langquest/tree/dev/supabase/functions/send-email/_templates"
    click SQLTR "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/functions/sqltr/index.ts"
    click Storage "https://github.com/genesis-ai-dev/langquest/tree/dev/supabase/assets"
    click Postgres "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/config/docker-compose.yml"
    click Realtime "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/config/powersync.yml"
    click AuthAPI "https://github.com/genesis-ai-dev/langquest/blob/dev/supabase/config/sync-rules.yml"
    click PostHog "https://github.com/genesis-ai-dev/langquest/blob/dev/services/posthog.ts"
    click EAS "https://github.com/genesis-ai-dev/langquest/blob/dev/eas.json"
    click GHActions "https://github.com/genesis-ai-dev/langquest/tree/dev/.github/workflows"
    click EASFlows "https://github.com/genesis-ai-dev/langquest/tree/dev/.eas/workflows"
    click Tooling "https://github.com/genesis-ai-dev/langquest/tree/dev/tooling/github"
    
    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef logic fill:#E8FFD0,stroke:#6C9F00,color:#6C9F00;
    classDef local fill:#DFFFE0,stroke:#2F8F00,color:#2F8F00;
    classDef remote fill:#FFE8D0,stroke:#D97706,color:#D97706;
    classDef external fill:#F0F0F0,stroke:#888888,color:#888888;
    classDef devops fill:#F8E0FF,stroke:#9B59B6,color:#9B59B6;
```
