# altcha-org/altcha architecture

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

- Interactive diagram: https://gitdiagram.com/altcha-org/altcha
- Repository: https://github.com/altcha-org/altcha

## Overview

##### Main Components

a. Client-Side Components:
- Web Component (altcha-widget)
- Worker Pool (for proof-of-work computation)
- Plugin System
- Core Verification Logic

b. Server-Side Components:
- Challenge Generation Service
- Verification Service
- Spam Filter Service
- Analytics Service (optional)

- Client Browser                                         |

- ALTCHA Widget   |  |   Worker Pool    |  |            Plugins               |      |
- (Web Component)  |--→| (PoW Computing) |  | - Analytics                      |      |
- Obfuscation                    |      |
- ↑                                   | - Upload                         |      |

- ↓                                                                     ↓

- Server Side                                            |

- Challenge     |  |   Verification    |  |          Spam Filter            |      |
- Generator     |←-→|     Service      |←-→|        Classification          |      |

##### Key Elements to Highlight

a. Data Flow Indicators:
- Challenge request flow
- Proof-of-work computation flow
- Verification flow
- Plugin integration points

b. Component Relationships:

##### Technical Details

- Worker pool configuration (max 16 workers)
- Challenge verification endpoints
- Spam filter integration points
- File upload paths (for upload plugin)
- Analytics data flow (for analytics plugin)

##### Implementation Notes

- Rectangles: Core components
- Hexagons: Services
- Circles: Integration points
- Diamonds: Decision points

- Blue: Core functionality
- Green: Optional plugins
- Yellow: Security-related components
- Gray: External services

##### Additional Elements

- Configuration options as a separate section
- Error handling paths
- Where CSP considerations apply

##### Optimization Paths

- Bundle optimization routes
- Where external resources can be loaded
- Critical rendering paths

- Self-hosted nature
- Cookie-less operation
- GDPR compliance
- Proof-of-work mechanism
- Plugin extensibility

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Browser"]
        Widget["ALTCHA Widget"]:::widget
        WorkerPool["Worker Pool"]:::worker
        Core["Core Verification"]:::core
        
        subgraph Plugins["Plugin System"]
            direction TB
            PluginManager["Plugin Manager"]:::plugin
            Analytics["Analytics Plugin"]:::plugin
            Obfuscation["Obfuscation Plugin"]:::plugin
            Upload["Upload Plugin"]:::plugin
            
            PluginManager --> Analytics
            PluginManager --> Obfuscation
            PluginManager --> Upload
        end
        
        Widget --> WorkerPool
        Widget --> Core
        Widget --> PluginManager
    end
    
    subgraph Server["Server Side"]
        Challenge["Challenge Generator"]:::server
        Verify["Verification Service"]:::server
        SpamFilter["Spam Filter"]:::server
        
        Challenge <--> Verify
        Verify <--> SpamFilter
    end
    
    Widget <--> Challenge
    Core <--> Verify
    
    classDef widget fill:#3498db,stroke:#2980b9,color:white
    classDef worker fill:#e74c3c,stroke:#c0392b,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef plugin fill:#9b59b6,stroke:#8e44ad,color:white
    classDef server fill:#f1c40f,stroke:#f39c12,color:black
    
    %% Click events for component mapping
    click Widget "https://github.com/altcha-org/altcha/blob/main/src/Altcha.svelte"
    click WorkerPool "https://github.com/altcha-org/altcha/blob/main/src/worker.ts"
    click PluginManager "https://github.com/altcha-org/altcha/blob/main/src/plugin.ts"
    click Analytics "https://github.com/altcha-org/altcha/blob/main/src/plugins/analytics.ts"
    click Obfuscation "https://github.com/altcha-org/altcha/blob/main/src/plugins/obfuscation.ts"
    click Upload "https://github.com/altcha-org/altcha/blob/main/src/plugins/upload.ts"
    click Core "https://github.com/altcha-org/altcha/blob/main/src/helpers.ts"
    click Challenge "https://github.com/altcha-org/altcha/blob/main/server/server-deno.ts"
    click Verify "https://github.com/altcha-org/altcha/blob/main/server/server-deno.ts"
    
    %% Legend
    subgraph Legend
        L1["Widget Component"]:::widget
        L2["Worker Process"]:::worker
        L3["Core Logic"]:::core
        L4["Plugin Component"]:::plugin
        L5["Server Component"]:::server
    end
```
