# himasnhu-at/noterai architecture

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

- Interactive diagram: https://gitdiagram.com/himasnhu-at/noterai
- Repository: https://github.com/himasnhu-at/noterai

## Overview

##### Main Components Identification

a) Client Applications:
- Web Application (Next.js)
- Mobile/Desktop App (Flutter)
- Native iOS/macOS App (Swift)

b) Backend Services:
- Main Backend Service (NestJS)
- AI Service
- Collaboration Tools Service
- Content Management Service
- Sharing & Publishing Integration Service

c) Data Storage:
- Primary Database (PostgreSQL with Prisma)
- Redis (for caching and real-time features)

**┌─────────────┐    ┌─────────────┐    ┌─────────────┐**
- Web App    │    │Flutter Apps │    │ Swift Apps  │
- (Next.js)  │    │(Cross-plat) │    │(iOS/macOS)  │
- ┘    └─────────────┘    └─────────────┘

**┌─────────────────────────────────────────────────┐**
- API Gateway / Load Balancer        │
- ┘

**┌─────────────┐ ┌─────────────┐ ┌─────────────┐**
- AI Service │ │   Backend   │ │   Content   │
- Service   │ │    Mgmt     │
- ┘ └─────────────┘ └─────────────┘

**┌─────────────┐ ┌─────────────────────────┐**
- Collab    │ │ Sharing & Publishing    │
- Tools     │ │      Integration        │
- ┘ └─────────────────────────┘

**┌─────────────┐    ┌─────────────┐**
- PostgreSQL │    │    Redis    │
- (Prisma)   │    │             │
- ┘    └─────────────┘

##### Key Features to Highlight

- Authentication Flow (JWT-based)
- Real-time Collaboration (WebSocket connections)
- AI Processing Pipeline
- Content Storage and Retrieval
- Cross-platform Sync

##### Connection Types

- Event-driven communication (wavy lines)

##### Additional Elements

Include:
- Version information
- Key technologies used in each component
- Security boundaries
- Scaling components

##### Specific Implementation Details

- The microservices architecture using NestJS
- The separation of AI services
- Real-time collaboration features
- Cross-platform client applications
- Database schema overview
- Caching strategy with Redis

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef ai fill:#f1c40f,stroke:#f39c12,color:black
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#34495e,stroke:#2c3e50,color:white

    %% Client Layer
    subgraph Clients
        WebApp["Web App\n(Next.js)"]:::client
        FlutterApp["Flutter Apps\n(Cross-platform)"]:::client
        SwiftApp["Swift Apps\n(iOS/macOS)"]:::client
    end

    %% API Gateway Layer
    Gateway["API Gateway/\nLoad Balancer"]:::infra

    %% Services Layer
    subgraph Services
        MainBackend["Main Backend\nService (NestJS)"]:::service
        AIService["AI Service"]:::ai
        CollabTools["Collaboration\nTools Service"]:::service
        ContentMgmt["Content Management\nService"]:::service
        SharingPub["Sharing & Publishing\nIntegration"]:::service
        AuthService["Authentication\nService"]:::security
        RTEditor["Real-time\nEditor"]:::service
    end

    %% Data Layer
    subgraph Data
        PostgreSQL[(PostgreSQL\nPrisma)]:::database
        Redis[(Redis\nCache)]:::database
    end

    %% Connections
    WebApp & FlutterApp & SwiftApp --> Gateway
    Gateway --> MainBackend
    Gateway --> AuthService
    MainBackend --> AIService
    MainBackend --> CollabTools
    MainBackend --> ContentMgmt
    MainBackend --> SharingPub
    CollabTools --> RTEditor
    MainBackend --> PostgreSQL
    MainBackend --> Redis
    RTEditor --> Redis
    
    %% Click Events
    click WebApp "https://github.com/Himasnhu-AT/noterai/tree/main/apps/web/"
    click FlutterApp "https://github.com/Himasnhu-AT/noterai/tree/main/apps/flutter/"
    click SwiftApp "https://github.com/Himasnhu-AT/noterai/tree/main/apps/swift/"
    click MainBackend "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/backend/"
    click AIService "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/ai-service/"
    click CollabTools "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/collab_tools/"
    click ContentMgmt "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/content_mgmt/"
    click SharingPub "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/sharing_publishing_integration/"
    click PostgreSQL "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/prisma/"
    click AuthService "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/backend/src/api/auth/"
    click RTEditor "https://github.com/Himasnhu-AT/noterai/tree/main/apps/backend/apps/content_mgmt/src/editor/"

    %% Legend
    subgraph Legend
        Client[Client Applications]:::client
        ServiceEx[Services]:::service
        AIEx[AI Components]:::ai
        InfraEx[Infrastructure]:::infra
        SecurityEx[Security Components]:::security
        DBEx[Databases]:::database
    end
```
