# techtronixx/formify-formgenerator architecture

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

- Interactive diagram: https://gitdiagram.com/techtronixx/formify-formgenerator
- Repository: https://github.com/techtronixx/formify-formgenerator

## Overview

##### Main Components

A. Frontend Layer:
- React Application (Vite)
- Form Builder Interface
- Preview Component
- Theme System
- Export Options UI

B. Backend Layer:
- Express.js Server
- Authentication & Authorization

C. External Services:
- OpenAI API Integration
- Google Forms API Integration
- Hugging Face API Integration

D. Core Features:
- AI Form Generation System
- Export System
- Theme Management
- Form Preview System

##### Component Relationships and Data Flow

**User Interface → Backend Server → AI Services**
**Form Generation → Preview System → Export Services**

**[Client Layer] ←→ [API Layer] ←→ [External Services Layer]**

- UI Components
- Form Builder Interface
- Theme System
- Preview Component
- State Management
- Form Builder Hook
- Utils
- Export Utils
- Form Validation

- API Routes
- Authentication
- External Service Integration
- OpenAI
- Google Forms
- Hugging Face

##### Specific Implementation Details

- How the form builder component (src/components/form-builder/AIFormBuilder.tsx) interacts with the AI service (src/lib/ai.ts)
- The export flow from form builder to Google Forms/XML (src/lib/export-utils.ts)
- Theme system integration (src/components/providers/ThemeProvider.tsx)

##### Key Architectural Patterns to Highlight

- Component-based architecture (shown in src/components structure)
- Provider pattern for theme management
- Hook-based state management (useFormBuilder.ts)
- Service-based external API integration

##### Elements

**⬡ React Component**
**⬢ External Service**
**→ Data Flow**
**⟲ State Updates**

##### Technical Stack Indicators

- Vite
- React
- Tailwind CSS
- Express.js
- OpenAI
- Google Forms API
- Hugging Face API

Remember to emphasize the three main flows:

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[Form Builder UI]
        FB[Form Builder Interface]
        PS[Preview System]
        TM[Theme Management]
        EX[Export Options]
        FS[Form Settings]
        Hook[Form Builder Hook]
        Val[Form Validation]
        Types[Form Types & Constants]
        UILib[UI Component Library]
    end

    subgraph Server
        BE[Backend Server]
        Auth[Authentication]
    end

    subgraph External
        OAI[OpenAI API]
        GF[Google Forms API]
        HF[Hugging Face API]
    end

    %% Client-side connections
    UI --> FB
    FB --> PS
    FB --> TM
    FB --> EX
    FB --> FS
    FB --> Hook
    Hook --> Val
    Hook --> Types
    FB --> UILib

    %% Server connections
    FB --> BE
    BE --> Auth
    
    %% External service connections
    BE --> OAI
    BE --> GF
    BE --> HF

    %% Component styles
    classDef frontend fill:#3b82f6,color:#fff
    classDef backend fill:#22c55e,color:#fff
    classDef external fill:#a855f7,color:#fff
    classDef util fill:#f97316,color:#fff

    class UI,FB,PS,TM,EX,FS,UILib frontend
    class BE,Auth backend
    class OAI,GF,HF external
    class Hook,Val,Types util

    %% Click events
    click FB "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/components/form-builder/AIFormBuilder.tsx"
    click PS "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/pages/FormPreview.tsx"
    click TM "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/components/providers/ThemeProvider.tsx"
    click EX "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/lib/export-utils.ts"
    click Hook "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/hooks/useFormBuilder.ts"
    click Val "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/utils/form-validation.ts"
    click BE "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/server/index.ts"
    click FS "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/components/form-builder/SettingsTab.tsx"
    click Types "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/src/types/form.ts"
    click UILib "https://github.com/TechTronixx/Formify-FormGenerator/tree/main/src/components/ui"
    click Auth "https://github.com/TechTronixx/Formify-FormGenerator/blob/main/scripts/get-refresh-token.ts"

    %% Legend
    subgraph Legend
        L1[Frontend Component]:::frontend
        L2[Backend Service]:::backend
        L3[External API]:::external
        L4[Utility]:::util
    end
```
