# linuxscout/yaziji architecture

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

- Interactive diagram: https://gitdiagram.com/linuxscout/yaziji
- Repository: https://github.com/linuxscout/yaziji

## Overview

##### Main System Components

a) Core Engine Layer:
- Main components: phrase_generator, phrase_pattern, stream_pattern, and components_set
- Data.json connection for word patterns and rules

b) Web Service Layer:
- Flask-based web server (yaziji_webserver.py)
- Database managers (MongoDB/SQLite options)
- Babel internationalization service
- Configuration management

c) Frontend Layer:
- Static resources
- Templates
- i18n support
- Client-side JavaScript components

##### Key Relationships to Illustrate

**User Interface → Web API → Core Engine → Database**
- ↕
- Translation Layer

##### Detailed Component Breakdown

a) Core Engine Components:
**┌─ Core Engine ─────────────┐**
- Phrase Generator        │
- Pattern Matcher         │
- Stream Processor        │
- Word Node Manager       │
- ┘

b) Translation System:
**┌─ Translation Layer ────────┐**
- PO Files                 │
- Language Configs         │
- Babel Integration        │
- Multi-language Support   │
- ┘

c) Web Service:
**┌─ Web Service ─────────────┐**
- Flask Server            │
- Route Handlers          │
- Database Interface      │
- Config Management       │
- ┘

##### Data Flow Indicators

- User input flow
- Translation processing
- Phrase generation pipeline
- Response delivery

##### Integration Points

Highlight:
- API endpoints
- Database connections
- Translation interfaces
- Frontend-backend communication

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Core Engine Layer"
        CoreEngine["Core Engine"]
        PhraseGen["Phrase Generator"]
        PhrasePat["Pattern Matcher"]
        StreamProc["Stream Processor"]
        WordNode["Word Node Manager"]
        CoreData[(Core Data Storage)]
    end

    subgraph "Web Service Layer"
        WebServer["Flask Server"]
        DBInterface["Database Interface"]
        MongoDB[(MongoDB)]
        SQLite[(SQLite)]
        ConfigMgr["Configuration Manager"]
        BabelService["Babel Translation Service"]
    end

    subgraph "Frontend Layer"
        Templates["Templates"]
        StaticRes["Static Resources"]
        ClientJS["Client JavaScript"]
        I18nFront["Frontend i18n"]
    end

    subgraph "Translation Layer"
        I18nBack["Backend i18n"]
        TransFiles["Translation Files"]
        LangConfig["Language Configs"]
    end

    %% Core Engine Relationships
    CoreEngine --> PhraseGen
    CoreEngine --> PhrasePat
    CoreEngine --> StreamProc
    CoreEngine --> WordNode
    CoreEngine --> CoreData

    %% Web Service Relationships
    WebServer --> CoreEngine
    WebServer --> DBInterface
    DBInterface --> MongoDB
    DBInterface --> SQLite
    WebServer --> ConfigMgr
    WebServer --> BabelService

    %% Frontend Relationships
    Templates --> WebServer
    StaticRes --> WebServer
    ClientJS --> WebServer
    I18nFront --> BabelService

    %% Translation Relationships
    BabelService --> I18nBack
    I18nBack --> TransFiles
    BabelService --> LangConfig
    I18nFront --> TransFiles

    %% Component Styling
    classDef core fill:#a8d1f0
    classDef web fill:#90EE90
    classDef front fill:#FFB347
    classDef trans fill:#FFE5B4
    classDef data fill:#DDA0DD

    class CoreEngine,PhraseGen,PhrasePat,StreamProc,WordNode core
    class WebServer,DBInterface,ConfigMgr,BabelService web
    class Templates,StaticRes,ClientJS,I18nFront front
    class I18nBack,TransFiles,LangConfig trans
    class CoreData,MongoDB,SQLite data

    %% Click Events
    click CoreEngine "https://github.com/linuxscout/yaziji/tree/master/yaziji/"
    click PhraseGen "https://github.com/linuxscout/yaziji/blob/master/yaziji/phrase_generator.py"
    click PhrasePat "https://github.com/linuxscout/yaziji/blob/master/yaziji/phrase_pattern.py"
    click StreamProc "https://github.com/linuxscout/yaziji/blob/master/yaziji/stream_pattern.py"
    click WordNode "https://github.com/linuxscout/yaziji/blob/master/yaziji/components_set.py"
    click CoreData "https://github.com/linuxscout/yaziji/blob/master/yaziji/data/data.json"
    click WebServer "https://github.com/linuxscout/yaziji/blob/master/web/yaziji_webserver.py"
    click DBInterface "https://github.com/linuxscout/yaziji/tree/master/web/db_manager/"
    click MongoDB "https://github.com/linuxscout/yaziji/blob/master/web/db_manager/db_mongo.py"
    click SQLite "https://github.com/linuxscout/yaziji/blob/master/web/db_manager/db_sqlite.py"
    click BabelService "https://github.com/linuxscout/yaziji/blob/master/web/yaziji_babel.py"
    click ConfigMgr "https://github.com/linuxscout/yaziji/tree/master/web/config/"
    click Templates "https://github.com/linuxscout/yaziji/tree/master/web/templates/"
    click StaticRes "https://github.com/linuxscout/yaziji/tree/master/web/static/resources/"
    click ClientJS "https://github.com/linuxscout/yaziji/tree/master/web/static/resources/files/"
    click I18nFront "https://github.com/linuxscout/yaziji/tree/master/web/static/resources/i18n/"
    click I18nBack "https://github.com/linuxscout/yaziji/tree/master/web/locales/"
    click TransFiles "https://github.com/linuxscout/yaziji/tree/master/translations/"
    click LangConfig "https://github.com/linuxscout/yaziji/blob/master/web/config/yaziji_config.py"
```
