# excoffierleonard/parser architecture

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

- Interactive diagram: https://gitdiagram.com/excoffierleonard/parser
- Repository: https://github.com/excoffierleonard/parser

## Overview

##### Main Components

a) Client Layer:
- Web Frontend (Static files: HTML, CSS, JS)
- External API Clients

b) Web Service Layer:
- HTTP Server (parser-web crate)
- Route Handlers
- /parse endpoint
- /hello endpoint
- static file serving

c) Core Parser Layer (parser-core crate):
- Document Parsers
- PDF Parser
- DOCX Parser
- XLSX Parser
- PPTX Parser
- Text Parser
- Image Parser (OCR)

d) External Dependencies:
- Tesseract OCR Engine
- File Format Libraries

**[Client Layer] → [Web Service Layer] → [Core Parser Layer]**

##### Important Relationships

- HTTP request flow from clients to web service
- File data flow through the system
- Error propagation paths
- Integration with Tesseract OCR
- Configuration influence on components

##### Additional Details

- Environment variable configuration points
- Docker container boundary
- Test coverage areas

##### Implementation Notes

- Version information for major components
- Scalability points

Remember to include:
- Clear entry points for both web UI and API clients
- The relationship between parser-web and parser-core crates
- The role of the Tesseract OCR engine
- Error handling paths
- Configuration points
- Docker container boundary
- Test coverage areas

This will provide a complete picture of how the service processes files while maintaining a clear separation of concerns between the web interface and core parsing functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#2374AB,color:white
    classDef api fill:#2E86AB,color:white
    classDef webservice fill:#37B6AB,color:white
    classDef core fill:#48BF91,color:white
    classDef external fill:#gray,color:black
    classDef error fill:#D64933,color:white
    classDef config fill:#7C90A0,color:black
    
    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        WebUI["Web Frontend"]:::frontend
        APIClient["API Clients"]:::api
    end
    
    %% Web Service Layer
    subgraph WebServiceLayer["Web Service Layer"]
        Server["HTTP Server"]:::webservice
        Config["Configuration"]:::config
        ErrorHandler["Error Handler"]:::error
        ResponseHandler["Response Handler"]:::webservice
        
        subgraph Routes["Route Handlers"]
            ParseRoute["/parse endpoint"]:::webservice
            HelloRoute["/hello endpoint"]:::webservice
            StaticRoute["Static Files Handler"]:::webservice
        end
    end
    
    %% Core Parser Layer
    subgraph CoreLayer["Core Parser Layer"]
        MainParser["Main Parser Module"]:::core
        CoreError["Error Handler"]:::error
        
        subgraph Parsers["Document Parsers"]
            PDFParser["PDF Parser"]:::core
            DOCXParser["DOCX Parser"]:::core
            XLSXParser["XLSX Parser"]:::core
            PPTXParser["PPTX Parser"]:::core
            TextParser["Text Parser"]:::core
            ImageParser["Image Parser"]:::core
        end
    end
    
    %% External Dependencies
    subgraph ExternalDeps["External Dependencies"]
        Tesseract["Tesseract OCR"]:::external
        FormatLibs["File Format Libraries"]:::external
    end
    
    %% Relationships
    WebUI --> Server
    APIClient --> Server
    Server --> Config
    Server --> Routes
    Server --> ErrorHandler
    Server --> ResponseHandler
    
    ParseRoute --> MainParser
    HelloRoute --> ResponseHandler
    StaticRoute --> ResponseHandler
    
    MainParser --> Parsers
    MainParser --> CoreError
    ImageParser --> Tesseract
    Parsers --> FormatLibs
    
    %% Click Events
    click WebUI "https://github.com/excoffierleonard/parser/tree/main/parser-web/static/"
    click Server "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/lib.rs"
    click Config "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/config.rs"
    click ErrorHandler "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/errors.rs"
    click ResponseHandler "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/responses.rs"
    click ParseRoute "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/routes/parse.rs"
    click HelloRoute "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/routes/hello.rs"
    click StaticRoute "https://github.com/excoffierleonard/parser/blob/main/parser-web/src/routes/static_files.rs"
    click MainParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/lib.rs"
    click PDFParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/pdf.rs"
    click DOCXParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/docx.rs"
    click XLSXParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/xlsx.rs"
    click PPTXParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/pptx.rs"
    click TextParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/text.rs"
    click ImageParser "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/parsers/image.rs"
    click CoreError "https://github.com/excoffierleonard/parser/blob/main/parser-core/src/errors.rs"
```
