# berrysauce/ingredients architecture

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

- Interactive diagram: https://gitdiagram.com/berrysauce/ingredients
- Repository: https://github.com/berrysauce/ingredients

## Overview

##### Main Components Identification
The system consists of two primary components:
- Frontend Application (SvelteKit)
- Backend API (FastAPI)

##### Key Architectural Elements
The system should be represented with the following components:

a. Client Layer:
- Web Browser Interface
- API Consumers

b. Frontend Layer:
- SvelteKit Application
- Static Assets (CSS, JS, images)

c. Backend Layer:
- FastAPI Service
- Website Scanner Engine
- Ingredients Database (JSON files)

d. External Integration:
- Target Websites (for scanning)

**[Client Layer]**
- ↓ ↑
**[Frontend Layer (SvelteKit)]**
- ↓ ↑
**[Backend Layer (FastAPI)]**
- ↓ ↑
**[Target Websites]**

##### Detailed Component Breakdown

Frontend (SvelteKit):
- UI routes structure (/src/routes)
- Static assets handling
- API communication layer

Backend (FastAPI):
- API endpoint (/ingredients)
- Scanner engine components:
- HTML Tag Checker
- HTTP Header Analyzer
- Results Processor

Data Store:
- Ingredients JSON files structure:
- Categories (ads, analytics, auth, etc.)
- Individual technology definitions

##### Data Flow Representation

Following flows:
##### Client request flow
- User → Frontend → Backend → Target Website → Backend → Frontend → User

##### Scanning process flow
- Request → Scanner Engine → Tag Checks → Header Checks → Results

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        Browser["Web Browser"]:::client
        APIConsumers["API Consumers"]:::client
    end

    %% Frontend Layer
    subgraph FL["Frontend Layer"]
        SvelteApp["SvelteKit Application"]:::frontend
        Routes["Frontend Routes"]:::frontend
        StaticAssets["Static Assets"]:::frontend
    end

    %% Backend Layer
    subgraph BL["Backend Layer"]
        FastAPI["FastAPI Service"]:::backend
        ScannerEngine["Website Scanner Engine"]:::backend
        subgraph DB["Ingredients Database"]
            Categories["Categories JSON"]:::storage
            TechDefs["Technology Definitions"]:::storage
            Icons["Icons Storage"]:::storage
        end
        subgraph VS["Validation System"]
            CatValidator["Categories Validator"]:::validator
            IconValidator["Icons Validator"]:::validator
            IngValidator["Ingredients Validator"]:::validator
        end
    end

    %% External Layer
    subgraph EL["External Layer"]
        TargetSites["Target Websites"]:::external
    end

    %% Relationships
    Browser --> SvelteApp
    APIConsumers --> FastAPI
    SvelteApp <--> FastAPI
    FastAPI <--> ScannerEngine
    ScannerEngine <--> TargetSites
    ScannerEngine --> Categories
    ScannerEngine --> TechDefs
    ScannerEngine --> Icons
    CatValidator --> Categories
    IconValidator --> Icons
    IngValidator --> TechDefs
    Routes --> SvelteApp
    StaticAssets --> SvelteApp

    %% Click Events
    click SvelteApp "https://github.com/berrysauce/ingredients/tree/main/ui"
    click Routes "https://github.com/berrysauce/ingredients/tree/main/ui/src/routes"
    click StaticAssets "https://github.com/berrysauce/ingredients/tree/main/ui/static/assets"
    click FastAPI "https://github.com/berrysauce/ingredients/blob/main/main.py"
    click Categories "https://github.com/berrysauce/ingredients/blob/main/ingredients/categories.json"
    click Icons "https://github.com/berrysauce/ingredients/tree/main/icons"
    click CatValidator "https://github.com/berrysauce/ingredients/blob/main/.github/scripts/validate_categories.py"
    click IconValidator "https://github.com/berrysauce/ingredients/blob/main/.github/scripts/validate_icons.py"
    click IngValidator "https://github.com/berrysauce/ingredients/blob/main/.github/scripts/validate_ingredients.py"
    click Routes "https://github.com/berrysauce/ingredients/blob/main/ui/src/routes/+page.svelte"

    %% Styles
    classDef client fill:#a8d1f0
    classDef frontend fill:#90EE90
    classDef backend fill:#FFE5B4
    classDef storage fill:#E6E6FA
    classDef external fill:#D3D3D3
    classDef validator fill:#FFA07A

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        Front["Frontend Component"]:::frontend
        Back["Backend Component"]:::backend
        Store["Storage Component"]:::storage
        Ext["External System"]:::external
        Val["Validator"]:::validator
    end
```
