# fynnfluegge/rocketnotes architecture

> Architecture diagram of the GitHub repository fynnfluegge/rocketnotes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fynnfluegge/rocketnotes
- Repository: https://github.com/fynnfluegge/rocketnotes

## Overview

##### Main System Components

a. Frontend Layer:
- Angular Web Application (webapp directory)
- Electron Desktop Application
- Landing Page (Angular-based)

b. Backend Layer (Serverless):
- Lambda Functions (lambda-handler directory)
- Authentication (AWS Cognito)
- Storage Layer (DynamoDB)
- Vector Store (FAISS)

c. AI/ML Services:
- LLM Providers (OpenAI, Anthropic, Voyage)
- Local AI Options (Ollama)
- Vector Embedding Services

##### Component Relationships

a. Client-Side Flow:
**Web Browser/Electron App -> API Gateway -> Lambda Functions**

b. Authentication Flow:
**Client -> AWS Cognito -> Protected Resources**

c. Document Processing Flow:
**Editor Component -> Save Document Handler -> DynamoDB**
- > Vector Embedding Handler -> FAISS Index

d. Search/RAG Pipeline:
**Search Request -> Semantic Search Handler -> FAISS Index**
- > LLM Service -> Response

##### Specific Implementation Details

a. Frontend Components:
- Editor component
- Navigation/Sidenav
- Zettelkasten interface
- Dialog components (Config, LLM)
- Public document viewer

b. Lambda Functions (group by functionality):
- Document management handlers
- Zettel handlers
- AI/ML handlers (chat, semantic search, vector embeddings)
- User configuration handlers

c. Storage Systems:
- Document store (DynamoDB)
- Vector store (FAISS)
- User configurations

##### Infrastructure Layer

AWS infrastructure components:
- API Gateway
- Lambda
- DynamoDB
- Cognito
- CDK deployment

##### Notes for Implementation

- Use clear hierarchical layout
- Related components
- Primary and secondary data flows
- Version/environment indicators
- Component scaling indicators

Remember to include both the cloud-hosted and local Docker-based deployment scenarios, as they represent different architectural patterns within the same system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WA[Web Application]:::frontend
        EA[Electron App]:::frontend
        LP[Landing Page]:::frontend
        
        subgraph Components
            ED[Editor]:::frontend
            NAV[Navigation]:::frontend
            ZI[Zettelkasten Interface]:::frontend
            CD[Config Dialog]:::frontend
            LD[LLM Dialog]:::frontend
            PDV[Public Document Viewer]:::frontend
            AUTH[Authentication]:::frontend
        end
    end

    subgraph "AWS Infrastructure"
        APIG[API Gateway]:::aws
        COG[Cognito]:::auth
        
        subgraph "Lambda Functions"
            direction TB
            subgraph "Document Handlers"
                SDH[Save Document]:::lambda
                GDH[Get Document]:::lambda
                DDH[Delete Document]:::lambda
                DTH[Document Tree]:::lambda
            end
            
            subgraph "Zettel Handlers"
                SZH[Save Zettel]:::lambda
                DZH[Delete Zettel]:::lambda
                AZH[Archive Zettel]:::lambda
                GZH[Get Zettelkasten]:::lambda
            end
            
            subgraph "AI/ML Handlers"
                CH[Chat Handler]:::lambda
                TCH[Text Completion]:::lambda
                SSH[Semantic Search]:::lambda
                VEH[Vector Embeddings]:::lambda
            end
            
            subgraph "Config Handlers"
                GCH[Get Config]:::lambda
                SCH[Save Config]:::lambda
            end
        end
    end

    subgraph "Storage Layer"
        DDB[(DynamoDB)]:::storage
        FAISS[(FAISS Vector Store)]:::storage
    end

    subgraph "AI Services"
        OPENAI[OpenAI]:::ai
        ANTHROPIC[Anthropic]:::ai
        VOYAGE[Voyage]:::ai
        OLLAMA[Ollama Local]:::ai
    end

    %% Frontend Connections
    WA & EA & LP --> APIG
    APIG --> COG
    
    %% Lambda Connections
    APIG --> SDH & GDH & DDH & DTH & SZH & DZH & AZH & GZH & CH & TCH & SSH & VEH & GCH & SCH
    
    %% Storage Connections
    SDH & GDH & DDH & DTH --> DDB
    VEH & SSH --> FAISS
    
    %% AI Service Connections
    CH & TCH --> OPENAI & ANTHROPIC & VOYAGE & OLLAMA

    %% Click Events
    click WA "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp"
    click LP "https://github.com/fynnfluegge/rocketnotes/tree/main/landing-page"
    click ED "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/editor"
    click NAV "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/navigation"
    click ZI "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/zettelkasten"
    click CD "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/dialog-config"
    click LD "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/dialog-llm"
    click PDV "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/public-document-viewer"
    click AUTH "https://github.com/fynnfluegge/rocketnotes/tree/main/webapp/src/app/component/auth"
    click SDH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/save-document-handler"
    click GDH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/get-document-handler"
    click DDH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/delete-document-handler"
    click DTH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/get-document-tree-handler"
    click SZH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/save-zettel-handler"
    click DZH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/delete-zettel-handler"
    click AZH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/archive-zettel-handler"
    click GZH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/get-zettelkasten-handler"
    click CH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/chat-handler"
    click TCH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/text-completion-handler"
    click SSH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/semantic-search-handler"
    click VEH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/save-vector-embeddings-handler"
    click GCH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/get-user-config-handler"
    click SCH "https://github.com/fynnfluegge/rocketnotes/tree/main/lambda-handler/save-user-config-handler"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef lambda fill:#4CAF50,stroke:#388E3C,color:white
    classDef ai fill:#FFC107,stroke:#FFA000,color:black
    classDef storage fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef auth fill:#FF9800,stroke:#F57C00,color:white
    classDef aws fill:#232F3E,stroke:#1A242F,color:white
```
