# cjsladek2/scanadillo architecture

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

- Interactive diagram: https://gitdiagram.com/cjsladek2/scanadillo
- Repository: https://github.com/cjsladek2/scanadillo

## Overview

##### Project type and purpose
- From the README and file‐tree, we can see this is a full‐stack “Scanadillo” application combining:
- A Next.js front-end (in DilloScan/)
- A Node.js OCR microservice (in image-ocr-app/)
- A Python NLP/ingredients microservice (ingredx/ + server.py)
- Static/public assets (DilloScan/public/)
- The overall user flow is: user uploads/scans an image → OCR extracts text → NLP engine summarizes/translates ingredients or drives a chatbot.

##### File structure
- Top level:
- DilloScan/ – Next.js app
- image-ocr-app/ – Node.js server (Express) for handling uploads & Tesseract OCR
- ingredx/ + server.py – Python package and entrypoint for summarization/translation via OpenAI
- DilloScan/app/components – React UI components (ImageGallery, chatbot, ingredients, NavBar)
- DilloScan/public – static assets and Tesseract WASM if used client-side
- image-ocr-app/server.js – Express endpoints (/upload, /ocr)
- ingredx/api_server.py or server.py – Python HTTP endpoints for summarizer & translator
- Configuration files: next.config.mjs, package.json, requirements.txt

##### README for additional insights
- We infer the rest of the system from adjacent folders.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Browser["Browser"]:::external
        NextJS["Next.js Frontend"]:::frontend
    end

    %% Frontend Components
    subgraph "Next.js App Components"
        direction TB
        UIComponents["React UI Components"]:::frontend
        LayoutPages["Layout & Pages"]:::frontend
        StaticAssets["Static/Public Assets & Tesseract WASM"]:::frontend
        ConfigFiles["Next.js Configuration"]:::frontend
    end

    %% API Layer
    subgraph "OCR Service (Node.js)"
        direction TB
        OCRService["OCR Service"]:::nodejs
        OCRServer["OCR Express Server (server.js)"]:::nodejs
        OCRStorage["OCR Uploads & Models"]:::nodejs
        OCRConfig["OCR Service Configuration"]:::nodejs
    end

    %% Processing Layer
    subgraph "NLP Service (Python)"
        direction TB
        NLPService["NLP Service"]:::python
        NLPServer["NLP HTTP Server Entrypoint"]:::python
        CoreLogic["Core Logic & Models"]:::python
        Adapters["OpenAI Adapters"]:::python
        CLIEngine["CLI & Engine"]:::python
        Requirements["Python Dependencies"]:::python
        Tests["OpenAI & NLP Tests"]:::python
    end

    %% Storage and External
    Storage[(File Storage)]:::storage
    Tesseract["Tesseract Engine"]:::external
    OpenAI["OpenAI API"]:::external

    %% Connections
    Browser -->|"HTTP Request"| NextJS
    NextJS -->|"POST /upload"| OCRService
    OCRService -->|"save/read"| Storage
    OCRService -->|"invoke /ocr"| Tesseract
    OCRService -->|"POST text payload"| NLPService
    NLPService -->|"summarize/translate"| OpenAI
    OCRService -->|"OCR results"| NextJS
    NLPService -->|"final results"| NextJS

    %% Hierarchy Links
    NextJS --> UIComponents
    NextJS --> LayoutPages
    NextJS --> StaticAssets
    NextJS --> ConfigFiles

    OCRService --> OCRServer
    OCRService --> OCRStorage
    OCRService --> OCRConfig

    NLPService --> NLPServer
    NLPService --> CoreLogic
    NLPService --> Adapters
    NLPService --> CLIEngine
    NLPService --> Requirements
    NLPService --> Tests

    %% Click Events
    click NextJS "https://github.com/cjsladek2/scanadillo/tree/main/DilloScan/"
    click UIComponents "https://github.com/cjsladek2/scanadillo/tree/main/DilloScan/app/components/"
    click LayoutPages "https://github.com/cjsladek2/scanadillo/blob/main/DilloScan/app/layout.js"
    click LayoutPages "https://github.com/cjsladek2/scanadillo/blob/main/DilloScan/app/page.js"
    click StaticAssets "https://github.com/cjsladek2/scanadillo/tree/main/DilloScan/public/"
    click ConfigFiles "https://github.com/cjsladek2/scanadillo/blob/main/DilloScan/next.config.mjs"
    click ConfigFiles "https://github.com/cjsladek2/scanadillo/blob/main/DilloScan/jsconfig.json"
    click ConfigFiles "https://github.com/cjsladek2/scanadillo/blob/main/DilloScan/package.json"
    click OCRService "https://github.com/cjsladek2/scanadillo/tree/main/image-ocr-app/"
    click OCRServer "https://github.com/cjsladek2/scanadillo/blob/main/image-ocr-app/server.js"
    click OCRStorage "https://github.com/cjsladek2/scanadillo/tree/main/image-ocr-app/uploads/"
    click OCRConfig "https://github.com/cjsladek2/scanadillo/blob/main/image-ocr-app/package.json"
    click NLPService "https://github.com/cjsladek2/scanadillo/tree/main/ingredx/"
    click NLPServer "https://github.com/cjsladek2/scanadillo/blob/main/server.py"
    click CoreLogic "https://github.com/cjsladek2/scanadillo/tree/main/ingredx/core/"
    click Adapters "https://github.com/cjsladek2/scanadillo/tree/main/ingredx/adapters/"
    click CLIEngine "https://github.com/cjsladek2/scanadillo/blob/main/ingredx/cli.py"
    click CLIEngine "https://github.com/cjsladek2/scanadillo/blob/main/ingredx/engine.py"
    click Requirements "https://github.com/cjsladek2/scanadillo/blob/main/requirements.txt"
    click Tests "https://github.com/cjsladek2/scanadillo/blob/main/ingredx/tests.py"
    click Storage "https://github.com/cjsladek2/scanadillo/tree/main/image-ocr-app/uploads/"
    click Tesseract "https://github.com/cjsladek2/scanadillo/tree/main/DilloScan/public/tesseract/"
    click Tesseract "https://github.com/cjsladek2/scanadillo/blob/main/image-ocr-app/eng.traineddata"

    %% Styles
    classDef frontend fill:#a2f2a2,stroke:#333,stroke-width:1px
    classDef nodejs fill:#a2d0f2,stroke:#333,stroke-width:1px
    classDef python fill:#f2c290,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
    classDef storage fill:#dddddd,stroke:#333,stroke-width:1px,shape:cylinder
```
