# fathym-deno/eac-runtime architecture

> Architecture diagram of the GitHub repository fathym-deno/eac-runtime, 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/fathym-deno/eac-runtime
- Repository: https://github.com/fathym-deno/eac-runtime

## Overview

##### Main Architectural Components

a) Core Runtime Layer
- Configuration system (EaCRuntimeConfig)
- Handler pipeline system

b) Distributed File System (DFS) Layer
- Different DFS handlers (Local, KV, Remote, Worker)
- File resolution system

c) Module System Layer
- Various middleware modules:
- Authentication (JWT, OAuth)
- Performance (Cache, Keep-Alive)
- Content Processing (Markdown, Tailwind)
- Integration (Stripe)
- Monitoring (Tracing)

d) Processing Layer
- Different processors:
- API Processor
- Preact App Processor
- Proxy Processor
- Response Processor
- Tailwind Processor

##### Component Relationships

a) Request Flow:
- Entry point (server) → Runtime → Handler Pipeline
- How requests flow through middleware
- How processors are selected and executed

b) File System Integration:
- How DFS connects with different storage backends
- File resolution process

c) Plugin System:
- Demonstrate how plugins integrate with the core runtime
- Plugin configuration flow

##### Specific Implementation Details

Key architectural patterns:

a) Middleware Chain:
- Sequential processing of middleware
- How middleware can be composed

b) Island Architecture:
- Demonstrate the island-based component system
- Client/server boundary

c) Plugin System:
- How plugins extend core functionality
- Plugin registration and initialization

**┌─────────────────────────────────────────────┐**
- HTTP Server                   │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- EaC Runtime Core               │
- ┌─────────┐  ┌─────────┐  ┌─────────┐     │
- Config   │  │Handler  │  │Plugin   │     │
- System   │  │Pipeline │  │System   │     │
- ┘  └─────────┘  └─────────┘     │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Module System                   │
- ┌─────────┐  ┌─────────┐  ┌─────────┐     │
- Auth     │  │Cache    │  │Content  │     │
- Modules  │  │Modules  │  │Modules  │     │
- ┘  └─────────┘  └─────────┘     │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Distributed File System             │
- ┌─────────┐  ┌─────────┐  ┌─────────┐     │
- Local    │  │KV Store │  │Remote   │     │
- Storage  │  │         │  │Storage  │     │
- ┘  └─────────┘  └─────────┘     │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Server["HTTP Server Layer"]
        Server_Entry[Server Entry Point]
    end

    subgraph Core["Core Runtime Layer"]
        Runtime["Main Runtime"]:::runtime
        Config["Configuration System"]:::config
        HandlerPipeline["Handler Pipeline"]:::pipeline
        PluginSystem["Plugin System"]:::plugin
    end

    subgraph Plugins["Plugin Layer"]
        CorePlugin["Core Plugin"]:::plugin
        DFSPlugin["DFS Plugin"]:::plugin
        EaCPlugin["EaC Plugin"]:::plugin
        ServicesPlugin["Services Plugin"]:::plugin
    end

    subgraph Processors["Processing Layer"]
        APIProcessor["API Processor"]:::processor
        PreactProcessor["Preact App Processor"]:::processor
        ProxyProcessor["Proxy Processor"]:::processor
        ResponseProcessor["Response Processor"]:::processor
        TailwindProcessor["Tailwind Processor"]:::processor
    end

    subgraph Middleware["Middleware Layer"]
        direction TB
        AuthJWT["JWT Auth"]:::middleware
        AuthOAuth["OAuth"]:::middleware
        Cache["Cache System"]:::middleware
        KeepAlive["Keep-Alive"]:::middleware
        Markdown["Markdown Processing"]:::middleware
        TailwindMW["Tailwind Processing"]:::middleware
        Stripe["Stripe Integration"]:::middleware
        Tracing["Tracing"]:::middleware
    end

    subgraph DFS["Distributed File System Layer"]
        DFSCore["DFS Core"]:::dfs
        LocalStorage["Local Storage"]:::dfs
        KVStorage["KV Storage"]:::dfs
        RemoteStorage["Remote Storage"]:::dfs
        WorkerStorage["Worker Storage"]:::dfs
    end

    %% Connections
    Server_Entry --> Runtime
    Runtime --> HandlerPipeline
    Runtime --> Config
    Runtime --> PluginSystem

    PluginSystem --> CorePlugin
    PluginSystem --> DFSPlugin
    PluginSystem --> EaCPlugin
    PluginSystem --> ServicesPlugin

    HandlerPipeline --> Processors
    HandlerPipeline --> Middleware

    DFSCore --> LocalStorage
    DFSCore --> KVStorage
    DFSCore --> RemoteStorage
    DFSCore --> WorkerStorage

    %% Styles
    classDef runtime fill:#2b6cb0
    classDef config fill:#2b6cb0
    classDef pipeline fill:#2b6cb0
    classDef plugin fill:#9f7aea
    classDef processor fill:#48bb78
    classDef middleware fill:#ed8936
    classDef dfs fill:#667eea

    %% Click Events
    click Runtime "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/DefaultEaCRuntime.ts"
    click Config "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/config/EaCRuntimeConfig.ts"
    click HandlerPipeline "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/EaCRuntimeHandlerPipeline.ts"
    click DFSCore "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/dfs/DFSFileHandler.ts"
    click LocalStorage "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/dfs/EaCLocalDistributedFileSystemHandlerResolver.ts"
    click KVStorage "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/dfs/EaCDenoKVDistributedFileSystemHandlerResolver.ts"
    click RemoteStorage "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/dfs/EaCRemoteDistributedFileSystemHandlerResolver.ts"
    click WorkerStorage "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/dfs/EaCWorkerDistributedFileSystemHandlerResolver.ts"
    click AuthJWT "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/jwt/jwtValidationMiddleware.ts"
    click AuthOAuth "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/oauth/oauthMiddleware.ts"
    click Cache "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/cache/denoKvCacheMiddleware.ts"
    click KeepAlive "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/keepAlive/keepAliveMiddleware.ts"
    click Markdown "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/markdown/markdownToHtmlMiddleware.ts"
    click TailwindMW "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/tailwind/compiler.ts"
    click Stripe "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/stripe/stripeMiddleware.ts"
    click Tracing "https://github.com/fathym-deno/eac-runtime/blob/integration/src/modules/tracing/tracingMiddleware.ts"
    click APIProcessor "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/processors/EaCAPIProcessorHandlerResolver.ts"
    click PreactProcessor "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/processors/EaCPreactAppProcessorHandlerResolver.tsx"
    click ProxyProcessor "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/processors/EaCProxyProcessorHandlerResolver.ts"
    click ResponseProcessor "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/processors/EaCResponseProcessorHandlerResolver.ts"
    click TailwindProcessor "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/processors/EaCTailwindProcessorHandlerResolver.ts"
    click CorePlugin "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/plugins/FathymCorePlugin.ts"
    click DFSPlugin "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/plugins/FathymDFSFileHandlerPlugin.ts"
    click EaCPlugin "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/plugins/FathymEaCPlugin.ts"
    click ServicesPlugin "https://github.com/fathym-deno/eac-runtime/blob/integration/src/runtime/plugins/FathymEaCServicesPlugin.ts"
```
