# avinandan-mukherjee/nova-ai architecture

> Architecture diagram of the GitHub repository avinandan-mukherjee/nova-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/avinandan-mukherjee/nova-ai
- Repository: https://github.com/avinandan-mukherjee/nova-ai

## Overview

##### Project Type & Purpose
– Nova AI is a desktop “full-stack” assistant combining a PyQt-based GUI (Frontend), a set of Python modules that implement AI/voice/search/automation features (Backend), and local file-based persistence (Data).
– It orchestrates voice I/O, text chat, image generation, web search, system control, and logging by invoking external AI/NLP APIs and OS-level libraries.

##### High-Level Architectural Components
a. Frontend Layer
- GUI.py (PyQt5 UI)
- SystemMonitor.py (live CPU/memory graphs via pyqtgraph)
- Files folder (Database.data, Query.data, etc.) – simple local persistence for user/session state.
b. Core Engine / Backend Layer
- Main.py – application entrypoint, asyncio event loop, initializes GUI & modules
- Backend/*.py modules:
– SpeechToText.py (record/recognize mic input)
– Chatbot.py (orchestrates prompts & text responses)
– ImageGeneration.py (text→image via AI services)
– RealtimeSearchEngine.py (web scraping with requests/selenium)
– TextToSpeech.py (edge-tts for TTS)
– Automation.py (pyautogui, pywin32 for system tasks)
– Model.py (shared interfaces, environment & API-key management)
c. Data Layer
- Data/Chatlog.json (saved conversations)
- Data/Voice.html, Data/cat.txt – example data, demos
- Frontend/Files/*.data – user inputs, statuses, usernames, etc.
d. External Services & Libraries
- AI/NLP: Cohere, Groq, Hugging Face, mtranslate
- Voice I/O: edge-tts, pygame, pywhatkit
- Web: requests, BeautifulSoup4, selenium, webdriver-manager
- System Control: psutil, keyboard, pyautogui, pywin32, AppOpener

##### Data Flows & Interactions
– User ↔ GUI: click buttons, view responses, trigger voice commands
– GUI → SpeechToText → (PCM audio) → text transcripts
– Transcripts → Chatbot (possibly RealtimeSearchEngine) → calls external LLM/NLP APIs → receives response
– Response → TextToSpeech → audio played back
– Response & metadata → written to Data/Chatlog.json and Frontend/Files/Responses.data
– Image requests flow: GUI → ImageGeneration → external image-generation API → saved & rendered in GUI
– Automation tasks: GUI events or Chatbot instructions → Automation module → OS actions

##### Architectural Patterns & Principles
– Modularization: each backend feature lives in its own module for maintainability
– Event-driven & async: asyncio coordinates non-blocking API calls, speech I/O, GUI updates
– Separation of concerns: GUI strictly handles presentation; backend modules handle business logic
– File-based persistence for simple state; no heavy database dependency

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    User(("User")):::actor

    %% Frontend Layer
    subgraph "Frontend Layer"
        GUI["GUI (PyQt5 UI)"]:::frontend
        SysMon["SystemMonitor (pyqtgraph)"]:::frontend
        FilesFolder["Frontend/Files/"]:::data
    end

    %% Core Engine Layer
    subgraph "Core Engine"
        Main["Main.py\n(asyncio event loop)"]:::core
        STT["SpeechToText.py\n(edge-tts)"]:::core
        ChatbotMod["Chatbot.py\n(LLM orchestration)"]:::core
        ImgGen["ImageGeneration.py"]:::core
        RTS["RealtimeSearchEngine.py\n(requests/selenium)"]:::core
        TTS["TextToSpeech.py\n(edge-tts)"]:::core
        Auto["Automation.py\n(pyautogui,pywin32)"]:::core
        Model["Model.py\n(API-key management)"]:::core
    end

    %% External Services
    subgraph "External Services"
        AIAPI(("AI/NLP APIs\n(Cohere, Groq, HuggingFace, mtranslate)")):::external
        VoiceIO(("Voice I/O services\n(edge-tts,pygame,pywhatkit)")):::external
        WebLib(("Web Scraping libs\n(requests,BS4,selenium)")):::external
        SysCtl(("System Control libs\n(psutil,keyboard,pyautogui,pywin32)")):::external
    end

    %% Data Storage Layer
    subgraph "Data Storage"
        Chatlog["Chatlog.json"]:::data
        VoiceHTML["Voice.html"]:::data
        CatTxt["cat.txt"]:::data
        DBData["Database.data"]:::data
        ImageGenData["ImageGeneration.data"]:::data
        MicData["Mic.data"]:::data
        QueryData["Query.data"]:::data
        ResponsesData["Responses.data"]:::data
        StatusData["Status.data"]:::data
        UsernameData["Username.data"]:::data
    end

    %% Relationships - User to GUI
    User -->|"clicks / speaks"| GUI
    GUI -->|"monitor events"| SysMon

    %% Main orchestration
    Main --> GUI
    Main --> STT
    Main --> ChatbotMod
    Main --> ImgGen
    Main --> RTS
    Main --> TTS
    Main --> Auto
    Main --> Model

    %% Voice Input Flow
    GUI -->|"trigger STT"| STT
    STT -->|"text transcript"| ChatbotMod
    STT -->|"writes audio state"| MicData
    ChatbotMod -->|"uses model"| Model
    ChatbotMod -.->|"LLM API call"| AIAPI
    AIAPI -.->|"LLM response"| ChatbotMod
    ChatbotMod -->|"text response"| TTS
    TTS -->|"audio stream"| GUI
    TTS -->|"uses voice libs"| VoiceIO

    %% Search Flow
    ChatbotMod -.->|"needs web data"| RTS
    RTS -.->|"scrape request"| WebLib
    WebLib -.->|"scraped results"| RTS
    RTS -->|"search results"| ChatbotMod

    %% Image Generation Flow
    GUI -->|"image request"| ImgGen
    ImgGen -.->|"image API call"| AIAPI
    AIAPI -.->|"image data"| ImgGen
    ImgGen -->|"renders image"| GUI
    ImgGen -->|"writes state"| ImageGenData

    %% Automation Flow
    GUI -->|"UI automation"| Auto
    ChatbotMod -->|"automation command"| Auto
    Auto -.->|"OS action"| SysCtl

    %% Data Persistence
    ChatbotMod <-->|"logs JSON chat"| Chatlog
    ChatbotMod -->|"writes responses"| ResponsesData
    GUI <-->|"session state"| DBData
    GUI <-->|"query history"| QueryData
    GUI <-->|"status updates"| StatusData
    GUI <-->|"username store"| UsernameData

    %% Example Data
    Chatlog --> VoiceHTML
    Chatlog --> CatTxt

    %% Click events
    click GUI "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/GUI.py"
    click SysMon "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/SystemMonitor.py"
    click FilesFolder "https://github.com/avinandan-mukherjee/nova-ai/tree/main/Frontend/Files/"
    click Main "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Main.py"
    click STT "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/SpeechToText.py"
    click ChatbotMod "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/Chatbot.py"
    click ImgGen "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/ImageGeneration.py"
    click RTS "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/RealtimeSearchEngine.py"
    click TTS "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/TextToSpeech.py"
    click Auto "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/Automation.py"
    click Model "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Backend/Model.py"
    click Chatlog "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Data/Chatlog.json"
    click VoiceHTML "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Data/Voice.html"
    click CatTxt "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Data/cat.txt"
    click DBData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Database.data"
    click ImageGenData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/ImageGeneration.data"
    click MicData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Mic.data"
    click QueryData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Query.data"
    click ResponsesData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Responses.data"
    click StatusData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Status.data"
    click UsernameData "https://github.com/avinandan-mukherjee/nova-ai/blob/main/Frontend/Files/Username.data"

    %% Styles
    classDef actor fill:#e0f7fa,stroke:#000,stroke-width:1px
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef core fill:#c8e6c9,stroke:#1b5e20,stroke-width:1px
    classDef external fill:#f0f4c3,stroke:#827717,stroke-width:1px
    classDef data fill:#fff9c4,stroke:#f57f17,stroke-width:1px
```
