# mizchi/next-editor architecture

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

- Interactive diagram: https://gitdiagram.com/mizchi/next-editor
- Repository: https://github.com/mizchi/next-editor

## Overview

##### Main Components
- Frontend (UI Layer):
- The user interface is built using React components (located under src/ui) with a clear separation into atoms, molecules, and organisms. The UI components include pages (Main, Edit, Playground, Config) and utilities (like GlobalErrorBoundary, ThemeProvider, etc.).
- Editor components exist in src/editors (MonacoEditor, TextEditor, WysiwygEditor, etc.) to provide different editing interfaces.
- Domain Layer – Git and Filesystem:
- Under src/domain, you have two major subdomains: "git" and "filesystem". The Git domain further separates commands (e.g., cloneRepository, commitAll) and queries (like getFileHistory, getStagingStatus). Similarly, the filesystem domain offers commands (mkdir, unlink, writeFile) and queries (existsPath, readFile).
- Infrastructure/Utils:
- The src/lib directory includes various utility functions like parsing Git configuration and markdown formatting.
- There is additional configuration and setup for TypeScript (tsconfig.json), Babel (.babelrc), and webpack (webpack.config.js).
- Testing and CI/CD:
- Unit tests (in __tests__) and e2e tests (in e2e) verify functionality. The presence of CircleCI configuration (.circleci) and references to deployment scripts (script/deploy.sh, script/migrator.js) illustrate the deployment pipeline.
- Deployment & Configuration:
- Several configuration files (Netlify config via netlify.toml, renovate.json) and optional custom bootstrapping (src-custom directory support) indicate flexible deployment options and customization capabilities for production builds.

##### Relationships and Interactions
- UI Components interact with the Domain Layer by dispatching actions and invoking domain commands and queries.
- Domain modules (Git and Filesystem) encapsulate core business logic that the UI utilizes to perform operations like cloning a repository, committing changes, or managing file system actions.
- Utility libraries (src/lib) support both the UI and domain logic with helper functions.
- Deployment scripts and CI/CD workflows ensure that the application is built, tested, and deployed in a consistent manner.

##### Architectural Patterns and Design Principles
- Modularity: The clear separation between domain logic (git and filesystem) and the user interface enables easier maintenance and independent testing.
- Layered Architecture: The design follows a layered approach where UI components, domain logic, and utilities are distinctly separated.
- Component-Based UI: The UI layer employs React’s component hierarchy with atoms, molecules, and organisms mirroring design principles like Atomic Design.

##### Relevant Technologies, Frameworks, and Libraries
- React for the user interface (with a structured folder hierarchy in src/ui/components).
- PWA technology stacks that transform the app into a Progressive Web Application (manifest, service-worker considerations in production).
- Git integration, with a specialized domain for Git operations.
- Testing frameworks like Jest (see jest.config.js and __tests__ directories).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        UI1["React UI Components"]
        EDI["Editor Components"]
        EDI1["MonacoEditor.tsx"]
        EDI2["TextEditor.tsx"]
        EDI3["WysiwygEditor.tsx"]
        EDI4["ProgramEditor.tsx"]
    end

    subgraph "Domain Layer"
        subgraph "Git Domain"
            GITC["Git Commands"]
            GITQ["Git Queries"]
        end
        subgraph "Filesystem Domain"
            FSC["Filesystem Commands"]
            FSQ["Filesystem Queries"]
        end
    end

    subgraph "Infrastructure"
        LIB["Utility Libraries"]
    end

    subgraph "Deployment & CI/CD"
        CI["CI/CD (.circleci)"]
        DS["Deployment Scripts (script)"]
        NET["Netlify Config (netlify.toml)"]
        REN["Renovate Config (renovate.json)"]
    end

    subgraph "Configuration Files"
        TS["tsconfig.json"]
        BRC[".babelrc"]
        WC["webpack.config.js"]
        GI[".gitignore"]
        PP[".prettierrc"]
    end

    subgraph "Testing"
        UT["Unit Tests (__tests__)"]
        E2E["E2E Tests (e2e)"]
    end

    UI1 -->|"dispatches_action"| GITC
    UI1 -->|"dispatches_action"| FSC

    GITC -->|"updates"| GITQ
    FSC -->|"updates"| FSQ

    LIB -->|"supports"| UI1
    LIB -->|"supports"| GITC
    LIB -->|"supports"| FSC

    TS -->|"configures"| CI
    BRC -->|"configures"| CI
    WC -->|"configures"| CI

    CI -->|"deploys"| UI1
    DS -->|"deploys"| UI1
    NET -->|"deploys"| UI1
    REN -->|"deploys"| UI1

    UT -->|"validates"| UI1
    UT -->|"validates"| GITC
    UT -->|"validates"| FSC

    E2E -->|"validates"| UI1

    UI1 -->|"contains"| EDI
    EDI --> EDI1
    EDI --> EDI2
    EDI --> EDI3
    EDI --> EDI4

    click UI1 "https://github.com/mizchi/next-editor/tree/master/src/ui"
    click EDI "https://github.com/mizchi/next-editor/tree/master/src/editors"
    click EDI1 "https://github.com/mizchi/next-editor/blob/master/src/editors/MonacoEditor.tsx"
    click EDI2 "https://github.com/mizchi/next-editor/blob/master/src/editors/TextEditor.tsx"
    click EDI3 "https://github.com/mizchi/next-editor/blob/master/src/editors/WysiwygEditor.tsx"
    click EDI4 "https://github.com/mizchi/next-editor/blob/master/src/editors/ProgramEditor.tsx"
    click GITC "https://github.com/mizchi/next-editor/tree/master/src/domain/git/commands"
    click GITQ "https://github.com/mizchi/next-editor/tree/master/src/domain/git/queries"
    click FSC "https://github.com/mizchi/next-editor/tree/master/src/domain/filesystem/commands"
    click FSQ "https://github.com/mizchi/next-editor/tree/master/src/domain/filesystem/queries"
    click LIB "https://github.com/mizchi/next-editor/tree/master/src/lib"
    click UT "https://github.com/mizchi/next-editor/tree/master/__tests__"
    click E2E "https://github.com/mizchi/next-editor/tree/master/e2e"
    click CI "https://github.com/mizchi/next-editor/blob/master/.circleci"
    click DS "https://github.com/mizchi/next-editor/tree/master/script"
    click NET "https://github.com/mizchi/next-editor/blob/master/netlify.toml"
    click REN "https://github.com/mizchi/next-editor/blob/master/renovate.json"
    click TS "https://github.com/mizchi/next-editor/blob/master/tsconfig.json"
    click BRC "https://github.com/mizchi/next-editor/blob/master/.babelrc"
    click WC "https://github.com/mizchi/next-editor/blob/master/webpack.config.js"
    click GI "https://github.com/mizchi/next-editor/blob/master/.gitignore"
    click PP "https://github.com/mizchi/next-editor/blob/master/.prettierrc"

    class UI1,EDI,EDI1,EDI2,EDI3,EDI4 ui
    class GITC,GITQ,FSC,FSQ domain
    class LIB infra
    class CI,DS,NET,REN deploy
    class TS,BRC,WC,GI,PP config
    class UT,E2E test

    classDef ui fill:#ffeeaa,stroke:#e29,stroke-width:2px;
    classDef domain fill:#ccffcc,stroke:#088,stroke-width:2px;
    classDef infra fill:#ffcccc,stroke:#800,stroke-width:2px;
    classDef deploy fill:#cce5ff,stroke:#339,stroke-width:2px;
    classDef config fill:#e6ccff,stroke:#933,stroke-width:2px;
    classDef test fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
```
