# fouad8080/code-editor architecture

> Architecture diagram of the GitHub repository fouad8080/code-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fouad8080/code-editor
- Repository: https://github.com/fouad8080/code-editor

## Overview

This is a browser-based code editor for locally selected files and folders. The main workflow is: choose a file or folder, load a file into the CodeMirror editor, save edits through browser file handles, then preview HTML with linked CSS and JavaScript in an iframe. The graph reflects the sampled components and README; browser APIs are shown as external dependencies, and no backend is evidenced.

Main entry points: [`src/App.tsx`](https://github.com/fouad8080/code-editor/blob/main/src/App.tsx) (App state and tabs), [`src/component/floders.tsx`](https://github.com/fouad8080/code-editor/blob/main/src/component/floders.tsx) (File and folder browser), [`src/component/CodeShow.tsx`](https://github.com/fouad8080/code-editor/blob/main/src/component/CodeShow.tsx) (CodeMirror editor), [`src/component/proview.tsx`](https://github.com/fouad8080/code-editor/blob/main/src/component/proview.tsx) (Iframe preview)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shell["App shell"]
  node_app["App state and tabs<br/>[App.tsx]"]
  node_mount["React mount<br/>[main.tsx]"]
  node_topbar["Top bar<br/>[Upbar.tsx]"]
end

subgraph group_files["File workspace"]
  node_files["File and folder browser<br/>[floders.tsx]"]
  node_previewbuilder["HTML asset inliner"]
end

subgraph group_editing["Editing and preview"]
  node_editor["CodeMirror editor<br/>[CodeShow.tsx]"]
  node_preview["Iframe preview<br/>[proview.tsx]"]
end

node_user(("User"))
node_filesystem["Browser file APIs"]

node_user -->|"selects files"| node_files
node_user -->|"edits code"| node_editor
node_mount -->|"renders"| node_app
node_app -->|"renders"| node_topbar
node_app -->|"renders and shares state"| node_files
node_app -->|"renders with state"| node_editor
node_app -->|"renders with preview state"| node_preview
node_files -->|"picks and reads"| node_filesystem
node_files -->|"builds preview HTML"| node_previewbuilder
node_editor -->|"writes saved edits"| node_filesystem
node_editor -->|"rebuilds preview HTML"| node_previewbuilder
node_editor -->|"updates shared file state"| node_app
node_files -->|"sets selected file state"| node_app
node_preview -->|"reads preview state"| node_app

click node_app "https://github.com/fouad8080/code-editor/blob/main/src/App.tsx"
click node_mount "https://github.com/fouad8080/code-editor/blob/main/src/main.tsx"
click node_topbar "https://github.com/fouad8080/code-editor/blob/main/src/component/Upbar.tsx"
click node_files "https://github.com/fouad8080/code-editor/blob/main/src/component/floders.tsx"
click node_previewbuilder "https://github.com/fouad8080/code-editor/blob/main/src/component/tools/buildproviewhtml.tsx"
click node_editor "https://github.com/fouad8080/code-editor/blob/main/src/component/CodeShow.tsx"
click node_preview "https://github.com/fouad8080/code-editor/blob/main/src/component/proview.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_mount,node_topbar,node_user,node_filesystem toneBlue
class node_files,node_previewbuilder toneAmber
class node_editor,node_preview toneMint
```

## Components

### App shell

- [App state and tabs](https://github.com/fouad8080/code-editor/blob/main/src/App.tsx): `src/App.tsx`
- [React mount](https://github.com/fouad8080/code-editor/blob/main/src/main.tsx): `src/main.tsx`
- [Top bar](https://github.com/fouad8080/code-editor/blob/main/src/component/Upbar.tsx): `src/component/Upbar.tsx`

### File workspace

- [File and folder browser](https://github.com/fouad8080/code-editor/blob/main/src/component/floders.tsx): `src/component/floders.tsx`
- [HTML asset inliner](https://github.com/fouad8080/code-editor/blob/main/src/component/tools/buildproviewhtml.tsx): `src/component/tools/buildproviewhtml.tsx`

### Editing and preview

- [CodeMirror editor](https://github.com/fouad8080/code-editor/blob/main/src/component/CodeShow.tsx): `src/component/CodeShow.tsx`
- [Iframe preview](https://github.com/fouad8080/code-editor/blob/main/src/component/proview.tsx): `src/component/proview.tsx`

### Other components

- **User**
- **Browser file APIs**

## Connections

- User → File and folder browser: selects files (evidence: `src/component/floders.tsx`)
- User → CodeMirror editor: edits code (evidence: `src/component/CodeShow.tsx`)
- React mount → App state and tabs: renders (evidence: `src/main.tsx`)
- App state and tabs → Top bar: renders (evidence: `src/App.tsx`)
- App state and tabs → File and folder browser: renders and shares state (evidence: `src/App.tsx`)
- App state and tabs → CodeMirror editor: renders with state (evidence: `src/App.tsx`)
- App state and tabs → Iframe preview: renders with preview state (evidence: `src/App.tsx`)
- File and folder browser → Browser file APIs: picks and reads (evidence: `src/component/floders.tsx`)
- File and folder browser → HTML asset inliner: builds preview HTML (evidence: `src/component/floders.tsx`)
- CodeMirror editor → Browser file APIs: writes saved edits (evidence: `src/component/CodeShow.tsx`)
- CodeMirror editor → HTML asset inliner: rebuilds preview HTML (evidence: `src/component/CodeShow.tsx`)
- CodeMirror editor → App state and tabs: updates shared file state (evidence: `src/component/CodeShow.tsx`)
- File and folder browser → App state and tabs: sets selected file state (evidence: `src/component/floders.tsx`)
- Iframe preview → App state and tabs: reads preview state (evidence: `src/component/proview.tsx`)
