# codefen/codefend-user architecture

> Architecture diagram of the GitHub repository codefen/codefend-user, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codefen/codefend-user
- Repository: https://github.com/codefen/codefend-user

## Overview

##### Project type and purpose
- This is a multi-platform frontend application:
- A web UI built in React + Vite (TypeScript)
- A desktop wrapper via Tauri (Rust)
- It does not contain its own backend code but calls external REST APIs and uses Tauri to access OS-level capabilities.

##### File structure
- Top-level folders:
- public/ – static assets (images, fonts, TinyMCE scripts)
- src/ – web‐app source
– app/ – React application (constants, data layer, router, views)
– editor-lib/ – wrappers and types for TinyMCE
– main.tsx, vite.config.ts, tsconfig.json – bootstrapping and build
- src-tauri/ – Rust code for the desktop version (Cargo.toml, main.rs, parser.rs, build.rs, tauri.conf.json)
- CI/CD configuration in .github/workflows for web, macOS, Linux, Windows and release automation
- Environmental and linting configs (.env example, ESLint, Prettier, Stylelint, Husky, commitlint)

##### Extract architecture insights from README
- Uses Node.js 22, PNPM (or NPM)
- `.env` file for runtime configuration
- `npm start` spins up the Vite dev server
- Tauri provides desktop bundling

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Browser["Browser (Web UI)"]:::client
    DesktopApp["Desktop App (Tauri + Web UI)"]:::client

    %% UI Layer
    subgraph "UI Layer"
        ReactUI["React UI"]:::ui
        Routes["Routes.tsx"]:::ui
        ProtectedRoute["ProtectedRoute.tsx"]:::ui
        Constants["UI Constants"]:::ui
        TinyMCE["TinyMCE Integration"]:::ui
    end

    %% Data Layer
    subgraph "Data Layer"
        HooksStore["Hooks & Store"]:::data
    end

    %% Service Layer
    subgraph "Service Layer"
        AbstractHTTP["abstractHttp.service.ts"]:::service
        Axios["axiosHTTP.service.ts"]:::service
        Fetch["fetchHTTP.service.ts"]:::service
        SWR["swr.ts"]:::service
        Config["Data Utils/Config"]:::service
        APIUtils["API Utils"]:::service
    end

    %% Tauri Backend
    subgraph "Tauri Backend"
        MainRs["main.rs"]:::native
        LibRs["lib.rs"]:::native
        ParserRs["parser.rs"]:::native
        Cargo["Cargo.toml"]:::native
        BuildRs["build.rs"]:::native
        TauriConf["tauri.conf.json"]:::native
        Schemas["Generated Schemas"]:::native
        Capabilities["Default Capabilities"]:::native
    end

    %% External Services
    subgraph "External Services"
        ExternalAPIs["External REST APIs"]:::external
        OSCapabilities["OS-level Capabilities"]:::external
    end

    %% CI/CD
    subgraph "CI/CD & Deployment"
        CI["GitHub Actions CI/CD"]:::ci
    end

    %% Connections
    Browser --> ReactUI
    DesktopApp --> ReactUI
    ReactUI -->|uses| Routes
    ReactUI -->|uses| ProtectedRoute
    ReactUI -->|reads| Constants
    ReactUI -->|integrates| TinyMCE
    ReactUI --> HooksStore
    HooksStore --> AbstractHTTP
    HooksStore --> Axios
    HooksStore --> Fetch
    HooksStore --> SWR
    AbstractHTTP --> Config
    AbstractHTTP --> APIUtils
    Axios --> ExternalAPIs
    Fetch --> ExternalAPIs
    SWR --> ExternalAPIs
    DesktopApp -->|IPC| MainRs
    MainRs --> ParserRs
    MainRs --> LibRs
    MainRs -->|performs| OSCapabilities
    MainRs -->|loads schemas| Schemas
    MainRs -->|loads capabilities| Capabilities
    CI --> ReactUI
    CI --> MainRs

    %% Click Events
    click ReactUI "https://github.com/codefen/codefend-user/blob/main/src/app/App.tsx"
    click Routes "https://github.com/codefen/codefend-user/blob/main/src/app/router/Routes.tsx"
    click ProtectedRoute "https://github.com/codefen/codefend-user/blob/main/src/app/router/ProtectedRoute.tsx"
    click Constants "https://github.com/codefen/codefend-user/blob/main/src/app/constants/app-constanst.ts"
    click Constants "https://github.com/codefen/codefend-user/blob/main/src/app/constants/app-texts.ts"
    click TinyMCE "https://github.com/codefen/codefend-user/blob/main/src/editor-lib/index.js"
    click HooksStore "https://github.com/codefen/codefend-user/tree/main/src/app/data/hooks/"
    click HooksStore "https://github.com/codefen/codefend-user/tree/main/src/app/data/interfaces/"
    click HooksStore "https://github.com/codefen/codefend-user/tree/main/src/app/data/mocks/"
    click HooksStore "https://github.com/codefen/codefend-user/tree/main/src/app/data/store/"
    click AbstractHTTP "https://github.com/codefen/codefend-user/blob/main/src/app/data/services/abstractHttp.service.ts"
    click Axios "https://github.com/codefen/codefend-user/blob/main/src/app/data/services/axiosHTTP.service.ts"
    click Fetch "https://github.com/codefen/codefend-user/blob/main/src/app/data/services/fetchHTTP.service.ts"
    click SWR "https://github.com/codefen/codefend-user/blob/main/src/app/data/services/swr.ts"
    click Config "https://github.com/codefen/codefend-user/blob/main/src/app/data/utils/config.ts"
    click APIUtils "https://github.com/codefen/codefend-user/blob/main/src/app/data/utils/api.utils.ts"
    click MainRs "https://github.com/codefen/codefend-user/blob/main/src-tauri/src/main.rs"
    click LibRs "https://github.com/codefen/codefend-user/blob/main/src-tauri/src/lib.rs"
    click ParserRs "https://github.com/codefen/codefend-user/blob/main/src-tauri/src/parser.rs"
    click Cargo "https://github.com/codefen/codefend-user/blob/main/src-tauri/Cargo.toml"
    click BuildRs "https://github.com/codefen/codefend-user/blob/main/src-tauri/build.rs"
    click TauriConf "https://github.com/codefen/codefend-user/blob/main/src-tauri/tauri.conf.json"
    click Schemas "https://github.com/codefen/codefend-user/tree/main/src-tauri/gen/schemas/"
    click Capabilities "https://github.com/codefen/codefend-user/blob/main/src-tauri/capabilities/default.json"
    click CI "https://github.com/codefen/codefend-user/blob/main/.github/workflows/CI.yml"

    %% Styles
    classDef client fill:#d0e8ff,stroke:#0366d6,color:#0366d6
    classDef ui fill:#e0f7fa,stroke:#00796b,color:#00796b
    classDef data fill:#e8f5e9,stroke:#388e3c,color:#388e3c
    classDef service fill:#fff3e0,stroke:#f57c00,color:#f57c00
    classDef native fill:#eceff1,stroke:#546e7a,color:#546e7a
    classDef external fill:#f3e5f5,stroke-dasharray: 5 5,stroke:#6a1b9a,color:#6a1b9a
    classDef ci fill:#e1f5fe,stroke:#0288d1,color:#0288d1
```
