# leoweitz/flashya architecture

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

- Interactive diagram: https://gitdiagram.com/leoweitz/flashya
- Repository: https://github.com/leoweitz/flashya

## Overview

##### Project type and purpose
- This is a single–page, client-focused full-stack web application built with Next.js (App Router) and Tailwind CSS.
- Purpose: Let users upload a PDF, extract key concepts via the OpenAI API, then generate interactive flashcards and offer a smart review mode—all hosted on Vercel.

##### File structure
- Top-level “web” directory contains the Next.js application.
- web/src/app: the App Router layout and routes (landing, create, view, practice, test, ready).
- web/src/components: reusable UI pieces (buttons, cards, nav bar, logo).
- web/src/actions: “openaiActions.ts” encapsulates calls to the OpenAI API.
- web/src/utils & web/src/lib: helper functions (localStorage management, utility routines).
- No dedicated database layer—state and flashcard data are managed in the browser (localStorage).
- Configuration files: next.config.js, tailwind.config.js, eslint.config.mjs.

##### README
- Confirms use of Next.js, Tailwind, and OpenAI API.
- No mention of backend databases; environment variable required is OPENAI_API_KEY.
- Workflow: user uploads PDF → AI extracts concepts → flashcards generated → review mode.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client side
    subgraph "Browser / Client"
        Browser["Browser"]:::front
    end

    %% Next.js App
    subgraph "Next.js App (SSR/CSR)" 
        subgraph "App Router Routes"
            Landing["Landing Page"]:::frontend
            Create["Create Flashcards"]:::frontend
            View["View Flashcards"]:::frontend
            Practice["Practice Mode"]:::frontend
            Test["Test Mode"]:::frontend
            Ready["Ready Screen"]:::frontend
        end
        Layout["Root Layout & Global Styles"]:::frontend
    end

    %% UI Components
    subgraph "UI Components"
        Components["Reusable React Components"]:::frontend
        Primitives["Primitive UI Elements"]:::frontend
        NavBar["Navigation Bar"]:::frontend
        Logo["FlashYa Logo"]:::frontend
        Theme["Theme Provider"]:::frontend
        Icons["Icons"]:::frontend
    end

    %% Action Layer
    subgraph "Action Layer"
        OpenAIActions["openaiActions"]:::server
    end

    %% Utilities
    subgraph "Utilities"
        LocalStorage["localStorage Utilities"]:::storage
        Utils["General Utility Functions"]:::storage
        PDFTypes["PDF Parsing Types"]:::storage
    end

    %% External Service
    OpenAI["OpenAI API"]:::external

    %% Static Assets and Config
    Public["Static Assets (/public)"]:::storage
    NextConfig["next.config.js"]:::server
    TailwindConfig["tailwind.config.js"]:::server
    ESLintConfig["eslint.config.mjs"]:::server

    %% Relationships
    Browser -->|"Requests Pages"| Landing
    Browser -->|"Requests Pages"| Create
    Browser -->|"Requests Pages"| View
    Browser -->|"Requests Pages"| Practice
    Browser -->|"Requests Pages"| Test
    Browser -->|"Requests Pages"| Ready
    Landing -->|"Renders via Layout"| Layout
    Create -->|"Renders via Layout"| Layout
    View -->|"Renders via Layout"| Layout
    Practice -->|"Renders via Layout"| Layout
    Test -->|"Renders via Layout"| Layout
    Ready -->|"Renders via Layout"| Layout

    Layout --> Components
    Components --> Primitives
    Components --> NavBar
    Components --> Logo
    Components --> Theme
    Components --> Icons

    Components -->|"Upload PDF & Request Flashcards"| OpenAIActions
    OpenAIActions -->|"POST PDF"| OpenAI
    OpenAIActions -->|"Read/Write"| LocalStorage
    OpenAIActions -->|"Use Helpers"| Utils
    Components --> Public

    %% Click Events
    click Landing "https://github.com/leoweitz/flashya/blob/main/web/src/app/landing/page.tsx"
    click Create "https://github.com/leoweitz/flashya/blob/main/web/src/app/create/page.tsx"
    click View "https://github.com/leoweitz/flashya/blob/main/web/src/app/view/page.tsx"
    click Practice "https://github.com/leoweitz/flashya/blob/main/web/src/app/practice/page.tsx"
    click Test "https://github.com/leoweitz/flashya/blob/main/web/src/app/test/page.tsx"
    click Ready "https://github.com/leoweitz/flashya/blob/main/web/src/app/ready/page.tsx"
    click Layout "https://github.com/leoweitz/flashya/blob/main/web/src/app/layout.tsx"
    click Public "https://github.com/leoweitz/flashya/tree/main/web/public"
    click Components "https://github.com/leoweitz/flashya/tree/main/web/src/components"
    click Primitives "https://github.com/leoweitz/flashya/tree/main/web/src/components/ui"
    click NavBar "https://github.com/leoweitz/flashya/blob/main/web/src/components/nav-bar.tsx"
    click Logo "https://github.com/leoweitz/flashya/blob/main/web/src/components/flashya-logo.tsx"
    click Theme "https://github.com/leoweitz/flashya/blob/main/web/src/components/theme-provider.tsx"
    click Icons "https://github.com/leoweitz/flashya/blob/main/web/src/components/icons.tsx"
    click OpenAIActions "https://github.com/leoweitz/flashya/blob/main/web/src/actions/openaiActions.ts"
    click LocalStorage "https://github.com/leoweitz/flashya/blob/main/web/src/utils/localstorageUtils.ts"
    click Utils "https://github.com/leoweitz/flashya/blob/main/web/src/lib/utils.ts"
    click PDFTypes "https://github.com/leoweitz/flashya/blob/main/web/src/types/pdf-parse.d.ts"
    click NextConfig "https://github.com/leoweitz/flashya/blob/main/web/next.config.js"
    click TailwindConfig "https://github.com/leoweitz/flashya/blob/main/web/tailwind.config.js"
    click ESLintConfig "https://github.com/leoweitz/flashya/blob/main/web/eslint.config.mjs"

    %% Styles
    classDef frontend fill:#DDEEFF,stroke:#3366CC,stroke-width:1px;
    classDef front fill:#CCE5FF,stroke:#0055AA,stroke-width:1px;
    classDef server fill:#E0F5E0,stroke:#3A8F3A,stroke-width:1px;
    classDef external fill:#FFE5CC,stroke:#CC6600,stroke-width:1px;
    classDef storage fill:#FFF5CC,stroke:#CCAA00,stroke-width:1px;
```
