# dendianugerah/reubah architecture

> Architecture diagram of the GitHub repository dendianugerah/reubah, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dendianugerah/reubah
- Repository: https://github.com/dendianugerah/reubah

## Overview

##### Main System Components

a) Web Interface Layer:
- Static frontend components (templates directory)
- HTML templates and JavaScript handlers
- TailwindCSS integration

b) Server Layer:
- Main server component (cmd/server)
- Request handlers (internal/handlers)
- Input validation (internal/validator)

c) Processing Layer:
- Document processor
- Image processor
- Background removal service (planned feature)
- Optimization service

d) Storage Layer:
- Temporary storage system (tmp directory)
- "no permanent storage" architecture

##### Component Relationships

- User → Web Interface → Server Handlers → Processors → Temporary Storage

##### Specific Implementation Details

a) Document Processing Pipeline:
- Input validation
- Format conversion (show supported formats matrix)
- PDF merging capabilities
- Output delivery

b) Image Processing Pipeline:
- Format conversion
- Optimization
- Batch processing
- Background removal (marked as future feature)

##### Technical Stack Representation

Technologies:
- Go (1.22+)
- LibreOffice integration
- Docker containerization
- TailwindCSS
- Native JavaScript

##### Architectural Patterns

Emphasize:
- Clean architecture (internal/pkg separation)
- Handler-Processor-Validator pattern
- Stateless processing model
- Containerized deployment

a) Frontend Components:
**/templates**
- components/
- pages/
- js/

b) Backend Services:
**/internal**
- handlers/
- processor/
- validator/

c) Supporting Infrastructure:
- Docker container
- Temporary storage volume
- LibreOffice service

##### Important Notes

- Isolated processing environment
- Immediate delivery mechanism
- Cleanup processes
- Validation checkpoints

This system design should emphasize the project's core strengths: its clean architecture, efficient processing pipeline, and security-conscious design with no permanent file storage.

## Diagram (Mermaid)

```mermaid
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#2B2B2B',
    'primaryTextColor': '#fff',
    'primaryBorderColor': '#7C7C7C',
    'lineColor': '#7C7C7C',
    'secondaryColor': '#393939',
    'tertiaryColor': '#fff'
  }
}}%%

flowchart TB
    classDef frontend fill:#4A90E2,stroke:#2171C7,color:white
    classDef backend fill:#50C878,stroke:#2E8B57,color:white
    classDef storage fill:#FFB366,stroke:#FF8000,color:white
    classDef validation fill:#FFD700,stroke:#DAA520,color:black
    classDef processing fill:#9370DB,stroke:#673AB7,color:white
    classDef future fill:#A9A9A9,stroke:#808080,color:white
    classDef error fill:#FF6B6B,stroke:#DC3545,color:white

    subgraph Web["Web Interface Layer"]
        UI["Web UI"]:::frontend
        Templates["Templates"]:::frontend
        JS["JavaScript Handlers"]:::frontend
        CSS["TailwindCSS"]:::frontend
    end

    subgraph Server["Server Layer"]
        MainServer["Main Server"]:::backend
        ReqHandlers["Request Handlers"]:::backend
        ErrorHandle["Error Handling"]:::error
        Response["Response Handler"]:::backend
    end

    subgraph Validation["Validation Layer"]
        InputVal["Input Validation"]:::validation
        Constants["Constants & Config"]:::validation
    end

    subgraph Processing["Processing Layer"]
        DocProc["Document Processor"]:::processing
        ImgProc["Image Processor"]:::processing
        OptService["Optimization Service"]:::processing
        BGRemoval["Background Removal"]:::future
    end

    subgraph Storage["Storage Layer"]
        TempStore["Temporary Storage"]:::storage
    end

    UI --> Templates
    Templates --> JS
    Templates --> CSS
    
    UI --> MainServer
    MainServer --> ReqHandlers
    ReqHandlers --> ErrorHandle
    ReqHandlers --> Response
    ReqHandlers --> InputVal
    InputVal --> Constants
    
    InputVal --> Processing
    Processing --> TempStore
    TempStore --> Response
    Response --> UI

    %% Click events for component mapping
    click MainServer "https://github.com/dendianugerah/reubah/blob/main/cmd/server/main.go"
    click ReqHandlers "https://github.com/dendianugerah/reubah/tree/main/internal/handlers/"
    click InputVal "https://github.com/dendianugerah/reubah/tree/main/internal/validator/"
    click DocProc "https://github.com/dendianugerah/reubah/tree/main/internal/processor/document/"
    click BGRemoval "https://github.com/dendianugerah/reubah/tree/main/internal/processor/background/"
    click OptService "https://github.com/dendianugerah/reubah/tree/main/internal/processor/optimize/"
    click ImgProc "https://github.com/dendianugerah/reubah/tree/main/internal/processor/resize/"
    click Templates "https://github.com/dendianugerah/reubah/tree/main/templates/components/"
    click JS "https://github.com/dendianugerah/reubah/tree/main/templates/js/"
    click UI "https://github.com/dendianugerah/reubah/tree/main/templates/pages/"
    click CSS "https://github.com/dendianugerah/reubah/blob/main/templates/tailwind.config.js"
    click TempStore "https://github.com/dendianugerah/reubah/tree/main/tmp/"
    click ErrorHandle "https://github.com/dendianugerah/reubah/tree/main/pkg/errors/"
    click Response "https://github.com/dendianugerah/reubah/tree/main/pkg/response/"
    click Constants "https://github.com/dendianugerah/reubah/blob/main/internal/constants/constants.go"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Valid["Validation Component"]:::validation
        Proc["Processing Component"]:::processing
        Store["Storage Component"]:::storage
        Fut["Future Feature"]:::future
        Err["Error Handling"]:::error
    end
```
