# datashades/ckanext-charts architecture

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

- Interactive diagram: https://gitdiagram.com/datashades/ckanext-charts
- Repository: https://github.com/datashades/ckanext-charts

## Overview

##### Main Components Identification

a. Core Extension Components:
- View Plugins (charts_view and charts_builder_view)
- Chart Builders Layer
- Data Fetchers Layer
- Caching System

b. Chart Engine Integration:
- ChartJS Integration
- ECharts Integration
- Observable Integration
- Plotly Integration

##### Component Relationships

**Top Layer (Presentation):**
- Templates & Assets
- Web Interface Components

**Middle Layer (Business Logic):**
- Chart Builders
- Data Processing
- Caching System

**Bottom Layer (Data Access):**
- Data Fetchers
- CKAN Core Integration

##### Specific Elements

a. Chart Building Pipeline:
**Data Source → Fetcher → Cache → Builder → Renderer → Frontend Display**

b. Chart Engine Components:
- Parallel implementation of different chart engines
- Demonstrate shared interfaces and specific implementations

##### Key Relationships to Highlight

- View plugins and CKAN core
- Chart builders and their respective JavaScript libraries
- Data fetchers and various data sources

##### Technical Details

- Cache implementation options (Redis/File)
- Supported chart types per engine
- Data format transformations
- Asset management system

##### Implementation Notes

- Configuration management
- Template system
- Asset pipeline
- Testing framework

##### The template hierarchy

Use a hierarchical layout with clear separation between:
- Frontend components (templates, assets)
- Backend services (builders, fetchers)
- Data processing layer
- Caching system

Annotations for:
- Supported file formats
- Chart type capabilities
- Configuration options
- Cache strategies

This will create a comprehensive visualization that accurately represents the extension's architecture while maintaining clarity and usefulness for development and documentation purposes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Backend Component]:::backend
        L2[Frontend Component]:::frontend
        L3[(Database/Cache)]:::storage
        L4[Chart Engine]:::engine
    end

    subgraph "Frontend Layer"
        Templates["Templates"]:::frontend
        click Templates "https://github.com/DataShades/ckanext-charts/tree/master/ckanext/charts/templates/charts"
        Assets["Assets Management"]:::frontend
        click Assets "https://github.com/DataShades/ckanext-charts/tree/master/ckanext/charts/assets"
        WebInterface["Web Interface Components"]:::frontend
    end

    subgraph "Core Extension Layer"
        ViewPlugins["View Plugins"]:::backend
        click ViewPlugins "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/plugin.py"
        Config["Configuration Management"]:::backend
        click Config "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/config.py"
    end

    subgraph "Chart Building Layer"
        ChartBuilders["Chart Builders Base"]:::backend
        click ChartBuilders "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/chart_builders/base.py"
        
        subgraph "Chart Engines"
            ChartJS["ChartJS Builder"]:::engine
            click ChartJS "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/chart_builders/chartjs.py"
            ECharts["ECharts Builder"]:::engine
            click ECharts "https://github.com/DataShades/ckanext-charts/tree/master/ckanext/charts/chart_builders/echarts"
            Observable["Observable Builder"]:::engine
            click Observable "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/chart_builders/observable.py"
            Plotly["Plotly Builder"]:::engine
            click Plotly "https://github.com/DataShades/ckanext-charts/tree/master/ckanext/charts/chart_builders/plotly"
        end
    end

    subgraph "Data Processing Layer"
        DataFetchers["Data Fetchers"]:::backend
        click DataFetchers "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/fetchers.py"
        Cache["Caching System"]:::storage
        click Cache "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/cache.py"
    end

    subgraph "Frontend Integration"
        ChartJSRender["ChartJS Renderer"]:::frontend
        click ChartJSRender "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/assets/js/charts-render-chartjs.js"
        EChartsRender["ECharts Renderer"]:::frontend
        click EChartsRender "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/assets/js/charts-render-echarts.js"
        ObservableRender["Observable Renderer"]:::frontend
        click ObservableRender "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/assets/js/charts-render-observable.js"
        PlotlyRender["Plotly Renderer"]:::frontend
        click PlotlyRender "https://github.com/DataShades/ckanext-charts/blob/master/ckanext/charts/assets/js/charts-render-plotly.js"
    end

    %% Relationships
    ViewPlugins --> Templates
    ViewPlugins --> ChartBuilders
    Config --> ChartBuilders
    Assets --> WebInterface
    Templates --> WebInterface

    ChartBuilders --> ChartJS
    ChartBuilders --> ECharts
    ChartBuilders --> Observable
    ChartBuilders --> Plotly

    ChartJS --> ChartJSRender
    ECharts --> EChartsRender
    Observable --> ObservableRender
    Plotly --> PlotlyRender

    DataFetchers --> Cache
    Cache --> ChartBuilders

    ChartJSRender --> WebInterface
    EChartsRender --> WebInterface
    ObservableRender --> WebInterface
    PlotlyRender --> WebInterface

    %% Styles
    classDef backend fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef frontend fill:#f9d79b,stroke:#333,stroke-width:2px
    classDef storage fill:#c39bd3,stroke:#333,stroke-width:2px
    classDef engine fill:#f5b041,stroke:#333,stroke-width:2px
```
