# shioyama/mobility architecture

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

- Interactive diagram: https://gitdiagram.com/shioyama/mobility
- Repository: https://github.com/shioyama/mobility

## Overview

##### Main Components Overview

a) Core Components:
- Mobility Core (central orchestrator)
- Plugin System
- Backend System
- ORM Integration Layer (ActiveRecord/Sequel)

b) Storage Components:
- Database Layer (showing multiple backend options)
- Cache Layer

##### Detailed Component Breakdown

A. Core Layer:
**┌─────────────────────────────────────────────┐**
- Mobility Core                │
- ┤
- Translation Coordination                  │
- Locale Management                         │
- Configuration Management                  │
- ┘

B. Plugin System:
**┌─────────────────────────────────────────────┐**
- Plugin System                 │
- ┤
- Cache Plugin                             │
- Fallbacks Plugin                         │
- Dirty Tracking Plugin                    │
- Query Plugin                             │
- Locale Accessors Plugin                  │
- ┘

C. Backend System:
**┌─────────────────────────────────────────────┐**
- Backend System                 │
- ┤
- Key-Value Backend    │ Table Backend        │
- Column Backend      │ Container Backend    │
- JSON/JSONB Backend  │ Hstore Backend       │
- ┘

##### Integration Flow

- Model → Mobility Core → Plugins → Backend → Storage
- Cache interaction paths

##### Important Elements

a) Interface Layer:
- Model translation definition interface
- Query interface
- Locale management interface

b) Storage Strategies:
- Supported backend types
- Database compatibility

c) Plugin Integration:
- How plugins interact with core
- Optional vs. required plugins

##### Specific Implementation Details

Technical details such as:
- Translation table structures
- Cache implementation
- Fallback chains
- Query builder integration

##### Notes for Implementation

- Maintain consistent styling
- Version information
- Notes for specific implementation details

**┌─────────────────────────────────────────────┐**
- Application Layer             │
- ┤
- Mobility Core                 │
- ┤
- Plugin System                 │
- ┤
- Backend System               │
- ┤
- Storage Layer                 │
- ┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application Layer"
        Model["Application Models"]
    end

    subgraph "Core Layer"
        MobilityCore["Mobility Core"]:::core
        Config["Configuration Management"]:::core
    end

    subgraph "Plugin Layer"
        PluginSystem["Plugin System"]:::plugin
        Cache["Cache Plugin"]:::plugin
        Fallbacks["Fallbacks Plugin"]:::plugin
        Dirty["Dirty Plugin"]:::plugin
        Query["Query Plugin"]:::plugin
        LocaleAccessors["Locale Accessors"]:::plugin
    end

    subgraph "ORM Integration"
        ActiveRecord["ActiveRecord Integration"]:::orm
        Sequel["Sequel Integration"]:::orm
        ARCache["ActiveRecord Cache"]:::orm
        SeqCache["Sequel Cache"]:::orm
        ARQuery["ActiveRecord Query"]:::orm
        SeqQuery["Sequel Query"]:::orm
    end

    subgraph "Backend Layer"
        BackendSystem["Backend System"]:::backend
        KeyValue["Key-Value Backend"]:::backend
        Column["Column Backend"]:::backend
        Table["Table Backend"]:::backend
        JSON["JSON Backend"]:::backend
        JSONB["JSONB Backend"]:::backend
        Hstore["Hstore Backend"]:::backend
    end

    subgraph "Storage Layer"
        DB[(Database)]:::storage
        Cache_Store[(Cache Store)]:::storage
    end

    %% Relationships
    Model --> MobilityCore
    MobilityCore --> PluginSystem
    MobilityCore --> Config
    PluginSystem --> |Manages|Cache
    PluginSystem --> |Manages|Fallbacks
    PluginSystem --> |Manages|Dirty
    PluginSystem --> |Manages|Query
    PluginSystem --> |Manages|LocaleAccessors
    
    Query --> ARQuery
    Query --> SeqQuery
    Cache --> ARCache
    Cache --> SeqCache
    
    PluginSystem --> ActiveRecord
    PluginSystem --> Sequel
    
    MobilityCore --> BackendSystem
    BackendSystem --> KeyValue
    BackendSystem --> Column
    BackendSystem --> Table
    BackendSystem --> JSON
    BackendSystem --> JSONB
    BackendSystem --> Hstore
    
    KeyValue --> DB
    Column --> DB
    Table --> DB
    JSON --> DB
    JSONB --> DB
    Hstore --> DB
    
    Cache --> Cache_Store

    %% Styles
    classDef core fill:#2374ab
    classDef plugin fill:#57a773
    classDef backend fill:#ff8c42
    classDef storage fill:#9b5de5
    classDef orm fill:#f15bb5

    %% Click Events
    click MobilityCore "https://github.com/shioyama/mobility/blob/master/lib/mobility.rb"
    click PluginSystem "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugin.rb"
    click BackendSystem "https://github.com/shioyama/mobility/blob/master/lib/mobility/backend.rb"
    click KeyValue "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/key_value.rb"
    click Column "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/column.rb"
    click Table "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/table.rb"
    click JSON "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/json.rb"
    click JSONB "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/jsonb.rb"
    click Hstore "https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/hstore.rb"
    click Cache "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/cache.rb"
    click Fallbacks "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/fallbacks.rb"
    click Dirty "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/dirty.rb"
    click Query "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/query.rb"
    click LocaleAccessors "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/locale_accessors.rb"
    click ActiveRecord "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/active_record.rb"
    click Sequel "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/sequel.rb"
    click ARCache "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/active_record/cache.rb"
    click SeqCache "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/sequel/cache.rb"
    click ARQuery "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/active_record/query.rb"
    click SeqQuery "https://github.com/shioyama/mobility/blob/master/lib/mobility/plugins/sequel/query.rb"
```
