# denpy/alfred-curlbus architecture

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

- Interactive diagram: https://gitdiagram.com/denpy/alfred-curlbus
- Repository: https://github.com/denpy/alfred-curlbus

## Overview

##### Project Type Analysis
This is an Alfred workflow integration project that:
- Interfaces with an external curlbus service
- Handles user input through Alfred
- Processes and displays bus arrival information
- Uses Python for core functionality

##### Main Components

A. User Interface Layer:
- Alfred Workflow Interface
- Input handling (station selection)
- Output formatting (ETA display)

B. Core Components:
- Python Script (curlbus.py)
- Environment Variables Handler
- Station ID Configuration

C. External Services:
- Curlbus API Service
- Israeli Transit System

**┌─────────────────────────────────────────────────┐**
- Alfred Interface                 │
- ┘
- ↓↑
**┌─────────────────────────────────────────────────┐**
- Python Script (curlbus.py)         │
- ┌────────────────┐        ┌───────────────┐   │
- Config Reader │        │ Response      │   │
- (Env Vars)    │        │ Formatter     │   │
- ┘        └───────────────┘   │
- ┘
- ↓↑
**┌─────────────────────────────────────────────────┐**
- Curlbus API Service               │
- ┘
- ↓↑
**┌─────────────────────────────────────────────────┐**
- Israeli Transit System               │
- ┘

##### Important Elements to Highlight

A. Input Flow:
- User input through Alfred command "curlbus"
- Station selection (Home/Work/Manual ID)
- Environment variables configuration

B. Processing Flow:
- Python script execution
- API communication
- Response formatting

C. Output Flow:
- ETA information display
- Error handling

##### Key Relationships to Emphasize
- Alfred Workflow → Python Script interaction
- Python Script → Curlbus API communication
- Configuration → Runtime behavior

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        User(("User"))
        AlfredInterface["Alfred Workflow Interface"]:::alfred
        InputOptions{"Input Options"}:::input
        OutputDisplay["ETA Display"]:::output
    end

    subgraph Core["Core Processing Layer"]
        PythonScript["curlbus.py"]:::python
        ConfigHandler["Environment Variables Handler"]:::config
        StationProcessor["Station ID Processor"]:::processor
    end

    subgraph External["External Services Layer"]
        CurlbusAPI["Curlbus API"]:::api
        TransitSystem["Israeli Transit System"]:::external
    end

    User --> AlfredInterface
    AlfredInterface --> InputOptions
    InputOptions -->|"Home Station"| PythonScript
    InputOptions -->|"Work Station"| PythonScript
    InputOptions -->|"Manual Station ID"| PythonScript
    
    PythonScript --> ConfigHandler
    PythonScript --> StationProcessor
    StationProcessor --> CurlbusAPI
    CurlbusAPI --> TransitSystem
    TransitSystem --> CurlbusAPI
    CurlbusAPI --> PythonScript
    PythonScript --> OutputDisplay
    OutputDisplay --> AlfredInterface

    subgraph Config["Configuration"]
        EnvVars["Environment Variables"]:::config
        direction TB
        EnvVars -->|"Station IDs"| ConfigHandler
        EnvVars -->|"Python Path"| ConfigHandler
    end

    %% Click Events
    click AlfredInterface "https://github.com/denpy/alfred-curlbus/blob/master/curlbus.alfredworkflow"
    click PythonScript "https://github.com/denpy/alfred-curlbus/blob/master/curlbus.py"

    %% Styling
    classDef alfred fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef input fill:#f9d67a,stroke:#333,stroke-width:2px
    classDef output fill:#a8f0c6,stroke:#333,stroke-width:2px
    classDef python fill:#4a9eda,stroke:#333,stroke-width:2px,color:#fff
    classDef config fill:#f4d03f,stroke:#333,stroke-width:2px
    classDef processor fill:#85c1e9,stroke:#333,stroke-width:2px
    classDef api fill:#ec7063,stroke:#333,stroke-width:2px
    classDef external fill:#bdc3c7,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        direction TB
        L1["User Interface"]:::alfred
        L2["Input Component"]:::input
        L3["Output Component"]:::output
        L4["Python Process"]:::python
        L5["Configuration"]:::config
        L6["Data Processor"]:::processor
        L7["External API"]:::api
        L8["External System"]:::external
    end
```
