# devnodesin/gitwiki architecture

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

- Interactive diagram: https://gitdiagram.com/devnodesin/gitwiki
- Repository: https://github.com/devnodesin/gitwiki

## Overview

##### Main Components

a. Frontend Layer:
- Web Interface (Blade Views)
- Static Assets (CSS/JS)
- Authentication UI
- Wiki Content Rendering

b. Application Layer:
- Controllers (Admin, Auth, Wiki)
- Services (Git, Markdown, WikiFile)
- Middleware (Authentication, Admin)
- Command Line Interface

c. Storage Layer:
- Database (Users, Settings)
- Git Repository Storage
- Cache Storage
- File System

##### Key Relationships to Highlight

- User Authentication Flow
- Content Retrieval Flow
- Git Integration Flow
- Admin Management Flow

**[Client Layer]**
- ↓ ↑
**[Application Layer]**
- ↓ ↑
**[Storage Layer]**

##### Break down each layer

Client Layer:
- Main view components (wiki pages, admin interface, authentication)
- Static asset pipeline (Vite/npm)

Application Layer (Core):
- Controllers section
- WikiController
- AdminController
- AuthController
- Services section
- GitService
- MarkdownService
- WikiFileService
- Middleware section
- Authentication
- Admin Access

Storage Layer:
- Database (MySQL/PostgreSQL)
- Git Repository (/storage/git)
- Cache Storage
- Laravel Storage

##### Important Flows to Highlight

a. Content Access Flow:
**User Request → Auth Middleware → WikiController →**
**GitService/MarkdownService → Rendered Content**

b. Git Integration Flow:
**Admin/CLI → GitService → Git Repository →**
**WikiFileService → Rendered Content**

##### Additional Elements

- Notes about key security features
- Separation between public and private areas
- Async processes (like Git operations)

##### Technical Stack Indicators

- Laravel 11 Framework
- PHP 8.2+
- Node.js
- Git
- Markdown Processing
- Blade Templating

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#a8d1ff,stroke:#2d6bdb
    classDef service fill:#98ff98,stroke:#0f670f
    classDef storage fill:#ffdb99,stroke:#b36b00
    classDef controller fill:#ff9999,stroke:#cc0000
    classDef middleware fill:#e6b3ff,stroke:#6600cc
    classDef cli fill:#d9d9d9,stroke:#666666

    %% Frontend Layer
    subgraph Frontend
        WebUI["Web Interface"]:::frontend
        AuthUI["Authentication UI"]:::frontend
        StaticAssets["Static Assets"]:::frontend
        WikiRender["Wiki Content Rendering"]:::frontend
    end

    %% Application Layer
    subgraph Controllers
        AdminCtrl["Admin Controllers"]:::controller
        AuthCtrl["Auth Controllers"]:::controller
        WikiCtrl["Wiki Controller"]:::controller
    end

    subgraph Services
        GitSvc["Git Service"]:::service
        MarkdownSvc["Markdown Service"]:::service
        WikiFileSvc["Wiki File Service"]:::service
    end

    subgraph Middleware
        AuthMW["Authentication"]:::middleware
        AdminMW["Admin Access"]:::middleware
    end

    subgraph CLI
        GitCmds["Git Commands"]:::cli
        UserMgmt["User Management"]:::cli
    end

    %% Storage Layer
    subgraph Storage
        DB[(Database)]:::storage
        GitRepo[(Git Repository)]:::storage
        Cache[(Cache Storage)]:::storage
        FileSystem[(File System)]:::storage
    end

    %% Relationships
    WebUI --> AuthMW
    AuthUI --> AuthCtrl
    AuthMW --> |Authenticated| Controllers
    AdminMW --> |Admin Access| AdminCtrl
    
    WikiCtrl --> GitSvc
    WikiCtrl --> MarkdownSvc
    WikiCtrl --> WikiFileSvc
    
    GitSvc --> GitRepo
    WikiFileSvc --> FileSystem
    MarkdownSvc --> WikiRender
    
    GitCmds --> GitSvc
    UserMgmt --> DB

    %% Click Events
    click WebUI "https://github.com/devnodesin/gitwiki/tree/main/resources/views/pages"
    click AuthUI "https://github.com/devnodesin/gitwiki/blob/main/resources/views/pages/login.blade.php"
    click WikiRender "https://github.com/devnodesin/gitwiki/tree/main/resources/views/pages/wiki"
    click AdminCtrl "https://github.com/devnodesin/gitwiki/tree/main/app/Http/Controllers/Admin"
    click AuthCtrl "https://github.com/devnodesin/gitwiki/tree/main/app/Http/Controllers/Auth"
    click WikiCtrl "https://github.com/devnodesin/gitwiki/blob/main/app/Http/Controllers/Admin/WikiController.php"
    click GitSvc "https://github.com/devnodesin/gitwiki/blob/main/app/Services/GitService.php"
    click MarkdownSvc "https://github.com/devnodesin/gitwiki/blob/main/app/Services/MarkdownService.php"
    click WikiFileSvc "https://github.com/devnodesin/gitwiki/blob/main/app/Services/WikiFileService.php"
    click AuthMW "https://github.com/devnodesin/gitwiki/blob/main/app/Http/Middleware/AdminMiddleware.php"
    click GitCmds "https://github.com/devnodesin/gitwiki/blob/main/app/Console/Commands/GitClone.php"
    click UserMgmt "https://github.com/devnodesin/gitwiki/blob/main/app/Console/Commands/UserAdd.php"
    click DB "https://github.com/devnodesin/gitwiki/tree/main/database/migrations"
    click Cache "https://github.com/devnodesin/gitwiki/tree/main/storage/framework/cache"
    click FileSystem "https://github.com/devnodesin/gitwiki/tree/main/storage/app"
    click GitRepo "https://github.com/devnodesin/gitwiki/tree/main/storage/app/private"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Controller["Controller"]:::controller
        Service["Service"]:::service
        Store["Storage"]:::storage
        Mid["Middleware"]:::middleware
        Command["CLI Command"]:::cli
    end
```
