# willem3141/navi-reykunyu architecture

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

- Interactive diagram: https://gitdiagram.com/willem3141/navi-reykunyu
- Repository: https://github.com/willem3141/navi-reykunyu

## Overview

##### Main Components

a. Frontend Layer:
- As a web interface component with submodules:
- Study/Learning Interface (based on /frontend/src/study*.ts files)
- Dictionary Search Interface (based on frontend templates)
- Editor Interface (corpus, etymology, sources editors)

b. Backend Layer:
- Core Dictionary Engine (/src/dictionary.js, /src/annotatedDictionary.js)
- Authentication System (/src/auth.js)
- API Service (/src/api.js)
- Language Processing Components:
- Word Processing (verbs.js, nouns.js, adjectives.js)
- Phonology Handler (phonology.js)
- Translation Service (translations.js)

c. Data Layer:
- Database Connection (/src/db.js)
- Word Dictionary Storage (data/words.json)

##### Component Relationships

- HTTP/API requests between frontend and backend
- Data flow between backend and database
- Internal module dependencies

##### Key Architectural Patterns to Highlight

a. MVC-like Structure:
- Models: dictionary data and word processing
- Views: frontend templates (frontend/templates/)
- Controllers: API and route handlers

b. Modular Design:
- Clear separation between:
- Frontend assets (LESS, TypeScript)
- Backend services
- Data storage

##### Technical Stack Elements

- Node.js Backend (indicated by package.json)
- TypeScript Frontend (frontend/src/*.ts)
- LESS CSS Preprocessing (frontend/less/)
- EJS Template Engine (frontend/templates/*.ejs)

##### Additional Elements

a. Build/Deploy Pipeline:
- Gulp build process (gulpfile.js)
- Asset compilation flow

b. External Interfaces:
- OpenSearch integration (opensearch.xml)
- Public API endpoints

**[User Interface Layer]**
- ↓ ↑
**[Frontend Application Layer]**
- ↓ ↑
**[API/Backend Services Layer]**
- ↓ ↑
**[Data Storage Layer]**

Important Considerations:

##### Clear boundaries between
- Public-facing components
- Internal services
- Data management systems

Remember to indicate the scalability points and potential areas for extension, as this is an open-source project that others might want to build upon.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#d0e1f9,stroke:#333
    classDef backend fill:#c2e6c0,stroke:#333
    classDef data fill:#fff3b0,stroke:#333
    classDef api fill:#ffd6d6,stroke:#333
    classDef core fill:#e6c2e6,stroke:#333

    %% User Interface Layer
    subgraph UI
        WebInterface["Web Interface"]
    end

    %% Frontend Layer
    subgraph Frontend
        SearchUI["Dictionary Search UI"]:::frontend
        StudyUI["Study Interface"]:::frontend
        EditorUI["Editor Interface"]:::frontend
        Styles["Frontend Styling"]:::frontend
        AuthUI["Authentication UI"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        ServerCore["Server Core"]:::core
        APIService["API Service"]:::api
        AuthSystem["Authentication System"]:::backend
        
        subgraph DictionaryServices
            CoreDict["Core Dictionary Engine"]:::backend
            WordProc["Word Processing"]:::backend
            PhonologyHandler["Phonology Handler"]:::backend
            TransService["Translation Service"]:::backend
        end
    end

    %% Data Layer
    subgraph Data
        DB[(Database)]:::data
        WordStorage[("Dictionary Storage")]:::data
        TranslationData[("Translation Data")]:::data
    end

    %% Relationships
    WebInterface --> SearchUI
    WebInterface --> StudyUI
    WebInterface --> EditorUI
    WebInterface --> AuthUI

    SearchUI --> APIService
    StudyUI --> APIService
    EditorUI --> APIService
    AuthUI --> AuthSystem

    APIService --> ServerCore
    ServerCore --> CoreDict
    ServerCore --> AuthSystem

    CoreDict --> WordProc
    CoreDict --> PhonologyHandler
    CoreDict --> TransService

    WordProc --> DB
    TransService --> TranslationData
    CoreDict --> WordStorage

    %% Click Events
    click StudyUI "https://github.com/Willem3141/navi-reykunyu/blob/master/frontend/src/study.ts"
    click EditorUI "https://github.com/Willem3141/navi-reykunyu/blob/master/frontend/dist/js/corpusEditor.js"
    click CoreDict "https://github.com/Willem3141/navi-reykunyu/blob/master/src/dictionary.js"
    click AuthSystem "https://github.com/Willem3141/navi-reykunyu/blob/master/src/auth.js"
    click APIService "https://github.com/Willem3141/navi-reykunyu/blob/master/src/api.js"
    click WordProc "https://github.com/Willem3141/navi-reykunyu/blob/master/src/verbs.js"
    click PhonologyHandler "https://github.com/Willem3141/navi-reykunyu/blob/master/src/phonology.js"
    click TransService "https://github.com/Willem3141/navi-reykunyu/blob/master/src/translations.js"
    click DB "https://github.com/Willem3141/navi-reykunyu/blob/master/src/db.js"
    click Styles "https://github.com/Willem3141/navi-reykunyu/tree/master/frontend/less"
    click ServerCore "https://github.com/Willem3141/navi-reykunyu/blob/master/src/server.js"
    click AuthUI "https://github.com/Willem3141/navi-reykunyu/blob/master/frontend/templates/login-modal.ejs"

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Component"]:::backend
        Data["Data Storage"]:::data
        API["API Component"]:::api
        Core["Core Component"]:::core
    end
```
