# padi2312/dorcs architecture

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

- Interactive diagram: https://gitdiagram.com/padi2312/dorcs
- Repository: https://github.com/padi2312/dorcs

## Overview

##### Main Components

a) Core Components:
- Documentation Source Handler
- Markdown Processing Engine
- HTML Generator
- File Watcher System
- Built-in Web Server
- Frontend Application (Svelte-based)

b) Supporting Components:
- Configuration Manager
- Navigation Tree Builder
- WebSocket Manager (for hot reload)
- Theme System

##### Specific Implementation Details

- The separation between the Go backend and Svelte frontend
- The WebSocket connection for hot reload functionality
- The file watching system's interaction with the documentation processor
- The navigation tree building process
- Configuration management flow

##### Technical Specifications

Frontend:
- Svelte framework
- TailwindCSS for styling
- TypeScript for type safety
- Vite for building

Backend:
- Go(lang) implementation
- Built-in HTTP server
- WebSocket server
- File system watchers

##### Design Patterns to Highlight

- Observer Pattern (file watching system)
- Tree Structure (navigation)
- MVC-like pattern in the frontend
- Component-based architecture (Svelte)

##### Additional Elements

- Component groupings
- Configuration flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Interaction Layer"
        CLI["CLI Interface"]
        Browser["Web Browser"]
    end

    subgraph "Frontend Layer"
        FrontApp["Frontend Application"]:::frontend
        Router["Router System"]:::frontend
        WSClient["WebSocket Client"]:::frontend
        
        subgraph "Components"
            Content["Content Component"]:::frontend
            Sidebar["Sidebar Component"]:::frontend
            ContentLoader["Content Loader"]:::frontend
        end
        
        subgraph "State Management"
            DarkMode["Dark Mode Store"]:::frontend
            Settings["Settings Store"]:::frontend
        end
    end

    subgraph "Backend Services Layer"
        WebServer["Built-in Web Server"]:::backend
        WSServer["WebSocket Server"]:::backend
        FileWatcher["File Watcher System"]:::backend
    end

    subgraph "Core Processing Layer"
        DocProcessor["Documentation Processor"]:::core
        NavBuilder["Navigation Tree Builder"]:::core
        ConfigMgr["Configuration Manager"]:::core
        PathHandler["Path Handler"]:::core
        MetaProcessor["Metadata Processor"]:::core
    end

    subgraph "File System Layer"
        MD[("Markdown Files")]:::storage
        HTML[("Generated HTML")]:::storage
        Assets[("Static Assets")]:::storage
    end

    %% Relationships
    CLI --> WebServer
    Browser --> FrontApp
    FrontApp --> Router
    FrontApp --> WSClient
    FrontApp --> Content
    FrontApp --> Sidebar
    Content --> ContentLoader
    
    WSClient <-.-> WSServer
    WebServer --> DocProcessor
    FileWatcher --> DocProcessor
    DocProcessor --> NavBuilder
    DocProcessor --> PathHandler
    DocProcessor --> MetaProcessor
    ConfigMgr --> DocProcessor
    
    DocProcessor --> MD
    DocProcessor --> HTML
    WebServer --> Assets

    %% Click Events
    click FrontApp "https://github.com/padi2312/dorcs/blob/main/frontend/src/App.svelte"
    click Router "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/Router.ts"
    click WSClient "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/Websocket.ts"
    click Content "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/components/Content.svelte"
    click Sidebar "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/components/Sidebar.svelte"
    click ContentLoader "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/ContentLoader.ts"
    click DarkMode "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/darkModeStore.ts"
    click Settings "https://github.com/padi2312/dorcs/blob/main/frontend/src/lib/settingsStore.ts"
    click WebServer "https://github.com/padi2312/dorcs/blob/main/pkg/server/server.go"
    click FileWatcher "https://github.com/padi2312/dorcs/blob/main/pkg/utils/file_watcher.go"
    click DocProcessor "https://github.com/padi2312/dorcs/blob/main/pkg/dorcs/dorcs.go"
    click NavBuilder "https://github.com/padi2312/dorcs/blob/main/pkg/navigation/tree.go"
    click ConfigMgr "https://github.com/padi2312/dorcs/blob/main/internal/config.go"
    click PathHandler "https://github.com/padi2312/dorcs/blob/main/pkg/dorcs/path_handler.go"
    click MetaProcessor "https://github.com/padi2312/dorcs/blob/main/pkg/dorcs/meta_data.go"
    click CLI "https://github.com/padi2312/dorcs/blob/main/main.go"

    %% Styling
    classDef frontend fill:#ff9999,stroke:#333,stroke-width:2px
    classDef backend fill:#99ff99,stroke:#333,stroke-width:2px
    classDef core fill:#9999ff,stroke:#333,stroke-width:2px
    classDef storage fill:#ffff99,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        Core["Core Processing"]:::core
        Storage["Storage"]:::storage
    end
```
