# triggerdotdev/jsonhero-web architecture

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

- Interactive diagram: https://gitdiagram.com/triggerdotdev/jsonhero-web
- Repository: https://github.com/triggerdotdev/jsonhero-web

## Overview

##### Main System Components

a) Frontend Layer:
- React-based UI components (located in /app/components)
- Multiple view modes (Column, Tree, Editor)
- Theme system
- Search functionality
- Preview system

b) Backend Layer:
- Remix.run framework
- API endpoints
- File handling services
- URI preview service
- GitHub integration

c) Worker Layer:
- Background processing
- Cloudflare Workers integration (indicated by wrangler.toml)

##### Key Architectural Elements

a) Core Features Architecture:
- JSON document processing pipeline
- View rendering systems (Column, Tree, Editor)
- Search indexing and processing
- Preview generation system
- Schema inference system

b) Data Flow:
- Document creation flows (File upload, URL fetch, API creation)
- Document retrieval and caching
- Search query processing
- Preview generation pipeline

**┌─ Client Layer ─────────────────────────────┐**
- React Components                         │
- Theme System                             │
- View Engines (Column/Tree/Editor)        │
- Search UI                                │
- ┘
- ↕ (Remix Data Flow)
**┌─ Application Layer ────────────────────────┐**
- Route Handlers                           │
- JSON Processing                          │
- Schema Inference                         │
- Preview Generation                       │
- ┘
- ↕ (Service Integration)
**┌─ Service Layer ──────────────────────────────┐**
- API Hero Service                          │
- GitHub Service                            │
- URI Preview Service                       │
- Toast Service                             │
- ┘
- ↕ (External Communication)
**┌─ External Services ────────────────────────┐**
- Cloudflare Workers                       │
- External APIs                            │
- Storage Services                         │
- ┘

##### Important Details

- The separation between client and server code
- The Remix.run framework architecture
- The different view engines and their relationships
- The preview generation pipeline
- Search functionality architecture
- External service integrations

##### Specific Implementation Notes

Specialized components:
- JSON document processing pipeline
- Preview generation system
- Search indexing and query system
- Schema inference engine
- URI preview service
- File handling system

##### Interactions and Data Flow

Show:
- How JSON documents are processed and stored
- How different views are generated
- How search queries are processed
- How previews are generated and cached
- How external services are integrated

Remember to:
- Use consistent styling
- Notes for complex interactions
- Both synchronous and asynchronous flows

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        direction TB
        Views["View Modes"]
        ColumnView["Column View"]:::frontend
        TreeView["Tree View"]:::frontend
        EditorView["Editor View"]:::frontend
        Views --> ColumnView & TreeView & EditorView
        
        UI["Core UI Components"]
        Columns["Column System"]:::frontend
        InfoPanel["Info Panel"]:::frontend
        PathBar["Path Bar"]:::frontend
        Properties["Properties"]:::frontend
        UI --> Columns & InfoPanel & PathBar & Properties
        
        Theme["Theme System"]
        ThemeProvider["Theme Provider"]:::frontend
        ThemeToggle["Theme Toggle"]:::frontend
        Theme --> ThemeProvider & ThemeToggle
        
        Search["Search System"]
        SearchBar["Search Bar"]:::frontend
        SearchPalette["Search Palette"]:::frontend
        SearchLogic["Search Logic"]:::frontend
        SearchHook["Search Hook"]:::frontend
        Search --> SearchBar & SearchPalette & SearchLogic & SearchHook
        
        Preview["Preview System"]
        PreviewComponents["Preview Components"]:::frontend
        PreviewTypes["Preview Types"]:::frontend
        PreviewBox["Preview Box"]:::frontend
        Preview --> PreviewComponents & PreviewTypes & PreviewBox
        
        FileHandling["File Handling"]
        FileSelector["File Selector"]:::frontend
        FileUpload["File Upload"]:::frontend
        NewFile["New File"]:::frontend
        FileHandling --> FileSelector & FileUpload & NewFile
    end
    
    subgraph Server
        direction TB
        API["API Layer"]
        APIRoutes["API Routes"]:::backend
        ActionRoutes["Action Routes"]:::backend
        API --> APIRoutes & ActionRoutes
        
        DocProcessing["Document Processing"]
        JsonDoc["JSON Document Hook"]:::backend
        JsonSchema["JSON Schema"]:::backend
        JsonUtils["JSON Utilities"]:::backend
        DocProcessing --> JsonDoc & JsonSchema & JsonUtils
        
        ThemeServer["Theme Server"]:::backend
        Worker["Worker Architecture"]
        WorkerEntry["Worker Entry"]:::backend
        WorkerDir["Worker Directory"]:::backend
        Worker --> WorkerEntry & WorkerDir
    end
    
    subgraph External
        direction TB
        URIPreview["URI Preview Service"]:::external
        GitHub["GitHub Integration"]:::external
        APIHero["API Hero Integration"]:::external
    end
    
    Client --> Server
    Server --> External
    
    %% Click events for component mapping
    click ColumnView "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/JsonColumnView.tsx"
    click TreeView "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/JsonTreeView.tsx"
    click EditorView "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/JsonEditor.tsx"
    click ThemeProvider "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/ThemeProvider.tsx"
    click ThemeToggle "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/ThemeModeToggle.tsx"
    click ThemeServer "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/theme.server.ts"
    click SearchBar "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/SearchBar.tsx"
    click SearchPalette "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/SearchPalette.tsx"
    click SearchLogic "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/utilities/search.ts"
    click SearchHook "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/hooks/useJsonSearch.tsx"
    click PreviewComponents "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/components/Preview"
    click PreviewTypes "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/components/Preview/Types"
    click PreviewBox "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/Preview/PreviewBox.tsx"
    click URIPreview "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/services/uriPreview.server.ts"
    click GitHub "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/services/github.server.ts"
    click APIHero "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/services/apihero.server.ts"
    click APIRoutes "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/routes/api"
    click ActionRoutes "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/routes/actions"
    click JsonDoc "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/hooks/useJsonDoc.tsx"
    click JsonSchema "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/hooks/useJsonSchema.tsx"
    click JsonUtils "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/utilities"
    click FileSelector "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/components/FileSelector"
    click FileUpload "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/DragAndDropForm.tsx"
    click NewFile "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/NewFile.tsx"
    click Columns "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/Columns.tsx"
    click InfoPanel "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/InfoPanel.tsx"
    click PathBar "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/components/PathBar.tsx"
    click Properties "https://github.com/triggerdotdev/jsonhero-web/tree/main/app/components/Properties"
    click WorkerEntry "https://github.com/triggerdotdev/jsonhero-web/blob/main/app/entry.worker.ts"
    click WorkerDir "https://github.com/triggerdotdev/jsonhero-web/tree/main/worker"
    
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
```
