# erickestillosoph/ocr-poc architecture

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

- Interactive diagram: https://gitdiagram.com/erickestillosoph/ocr-poc
- Repository: https://github.com/erickestillosoph/ocr-poc

## Overview

##### Main Components
- Server: This is the backend component with its routes and services. It features a modular structure including factories, services, utilities, and types. Notable services include those interfacing with AI (aiService in factories) and image/LLM processes (services like anthropic, llm, and rekognition, as well as image utils).

##### Relationships and Interactions
- The server comprises separate execution layers – it uses factories and services to process requests. For example, when an OCR or AI function is needed, the server service might call out to require factors from the aiService or external APIs such as Anthropic or Rekognition.
- If relevant, illustrate any data flow for image handling from the server’s utilities to processing modules.

##### Architectural Patterns and Design
- The architecture shows separation of concerns between UI (client) and business logic (server).
- Within the server, there appears to be a layered approach – the top-level “index.ts” bootstraps the application, while factories and services encapsulate business functionality.

##### Technologies and Tools
- Client: Typescript, React (with .tsx components), Vite configuration for development.
- Server: Node.js environment (likely using ES modules given the .mjs loader), TypeScript, and RESTful service implementations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        direction TB
        ClientApp("Client App (React/Vite)"):::frontend
        ClientMain("Main Entry (main.tsx & App.tsx)"):::frontend_main
        UIComponents("UI Components (Components & Utilities)"):::frontend_sub
        ClientApp -->|"Renders"| ClientMain
        ClientMain -->|"Uses"| UIComponents
    end

    subgraph "Server"
        direction TB
        ServerCore("API Gateway / Server Core (index.ts)"):::backend
        ServerFactory("Factories - AI Service (aiService)"):::backend_factory
        subgraph "Services"
            direction TB
            Anthropics("Anthropic Service"):::backend_service
            LLMService("LLM Service"):::backend_service
            Rekognition("Rekognition Service"):::backend_service
        end
        ServerUtils("Image Processing Utilities"):::backend_util
        ServerTypes("Type Definitions"):::backend_types
        ServerCore -->|"Initialize"| ServerFactory
        ServerFactory -->|"CallsAI"| Anthropics
        ServerFactory -->|"CallsLLM"| LLMService
        ServerFactory -->|"UsesUtil"| ServerUtils
        ServerCore -->|"DirectCall"| Rekognition
        ServerCore -->|"UsesTypes"| ServerTypes
        Anthropics -->|"Returns"| ServerFactory
        LLMService -->|"Returns"| ServerFactory
        Rekognition -->|"Returns"| ServerCore
    end

    ClientApp -->|"HTTPRequest"| ServerCore

    click ClientApp "https://github.com/erickestillosoph/ocr-poc/tree/master/client/"
    click ClientMain "https://github.com/erickestillosoph/ocr-poc/blob/master/client/src/main.tsx"
    click ClientMain "https://github.com/erickestillosoph/ocr-poc/blob/master/client/src/App.tsx"
    click UIComponents "https://github.com/erickestillosoph/ocr-poc/tree/master/client/src/components/ui/"
    click ServerCore "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/index.ts"
    click ServerFactory "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/factories/aiService.ts"
    click Anthropics "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/services/anthropic.ts"
    click LLMService "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/services/llm.ts"
    click Rekognition "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/services/rekognition.ts"
    click ServerUtils "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/utils/image.ts"
    click ServerTypes "https://github.com/erickestillosoph/ocr-poc/blob/master/server/src/types.ts"

    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef frontend_main fill:#90caf9,stroke:#0d47a1,stroke-width:2px;
    classDef frontend_sub fill:#e3f2fd,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef backend_factory fill:#a5d6a7,stroke:#1b5e20,stroke-width:2px;
    classDef backend_service fill:#81c784,stroke:#1b5e20,stroke-width:2px;
    classDef backend_util fill:#66bb6a,stroke:#1b5e20,stroke-width:2px;
    classDef backend_types fill:#43a047,stroke:#1b5e20,stroke-width:2px;
```
