# nextstrain/auspice architecture

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

- Interactive diagram: https://gitdiagram.com/nextstrain/auspice
- Repository: https://github.com/nextstrain/auspice

## Overview

##### Main Components (Top Level)

a) Client-Side Application
- Use a large container to represent the React-based frontend
- Major component groups:
- Tree Visualization
- Visualization
- Controls Panel
- Narrative System
- Data Loading/Processing

b) Server Component
- Node.js server functionality
- API endpoints and data serving capabilities

##### Key Architectural Layers (Left to Right)

a) Data Layer
- Input data sources (JSON files, narratives)
- Data processing utilities
- State management (Redux store)

b) Core Application Layer
- Components hierarchy
- Actions/Reducers flow
- Middleware services

c) Presentation Layer
- UI Components
- Visualization elements (D3.js integration)
- Localization system

##### Important Interactions to Highlight

a) Data Flow
- How data moves from JSON files through the processing pipeline
- State management flow with Redux
- Demonstrate the interaction between components

b) Key Features
- Phylogenetic tree rendering pipeline
- Geographic visualization system
- Narrative functionality
- Multi-language support

##### Specific Implementation Details

a) Technology Stack Indicators
- React
- Redux
- D3.js
- WebPack
- TypeScript/JavaScript

b) External Integrations
- Mapbox integration
- Analytics services
- Data source connections

##### Development Tooling
- Build pipeline
- Testing framework integration
- Development server setup

Use the following symbols and conventions:

- Rectangles: Components and modules
- Hexagons: External services/integrations
- Blue: Frontend components
- Green: Server components
- Yellow: Data processing
- Purple: External services
- Gray: Development tools

Key Considerations:

1. Modular nature of the application, showing how components can be reused or extended.

2. Separation between the core visualization engine and the data processing pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client ["Client-Side Application"]
        direction TB
        subgraph DataLayer ["Data Layer"]
            direction TB
            JSON[("JSON Files")]
            DataProc["Data Processing"]:::data
            Redux["Redux Store"]:::state
        end

        subgraph CoreApp ["Core Application Layer"]
            direction TB
            TreeVis["Tree Visualization"]:::frontend
            MapVis["Map Visualization"]:::frontend
            Controls["Controls Panel"]:::frontend
            Narrative["Narrative System"]:::frontend
            DataLoad["Data Loading"]:::data
        end

        subgraph Present ["Presentation Layer"]
            direction TB
            UI["UI Components"]:::frontend
            D3["D3.js Integration"]:::frontend
            L10n["Localization System"]:::frontend
        end
    end

    subgraph Server ["Server Component"]
        direction TB
        API["API Endpoints"]:::server
        DataServe["Data Serving"]:::server
        NarrServe["Narrative Serving"]:::server
    end

    subgraph External ["External Services"]
        direction TB
        Mapbox["Mapbox"]:::external
        Analytics["Analytics"]:::external
    end

    subgraph DevTools ["Development Tools"]
        direction TB
        Webpack["Webpack"]:::tool
        Tests["Testing Framework"]:::tool
        DevServ["Development Server"]:::tool
    end

    %% Connections
    JSON --> DataProc
    DataProc --> Redux
    Redux --> CoreApp
    CoreApp --> Present
    API --> DataServe
    DataServe --> DataLoad
    NarrServe --> Narrative
    MapVis --> Mapbox
    UI --> Analytics

    %% Click Events
    click TreeVis "https://github.com/nextstrain/auspice/tree/master/src/components/tree/"
    click MapVis "https://github.com/nextstrain/auspice/tree/master/src/components/map/"
    click Controls "https://github.com/nextstrain/auspice/tree/master/src/components/controls/"
    click Narrative "https://github.com/nextstrain/auspice/tree/master/src/components/narrative/"
    click API "https://github.com/nextstrain/auspice/tree/master/cli/server/"
    click DataServe "https://github.com/nextstrain/auspice/blob/master/cli/server/getDataset.js"
    click NarrServe "https://github.com/nextstrain/auspice/blob/master/cli/server/getNarrative.js"
    click Redux "https://github.com/nextstrain/auspice/blob/master/src/store.ts"
    click L10n "https://github.com/nextstrain/auspice/tree/master/src/locales/"
    click DataProc "https://github.com/nextstrain/auspice/blob/master/src/util/treeJsonProcessing.ts"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef tool fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef state fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        direction TB
        F["Frontend"]:::frontend
        S["Server"]:::server
        D["Data Processing"]:::data
        E["External Services"]:::external
        T["Development Tools"]:::tool
        ST["State Management"]:::state
    end
```
