# brdebr/chatbot-form-filler architecture

> Architecture diagram of the GitHub repository brdebr/chatbot-form-filler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brdebr/chatbot-form-filler
- Repository: https://github.com/brdebr/chatbot-form-filler

## Overview

##### Project type and purpose
- This is a full‑stack Next.js 13 “app router” application (a POC) whose goal is to render a chat‑based form‑filling UI in the browser and back it with two serverless API routes:
- `/api/chatbot` – orchestrates calls to an LLM or chatbot service for generating form inputs.
- `/api/version‑deployed` – returns the currently deployed version.

##### File structure
- Top level config files (tsconfig.json, next.config.mjs, tailwind.config.ts) and package.json define the build and runtime.
- `app/` – Next.js “app” directory containing layouts, pages, providers, components, hooks, styles, and two API route folders (`chatbot` and `version‑deployed`).
- `components/ui/` – shared UI primitives (Button, Card, Input, Select, Skeleton) used by pages under `app/components`.
- `app/store/` – client‑side state slice (e.g. form store).
- `lib/` – utility hooks (`useDarkMode`) and helper functions.
- `public/` and `docs/` – static assets (demo gif).

##### README for additional insights
- Emphasis on a single‑page frontend served by Next.js and two minimal API endpoints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client (Browser)"
        subgraph "Pages & Layout"
            Layout["Layout"]:::frontend
            Page["Main Page"]:::frontend
        end
        subgraph "Page-Specific Components"
            Form["FormToFill"]:::frontend
            Trigger["Chat Trigger Button"]:::frontend
            ChatComp["Chat Component"]:::frontend
            ThemeSwitch["Theme Switch"]:::frontend
        end
        subgraph "UI Primitives"
            Button["Button"]:::ui
            Card["Card"]:::ui
            Input["Input"]:::ui
            Select["Select"]:::ui
            Skeleton["Skeleton"]:::ui
        end
        Layout --> Page
        Page --> Form
        Page --> Trigger
        Page --> ChatComp
        Page --> ThemeSwitch
        Form --> Button
        Form --> Input
        Form --> Select
        Trigger --> Button
    end

    subgraph "State & Providers"
        AppProv["App Provider"]:::frontend
        DarkProv["Dark Mode Provider"]:::frontend
        Store["Form Store"]:::frontend
        Hooks["Custom Hooks & Utils"]:::frontend
        Page --> AppProv
        AppProv --> DarkProv
        DarkProv --> Form
        Form --> Store
        Form --> Hooks
    end

    %% Server Side
    subgraph "Next.js App Server"
        API["Next.js Application Server"]:::backend
        subgraph "API Routes"
            ChatAPI["/api/chatbot"]:::backend
            VerAPI["/api/version-deployed"]:::backend
        end
        API --> ChatAPI
        API --> VerAPI
    end

    %% External Services
    subgraph "External Services"
        LLM["LLM/Chatbot Service"]:::external
        CDN["Static Assets CDN"]:::external
    end

    Static["Static Assets & Docs"]:::static

    subgraph "Config & Build"
        TS["tsconfig.json"]:::config
        NextConf["next.config.mjs"]:::config
        PKG["package.json"]:::config
        Eslint[".eslintrc.json"]:::config
    end

    %% Data Flows
    Page -->|"SSR/CSR"| API
    Form -->|POST /api/chatbot| ChatAPI
    ChatAPI -->|calls| LLM
    Page -->|GET /api/version-deployed| VerAPI
    VerAPI -->|reads version| TS
    Page -->|serves static| CDN
    Static -->|hosted on| CDN

    %% Click Events
    click API "https://github.com/brdebr/chatbot-form-filler/tree/master/app/"
    click ChatAPI "https://github.com/brdebr/chatbot-form-filler/blob/master/app/api/chatbot/route.ts"
    click VerAPI "https://github.com/brdebr/chatbot-form-filler/blob/master/app/api/version-deployed/route.ts"
    click Layout "https://github.com/brdebr/chatbot-form-filler/blob/master/app/layout.tsx"
    click Page "https://github.com/brdebr/chatbot-form-filler/blob/master/app/page.tsx"
    click Button "https://github.com/brdebr/chatbot-form-filler/blob/master/components/ui/button.tsx"
    click Card "https://github.com/brdebr/chatbot-form-filler/blob/master/components/ui/card.tsx"
    click Input "https://github.com/brdebr/chatbot-form-filler/blob/master/components/ui/input.tsx"
    click Select "https://github.com/brdebr/chatbot-form-filler/blob/master/components/ui/select.tsx"
    click Skeleton "https://github.com/brdebr/chatbot-form-filler/blob/master/components/ui/skeleton.tsx"
    click Form "https://github.com/brdebr/chatbot-form-filler/blob/master/app/components/FormToFill.tsx"
    click Trigger "https://github.com/brdebr/chatbot-form-filler/blob/master/app/components/chat-trigger-button.tsx"
    click ChatComp "https://github.com/brdebr/chatbot-form-filler/blob/master/app/components/chat.tsx"
    click ThemeSwitch "https://github.com/brdebr/chatbot-form-filler/blob/master/app/components/theme-switch.tsx"
    click Store "https://github.com/brdebr/chatbot-form-filler/blob/master/app/store/form.ts"
    click AppProv "https://github.com/brdebr/chatbot-form-filler/blob/master/app/providers/app-provider.tsx"
    click DarkProv "https://github.com/brdebr/chatbot-form-filler/blob/master/app/providers/dark-mode-provider.tsx"
    click Hooks "https://github.com/brdebr/chatbot-form-filler/blob/master/lib/useDarkMode.ts"
    click TS "https://github.com/brdebr/chatbot-form-filler/blob/master/tsconfig.json"
    click NextConf "https://github.com/brdebr/chatbot-form-filler/blob/master/next.config.mjs"
    click PKG "https://github.com/brdebr/chatbot-form-filler/blob/master/package.json"
    click Eslint "https://github.com/brdebr/chatbot-form-filler/blob/master/.eslintrc.json"

    %% Styles
    classDef frontend fill:#D6E4FF,stroke:#1E3A8A;
    classDef ui fill:#E0F2FE,stroke:#0284C7;
    classDef backend fill:#DCFCE7,stroke:#166534;
    classDef external fill:#FEF9C3,stroke:#854D0E;
    classDef static fill:#F3F4F6,stroke:#6B7280;
    classDef config fill:#F3F4F6,stroke:#374151;
```
