# kenya-dk/quantframe-react architecture

> Architecture diagram of the GitHub repository kenya-dk/quantframe-react, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kenya-dk/quantframe-react
- Repository: https://github.com/kenya-dk/quantframe-react

## Overview

##### Main Components
- Frontend Component:
- Located mostly in the “src” folder. It includes React components, pages, contexts, hooks, and API modules.
- Utilizes Mantine for UI, and the design includes many reusable UI elements (forms, modals, layouts, charts, etc.).

- Tauri Backend Component:
- Located in “src-tauri”. It contains Rust code that powers the backend. It is divided into several submodules:
▪ entity – Represents the data model and business entities (stocks, transactions, wish lists, etc.).
▪ migration – Holds database migration scripts (for creating tables like transactions, stock items, etc.).
▪ service – Contains the logic for performing mutations and queries against the database.
▪ Other modules such as auth, cache, http_client, live_scraper, log_parser, notification, and various clients (qf_client, wfm_client) that are responsible for interfacing with external APIs and services.
- The Rust backend also includes configuration files (like tauri.conf.json) and build scripts.

- Database:
- SQLite database where application data, logs, and settings are stored. This is mentioned in the README and the migration files in “src-tauri/migration” imply a structured schema.

- External API Services:
- The system integrates with external services (e.g., wf.market) to send/receive data, as shown in the API client and modules under “src/api” and in the “qf_client” and “wfm_client” folders.

##### Relationships and Interactions Between Components
- The React frontend (in “src”) communicates with the Tauri backend for core functionalities via Tauri’s API interface. This communication is typically bi-directional—UI actions trigger backend commands (like API calls to perform mutations or queries), and the backend returns data or notifications.
- The backend manages data persistence using SQLite, processes data-related operations (e.g., through services and migrations), and interacts with external APIs.
- Frontend API modules (in “src/api”) may be responsible for defining how the UI calls backend functionality.
- There is integration for real-time features such as notifications, live scraper updates, and chat, which connect across both frontend and backend.
- Developer tools and debugging routes are provided as well (e.g. in “src/pages/debug”).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The division of the project into “src” (frontend) and “src-tauri” (backend) clearly demarcates the presentation layer from the business logic and data handling layers.
- Modularity: The backend is split into various services and modules (entities, migrations, services, notification, cache, live scraping, log parsing) that each address specific concerns.
- Client-Server Style Communication: Although this is a desktop app, Tauri provides a message-passing API that emulates traditional client-server communication within a single packaged application.
- Use of a layered architecture in the frontend (components, pages, contexts, hooks) supports reusability and maintainability.

##### Relevant Technologies, Frameworks, or Libraries
- Tauri – for desktop application wrapper with a Rust backend.
- Rust – as the backend language managing heavy-lifting, data persistence, and integrations.
- React – for the frontend user interface.
- Mantine – for UI components and styling.
- SQLite – as the local database solution.
- Other tooling includes PNPM (for package management), TypeScript (judging by .tsx and .ts files), and various CI/CD configurations (GitHub workflows).

##### Elements
- Use clear labels for major components:
- "Frontend (React/Mantine)"
- "Backend (Rust/Tauri)"
- "Data Persistence (SQLite Database)"
- "External APIs (wf.market, etc.)"
- "Modules" within the backend (e.g., "Services", "Entities", "Migrations", "Clients", "Notification", "Cache")
- "UI Modules" in frontend (e.g., "Components", "Pages", "Contexts", "API Interfaces")
- Data flow from the user to the frontend.
- Interaction between frontend and backend through Tauri’s APIs.
- Backend interactions with the local database.
- Backend communication with external services.
- Rectangles for application modules.

##### Detailed Steps for the Principal Software Engineer
- “Entity” – showing models for stock, transaction, wish list, etc.
- “Service” – split further into “query” and “mutation” services for data manipulation.
- Additional modules like “Notification”, “Cache”, “Live Scraper”, “Log Parser”, and various client modules.
- Within the frontend section:
- High-level directories such as “api”, “components”, “contexts”, and “pages”.
- How API modules communicate with Tauri configuration via remote or direct commands.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (React/Mantine)"
        FE1["API Interfaces"]:::frontend
        FE2["Components"]:::frontend
        FE3["Pages"]:::frontend
        FE4["Contexts"]:::frontend
        FE5["Hooks"]:::frontend
    end

    subgraph "Backend (Rust/Tauri)"
        BE1["Tauri Backend"]:::backend
        subgraph "Backend Modules"
            BE2["Entities"]:::backend
            BE3["Migrations"]:::backend
            BE4["Services"]:::backend
            BE5["Authentication"]:::backend
            BE6["Cache"]:::backend
            BE7["HTTP Client"]:::backend
            BE8["Live Scraper"]:::backend
            BE9["Log Parser"]:::backend
            BE10["Notification"]:::backend
            BE11["QF Client"]:::backend
            BE12["WFM Client"]:::backend
        end
    end

    DB["Data Persistence (SQLite)"]:::database
    EXT["External APIs"]:::external

    %% Connections between Frontend and Backend
    FE1 -->|"TauriCommand"| BE1

    %% Backend interactions with Database and External APIs
    BE1 -->|"SQLiteOps"| DB
    BE4 -->|"UsesEntities"| BE2
    BE4 -->|"UsesMigrations"| BE3
    BE11 -->|"APIcall"| EXT
    BE12 -->|"APIcall"| EXT

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;

    %% Click Events for Frontend Modules
    click FE1 "https://github.com/kenya-dk/quantframe-react/tree/main/src/api"
    click FE2 "https://github.com/kenya-dk/quantframe-react/tree/main/src/components"
    click FE3 "https://github.com/kenya-dk/quantframe-react/tree/main/src/pages"
    click FE4 "https://github.com/kenya-dk/quantframe-react/tree/main/src/contexts"
    click FE5 "https://github.com/kenya-dk/quantframe-react/tree/main/src/hooks"

    %% Click Events for Backend Modules
    click BE1 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri"
    click BE2 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/entity"
    click BE3 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/migration"
    click BE4 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/service"
    click BE5 "https://github.com/kenya-dk/quantframe-react/blob/main/src-tauri/src/auth.rs"
    click BE6 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/cache"
    click BE7 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/http_client"
    click BE8 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/live_scraper"
    click BE9 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/log_parser"
    click BE10 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/notification"
    click BE11 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/qf_client"
    click BE12 "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/src/wfm_client"

    %% Click Event for Database
    click DB "https://github.com/kenya-dk/quantframe-react/tree/main/src-tauri/migration"
```
