# ethandengs/eremois architecture

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

- Interactive diagram: https://gitdiagram.com/ethandengs/eremois
- Repository: https://github.com/ethandengs/eremois

## Overview

##### Main Components
- Applications:
– Desktop App (built with Tauri in apps/desktop)
– Mobile App (React Native in apps/mobile)
– Web App (Next.js in apps/web)
– API Backend (located in apps/api, responsible for handling API requests, authentication, and possibly acting as a server for self-hosted setups)
- Core Packages:
– AI Package (packages/ai): Implements privacy-preserving, edge-based AI (using TensorFlow.js or ONNX Runtime) for local learning and prediction
– Core (packages/core): Contains business logic, authentication context, and other shared data models that drive app behavior
– UI Package (packages/ui): Offers shared components like forms, visualizations, and themed UI elements across platforms
- Supporting Elements:
– Documentation (docs folder) detailing architecture, deployment, and contribution guidelines
– Configuration/Build Tools: Turbo configuration, TypeScript configurations, and scripts in tools/ for setup and maintenance

##### Relationships and Interactions
- Frontend-to-Backend:
– The mobile, web, and desktop apps interface with the backend API (apps/api) for tasks such as authentication and data synchronization (for instance, for self-hosted or multi-device sync scenarios).
– Each frontend might also integrate closely with the local edge AI component (via packages/ai) to perform real-time, privacy-preserving learning on the device.
- Package Dependencies:
– The core business logic (packages/core) is used across various applications to manage scheduling, tasks, and natural rhythm predictions.
– The UI package (packages/ui) is imported by each application for a consistent look, such as the CircularTimeline and interactive components.
- Data Flow:
– User interactions in the app layer trigger calls to both the local AI (for predictions and learning) and, where required, remote API calls.
– The AI component processes user data locally and offers suggestions along with explanations (as per the interface outlined in the README).
– For self-hosted and enterprise deployments, a more centralized API server ensures data synchronization between devices.

##### Architectural Patterns and Design Principles
- Multi-platform Architecture: Separation of concerns is clear, with dedicated directories for desktop, mobile, and web frontends.
- Modularization: The use of packages (ai, core, ui) shows a clear modular approach allowing reusability and independent evolution of key functionalities.
- Edge AI and Privacy by Design: Emphasize that AI learning happens locally (edge processing) and that there is an optional API backend for synchronization while preserving privacy.
- Clear Separation of Development and Deployment: Local development tools, CI workflows (.github/workflows), and clear documentation (docs/architecture and docs/deployment) reinforce a well-managed build and deployment process.

- Each component should have clear labels with its technology reference (e.g., “Mobile (React Native)”, “Backend API (Node.js/TypeScript)”, “AI Module (TensorFlow.js)”).
- Interfaces and data flow paths, such as the “local learning” and “predictive suggestion” flows defined in the README’s Edge AI Architecture.
- Environmental context:
– For a personal installation, emphasize on-device data processing and minimal API communication.
– For self-hosting and enterprise, illustrate the flow from multiple devices to the central API and backup systems.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User"]

    subgraph "Frontend Applications"
        A1["Desktop App (Tauri)"]
        A2["Mobile App (React Native)"]
        A3["Web App (Next.js)"]
    end

    subgraph "Backend Services"
        B1["API Backend (Node.js/TypeScript)"]
    end

    subgraph "Shared Modules"
        C1["AI Package (Edge AI)"]
        C2["Core Business Logic"]
        C3["UI Package"]
    end

    subgraph "Supporting Elements"
        D1["Documentation"]
        D2["Configuration/Build Tools"]
    end

    %% User to Frontend Applications
    U --> A1
    U --> A2
    U --> A3

    %% Frontend to Backend API
    A1 -->|"API_Sync"| B1
    A2 -->|"API_Sync"| B1
    A3 -->|"API_Sync"| B1

    %% Frontend to Shared Modules: AI for local learning
    A1 -->|"Local_Learning"| C1
    A2 -->|"Local_Learning"| C1
    A3 -->|"Local_Learning"| C1

    %% Frontend to Shared Modules: Core Business Logic
    A1 -->|"Uses_BusinessLogic"| C2
    A2 -->|"Uses_BusinessLogic"| C2
    A3 -->|"Uses_BusinessLogic"| C2

    %% Frontend to Shared Modules: UI Components
    A1 -->|"Uses_UI"| C3
    A2 -->|"Uses_UI"| C3
    A3 -->|"Uses_UI"| C3

    %% Backend API integrates with Shared Modules
    B1 -->|"Processes_with_BusinessLogic"| C2
    B1 -->|"Integrates_UI"| C3

    %% Supporting Elements: Build Tools support all modules
    D2 ---|"Build_Config"| A1
    D2 ---|"Build_Config"| A2
    D2 ---|"Build_Config"| A3
    D2 ---|"Build_Config"| B1
    D2 ---|"Build_Config"| C1
    D2 ---|"Build_Config"| C2
    D2 ---|"Build_Config"| C3

    %% Documentation guides the system
    D1 ---|"Guidelines"| U

    %% Click Events
    click A1 "https://github.com/ethandengs/eremois/blob/main/apps/desktop/package.json"
    click A2 "https://github.com/ethandengs/eremois/tree/main/apps/mobile/"
    click A3 "https://github.com/ethandengs/eremois/tree/main/apps/web/"
    click B1 "https://github.com/ethandengs/eremois/tree/main/apps/api/"
    click C1 "https://github.com/ethandengs/eremois/tree/main/packages/ai/"
    click C2 "https://github.com/ethandengs/eremois/tree/main/packages/core/"
    click C3 "https://github.com/ethandengs/eremois/tree/main/packages/ui/"
    click D1 "https://github.com/ethandengs/eremois/tree/main/docs/"
    click D2 "https://github.com/ethandengs/eremois/tree/main/tools/"

    %% Style Classes
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef package fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef support fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    class A1,A2,A3 frontend;
    class B1 backend;
    class C1,C2,C3 package;
    class D1,D2 support;
```
