# ritesh2351235/kidolearn architecture

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

- Interactive diagram: https://gitdiagram.com/ritesh2351235/kidolearn
- Repository: https://github.com/ritesh2351235/kidolearn

## Overview

##### Project type and purpose
- KidoLearn is a full-stack, cross-platform learning platform comprising:
- A Web Dashboard (Next.js, TypeScript, Tailwind, Radix UI) for parents
- A Mobile App (Expo + React Native, TypeScript) for children
- A unified Backend API (Next.js API Routes, Node.js)
- A PostgreSQL database (Prisma ORM)
- Integrations with external services (Clerk for auth, YouTube Data API, OpenAI GPT-4)

##### File structure
- Top-level “app/” folder houses web front-end pages (App Router) and `app/api/` for backend routes
- “components/” holds shared React UI elements (dashboard-specific vs generic UI)
- “lib/” provides server-side helpers (DB client, YouTube client, utilities)
- “prisma/” contains database schema and migrations
- “kids-mobile/” is a self-contained Expo monorepo for the mobile app
- Configuration files at root and in kids-mobile coordinate builds, linting, TypeScript, environment variables

##### README for additional insights
- Tech stack, data flow, database models, and deployment targets are explicitly described

##### Detailed coverage
- API domain as sub-components of the gateway (e.g., /api/videos, /api/children, /api/recommendations)
- Offline/online synchronization for the mobile app
- CI/CD flow: GitHub Actions → Vercel / Expo
- Environment variables and secrets management as minor callouts

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layers
    subgraph "Web Dashboard" 
        direction TB
        WD_PAGES["app/dashboard/"] 
        WD_LAYOUT["app/layout.tsx"]
        WD_ROOTPAGE["app/page.tsx"]
        WD_DASHUI["components/dashboard/"]
        WD_UI["components/ui/"]
    end

    subgraph "Mobile App"
        direction TB
        MA_APP["kids-mobile/app/"]
        MA_COMP["kids-mobile/components/"]
        MA_LIB["kids-mobile/lib/"]
        MA_ASSETS["kids-mobile/assets/"]
        MA_CONFIG_JS["kids-mobile/app.config.js"]
        MA_CONFIG_JSON["kids-mobile/app.json"]
    end

    %% API Gateway Layer
    subgraph "API Gateway (Next.js API Routes)"
        direction TB
        AGW_ROOT["app/api/"]
        AGW_CHILD["app/api/children/route.ts"]
        AGW_RECO["app/api/recommendations/route.ts"]
        AGW_VID["app/api/videos/route.ts"]
        AGW_VIDSUM["app/api/videos/summary/route.ts"]
        AGW_SESS["app/api/app-sessions/route.ts"]
        AGW_OTHER["app/api/(other domains)"]
        AGW_MW["middleware.ts"]
    end

    %% Authentication Service
    Auth["Clerk Auth Service"] 

    %% Database Layer
    subgraph "Database (PostgreSQL + Prisma)"
        direction TB
        DB_SCHEMA["prisma/schema.prisma"]
        DB_MIG["prisma/migrations/"]
        DB_CLIENT["lib/db.ts"]
        DB_MOBILE_CLIENT["kids-mobile/lib/db.ts"]
    end

    %% External APIs
    subgraph "External APIs"
        direction TB
        EXT_YT["lib/youtube.ts"]
        EXT_OAI["lib/openai.ts"]
        EXT_YT_MD["YOUTUBE_API_SETUP.md"]
        MA_EXT_YT["kids-mobile/lib/youtube.ts"]
        MA_EXT_OAI["kids-mobile/lib/openai.ts"]
    end

    %% CI/CD & Hosting
    subgraph "CI/CD & Hosting"
        direction TB
        CI_GH[".github/"]
        CI_VERCEL["Vercel (next.config.ts)"]
        CI_CSS["postcss.config.mjs & tailwind.config.js"]
        CI_EXPO_CFG["kids-mobile/eas.json"]
        CI_EXPO_MON["kids-mobile/scripts/monitor-production.sh"]
    end

    %% Flows
    WD_PAGES -->|HTTPS Request| AGW_ROOT
    MA_APP -->|HTTPS Request| AGW_ROOT
    AGW_ROOT -->|JWT Validation| AGW_MW
    AGW_MW -->|Validate Token| Auth
    AGW_ROOT -->|DB Query/Mutation| DB_CLIENT
    AGW_ROOT -->|DB Query/Mutation| DB_MOBILE_CLIENT
    AGW_ROOT -->|Fetch Video Data| EXT_YT
    AGW_ROOT -->|AI Analysis| EXT_OAI
    MA_LIB -->|Offline Cache| MA_ASSETS

    %% CI/CD Flows
    CI_GH -->|Push| CI_VERCEL
    CI_GH -->|Push| CI_EXPO_CFG

    %% Click Events
    click WD_PAGES "https://github.com/ritesh2351235/kidolearn/tree/main/app/dashboard/"
    click WD_LAYOUT "https://github.com/ritesh2351235/kidolearn/blob/main/app/layout.tsx"
    click WD_ROOTPAGE "https://github.com/ritesh2351235/kidolearn/blob/main/app/page.tsx"
    click WD_DASHUI "https://github.com/ritesh2351235/kidolearn/tree/main/components/dashboard/"
    click WD_UI "https://github.com/ritesh2351235/kidolearn/tree/main/components/ui/"

    click MA_APP "https://github.com/ritesh2351235/kidolearn/tree/main/kids-mobile/app/"
    click MA_COMP "https://github.com/ritesh2351235/kidolearn/tree/main/kids-mobile/components/"
    click MA_LIB "https://github.com/ritesh2351235/kidolearn/tree/main/kids-mobile/lib/"
    click MA_ASSETS "https://github.com/ritesh2351235/kidolearn/tree/main/kids-mobile/assets/"
    click MA_CONFIG_JS "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/app.config.js"
    click MA_CONFIG_JSON "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/app.json"

    click AGW_ROOT "https://github.com/ritesh2351235/kidolearn/tree/main/app/api/"
    click AGW_CHILD "https://github.com/ritesh2351235/kidolearn/blob/main/app/api/children/route.ts"
    click AGW_RECO "https://github.com/ritesh2351235/kidolearn/blob/main/app/api/recommendations/route.ts"
    click AGW_VID "https://github.com/ritesh2351235/kidolearn/blob/main/app/api/videos/route.ts"
    click AGW_VIDSUM "https://github.com/ritesh2351235/kidolearn/blob/main/app/api/videos/summary/route.ts"
    click AGW_SESS "https://github.com/ritesh2351235/kidolearn/blob/main/app/api/app-sessions/route.ts"
    click AGW_OTHER "https://github.com/ritesh2351235/kidolearn/tree/main/app/api/"
    click AGW_MW "https://github.com/ritesh2351235/kidolearn/blob/main/middleware.ts"

    click DB_SCHEMA "https://github.com/ritesh2351235/kidolearn/blob/main/prisma/schema.prisma"
    click DB_MIG "https://github.com/ritesh2351235/kidolearn/tree/main/prisma/migrations/"
    click DB_CLIENT "https://github.com/ritesh2351235/kidolearn/blob/main/lib/db.ts"
    click DB_MOBILE_CLIENT "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/lib/db.ts"

    click EXT_YT "https://github.com/ritesh2351235/kidolearn/blob/main/lib/youtube.ts"
    click EXT_OAI "https://github.com/ritesh2351235/kidolearn/blob/main/lib/openai.ts"
    click EXT_YT_MD "https://github.com/ritesh2351235/kidolearn/blob/main/YOUTUBE_API_SETUP.md"
    click MA_EXT_YT "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/lib/youtube.ts"
    click MA_EXT_OAI "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/lib/openai.ts"

    click CI_GH "https://github.com/ritesh2351235/kidolearn/tree/main/.github/"
    click CI_VERCEL "https://github.com/ritesh2351235/kidolearn/blob/main/next.config.ts"
    click CI_CSS "https://github.com/ritesh2351235/kidolearn/blob/main/postcss.config.mjs"
    click CI_CSS "https://github.com/ritesh2351235/kidolearn/blob/main/tailwind.config.js"
    click CI_EXPO_CFG "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/eas.json"
    click CI_EXPO_MON "https://github.com/ritesh2351235/kidolearn/blob/main/kids-mobile/scripts/monitor-production.sh"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#1E70BF;
    classDef backend fill:#D0FFD6,stroke:#2E7D32;
    classDef datastore fill:#FFE199,stroke:#C77800;
    classDef external fill:#E6D1FF,stroke:#6A1B9A;

    class WD_PAGES,WD_LAYOUT,WD_ROOTPAGE,WD_DASHUI,WD_UI,MA_APP,MA_COMP,MA_LIB,MA_ASSETS,MA_CONFIG_JS,MA_CONFIG_JSON frontend;
    class AGW_ROOT,AGW_CHILD,AGW_RECO,AGW_VID,AGW_VIDSUM,AGW_SESS,AGW_OTHER,AGW_MW backend;
    class DB_SCHEMA,DB_MIG,DB_CLIENT,DB_MOBILE_CLIENT datastore;
    class EXT_YT,EXT_OAI,EXT_YT_MD,MA_EXT_YT,MA_EXT_OAI,Auth external;
    class CI_GH,CI_VERCEL,CI_CSS,CI_EXPO_CFG,CI_EXPO_MON backend;
```
