# codexu/note-gen architecture

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

- Interactive diagram: https://gitdiagram.com/codexu/note-gen
- Repository: https://github.com/codexu/note-gen

## Overview

##### Main System Components

The system architecture should be divided into these major components:

a) Frontend Layer (Next.js Application)
- Core Features Module (/src/app/core)
- UI Components (/src/components)
- State Management (/src/stores)
- Configuration (/src/config)
- Database Interface (/src/db)
- Utility Services (/src/lib)

b) Backend Layer (Tauri)
- Native Features (src-tauri/src)
- Screenshot Module (src-tauri/src/screenshot.rs)
- System Integration

c) External Services
- AI Models Integration
- GitHub Integration (sync & image hosting)
- OCR Services

##### Component Relationships

**[Frontend Layer]**
- ↑↓
**[Tauri Bridge]**
- ↑↓
**[Backend Layer] ←→ [System Resources]**
- ↑
- ↓
**[External Services]**

##### Detailed Component Breakdown

Core Features should be represented as separate modules:
- Record Management
- Article Management
- Image Processing
- Search Functionality
- Settings Management
- Chat/AI Integration

##### Data Flow

Following key data flows:
- User Input → Frontend → Backend → Storage
- Image Capture → OCR → AI Processing → Note Generation
- Content Sync → GitHub Repository
- AI Interactions → Model APIs → UI

##### Key Architectural Patterns to Highlight

- Event-driven architecture (src/config/emitters.ts)
- Store-based state management (src/stores)
- Module-based feature organization
- Service-based external integrations (src/lib)

##### Important Technical Details

Technical aspects:
- Next.js 15 frontend framework
- Tauri 2 native runtime
- Local storage system
- AI model integration points
- GitHub sync mechanism
- Image processing pipeline

This architecture should emphasize the application's three main pillars as mentioned in the README:

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef external fill:#9b59b6,color:white
    classDef storage fill:#e67e22,color:white
    classDef system fill:#95a5a6,color:white

    %% Frontend Layer
    subgraph Frontend
        CoreFeatures["Core Features"]
        UI["UI Components"]
        State["State Management"]
        Config["Configuration"]
        DBInterface["Database Interface"]
        Utils["Utility Services"]

        %% Core Features Breakdown
        subgraph CoreModules
            Record["Record Management"]
            Article["Article Management"]
            Image["Image Processing"]
            Search["Search"]
            Settings["Settings"]
            Chat["Chat/AI Integration"]
        end

        %% State Management Breakdown
        subgraph StateStores
            ArticleStore["Article Store"]
            ChatStore["Chat Store"]
            ImageStore["Image Store"]
            SyncStore["Sync Store"]
            SettingsStore["Settings Store"]
            TagStore["Tag Store"]
        end
    end

    %% Backend Layer
    subgraph Backend
        TauriCore["Native Features"]
        Screenshot["Screenshot Module"]
        SystemInteg["System Integration"]
    end

    %% External Services
    subgraph External
        AI["AI Models"]
        GitHub["GitHub"]
        OCR["OCR Services"]
    end

    %% Relationships
    CoreFeatures --> State
    UI --> State
    State --> DBInterface
    DBInterface --> TauriCore
    Utils --> External
    Config --> TauriCore
    TauriCore --> SystemInteg
    Screenshot --> Image
    Image --> OCR
    Chat --> AI
    DBInterface --> GitHub

    %% Click Events
    click CoreFeatures "https://github.com/codexu/note-gen/tree/dev/src/app/core"
    click UI "https://github.com/codexu/note-gen/tree/dev/src/components"
    click State "https://github.com/codexu/note-gen/tree/dev/src/stores"
    click Config "https://github.com/codexu/note-gen/tree/dev/src/config"
    click DBInterface "https://github.com/codexu/note-gen/tree/dev/src/db"
    click Utils "https://github.com/codexu/note-gen/tree/dev/src/lib"
    click TauriCore "https://github.com/codexu/note-gen/tree/dev/src-tauri/src"
    click Screenshot "https://github.com/codexu/note-gen/blob/dev/src-tauri/src/screenshot.rs"
    click Record "https://github.com/codexu/note-gen/tree/dev/src/app/core/record"
    click Article "https://github.com/codexu/note-gen/tree/dev/src/app/core/article"
    click Image "https://github.com/codexu/note-gen/tree/dev/src/app/core/image"
    click Search "https://github.com/codexu/note-gen/tree/dev/src/app/core/search"
    click Settings "https://github.com/codexu/note-gen/tree/dev/src/app/core/setting"
    click Chat "https://github.com/codexu/note-gen/tree/dev/src/app/core/record/chat"
    click ArticleStore "https://github.com/codexu/note-gen/blob/dev/src/stores/article.ts"
    click ChatStore "https://github.com/codexu/note-gen/blob/dev/src/stores/chat.ts"
    click ImageStore "https://github.com/codexu/note-gen/blob/dev/src/stores/image.ts"
    click SyncStore "https://github.com/codexu/note-gen/blob/dev/src/stores/sync.ts"
    click SettingsStore "https://github.com/codexu/note-gen/blob/dev/src/stores/setting.ts"
    click TagStore "https://github.com/codexu/note-gen/blob/dev/src/stores/tag.ts"

    %% Apply Classes
    class CoreFeatures,UI,State,Config,DBInterface,Utils,CoreModules frontend
    class TauriCore,Screenshot,SystemInteg backend
    class AI,GitHub,OCR external
    class ArticleStore,ChatStore,ImageStore,SyncStore,SettingsStore,TagStore frontend
    class Record,Article,Image,Search,Settings,Chat frontend

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        External_L["External Services"]:::external
    end
```
