# deeppcodes/labellens architecture

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

- Interactive diagram: https://gitdiagram.com/deeppcodes/labellens
- Repository: https://github.com/deeppcodes/labellens

## Overview

##### Overall Project Type & Purpose
- LabelLens is built as a full-stack application designed to help users look up and understand ingredients in skincare, cosmetics, and medicine.
- It leverages real-time research by using Retrieval Augmented Generation (RAG) with Google Gemini on GCP, while its vector database (Weaviate) stores the ingredient data.
- The system eliminates bias by avoiding brand partnerships and relying on vetted databases.

##### Main Components
a. Frontend:
- Built in React (components, pages, assets, and styles) and styled with Tailwind CSS.
- The entry point is visible via index.html and files in the src/ directory (e.g., App.jsx, components, pages).
b. Backend:
- A Node.js server (server.js) acts as the API layer and routes incoming requests.
- Likely handles communication with both the frontend and external services.
c. External AI & Research Service:
- Google Gemini and associated GCP components (Docker, Kubernetes) handling the real-time AI analysis using RAG.
d. Data Storage – Vector Database:
- Weaviate is used for vector search capabilities. There are backup directories (weaviate_backup) indicating Weaviate’s role in preserving the data related to ingredients (e.g., adverse events, cosmeticingredient, drug).
e. Supporting Infrastructure & Configurations:
- Dockerfile.txt for containerization setups.
- Vite configuration files (vite.config.js, tailwind.config.ts) to manage development/build processes.
- ESLint and other configuration files in the root ensure code quality.

##### Relationships and Data Flow
- A user accesses the frontend (React application) via a browser.
- The frontend communicates with the Node.js backend (via API calls, likely managed in server.js).
- The backend processes requests and can optionally:
- Query the Weaviate vector database for ingredient information using RAG queries.
- Reach out to the external AI service (Google Gemini) hosted on GCP using containerization (Docker/Kubernetes) for enhanced, real-time research.
- The data sources (CSV files under src/assets) could be used for static reference or initial data seeding in the database.
- Backups for Weaviate indicate additional strategies for data persistence and recovery.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Clear separation between frontend and backend responsibilities.
- API Gateway Pattern: The Node.js server acts as a central router for frontend requests and external integrations.
- Microservices or External Service Integration: The use of container orchestration (via Docker/Kubernetes) and external AI services emphasizes decoupled, modular design.
- Data Flow & Dependency Inversion: The backend decouples the UI from heavy processing (AI and vector search) by interfacing with external services.

- Use clear labels for each layer and indicate the deployment context (GCP cloud via Docker/Kubernetes).
- That all major components are captured, even if briefly: from static files in the repository (which support the web UI) to third-party AI and vector database components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    UserBrowser["User Browser/Client"]:::client

    subgraph "Frontend Layer"
        Frontend["React Frontend (Vite/Tailwind)"]:::frontend
        FrontendIndex["index.html"]:::frontend_child
        FrontendSrc["src/"]:::frontend_child
        DataAssets["Data Assets (CSV Files)"]:::frontend_child
    end

    subgraph "Backend Layer"
        Backend["Node.js Backend (server.js)"]:::backend
        ESLint["ESLint Config (eslint.config.js)"]:::config
    end

    subgraph "External Services"
        subgraph "AI Service"
            Gemini["Google Gemini on GCP (Docker/Kubernetes)"]:::external
            DockerConfig["Dockerfile.txt"]:::config
            ViteConfig["vite.config.js"]:::config
            TailwindConfig["tailwind.config.ts"]:::config
        end
        subgraph "Vector Database"
            DB["Weaviate Vector Database"]:::database
            DBZip["weaviate-gke.zip"]:::config
            DBBackup["weaviate_backup/"]:::config
        end
    end

    %% Data Flow
    UserBrowser -->|"access"| Frontend
    Frontend -->|"APIRequest"| Backend
    Backend -->|"RAGQuery"| DB
    Backend -->|"AIRequest"| Gemini
    Frontend -->|"staticData"| DataAssets

    %% Component Contains Details
    Frontend ---|"contains"| FrontendIndex
    Frontend ---|"contains"| FrontendSrc
    Gemini ---|"config"| DockerConfig
    Gemini ---|"config"| ViteConfig
    Gemini ---|"config"| TailwindConfig
    DB ---|"backup"| DBZip
    DB ---|"backup"| DBBackup
    Backend ---|"uses"| ESLint

    %% Click Events
    click FrontendIndex "https://github.com/deeppcodes/labellens/blob/main/index.html"
    click FrontendSrc "https://github.com/deeppcodes/labellens/tree/main/src/"
    click Backend "https://github.com/deeppcodes/labellens/blob/main/server.js"
    click DockerConfig "https://github.com/deeppcodes/labellens/blob/main/Dockerfile.txt"
    click ViteConfig "https://github.com/deeppcodes/labellens/blob/main/vite.config.js"
    click TailwindConfig "https://github.com/deeppcodes/labellens/blob/main/tailwind.config.ts"
    click DBZip "https://github.com/deeppcodes/labellens/blob/main/weaviate-gke.zip"
    click DBBackup "https://github.com/deeppcodes/labellens/tree/main/weaviate_backup/"
    click ESLint "https://github.com/deeppcodes/labellens/blob/main/eslint.config.js"

    %% Styles
    classDef client fill:#ffccbc,stroke:#d84315,stroke-width:2px;
    classDef frontend fill:#fceabb,stroke:#e2a03f,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef external fill:#bbdefb,stroke:#1565c0,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#6a1b9a,stroke-width:2px;
    classDef config fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
    classDef frontend_child fill:#fff9c4,stroke:#fbc02d,stroke-width:1px;
```
