# arinzingade/tlc-with-image-processing architecture

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

- Interactive diagram: https://gitdiagram.com/arinzingade/tlc-with-image-processing
- Repository: https://github.com/arinzingade/tlc-with-image-processing

## Overview

##### Project Overview
- This repository is aimed at automating the analysis of Thin Layer Chromatography (TLC) plates by calculating RF (Retention Factor) values. The tool drastically speeds up TLC analysis (from minutes to milliseconds) and likely uses image processing to derive these values.
- It is essentially a web-enabled utility for chemists, combining a simple web interface (using templates like index.html) with backend image-processing and RF calculation modules.

##### Identifying the Main Components
- Web Frontend:
- Located in the “templates” folder (index.html) and “uploads” folder (for user provided images).
- Responsible for providing an interface for users to upload TLC plate images and display results.
- Web Backend/Server:
- The main execution starting points are files like “app.py” and optionally “main.py.”
- This layer handles HTTP requests, routes connections between the user’s interactions and the processing modules.
- Image Processing Module:
- The “Detection” folder contains DocScan.py and utils (likely image processing helper functions). This module processes the TLC plate images to extract necessary data.
- RF Calculation Module:
- “RFCalc.py”, and even a C++ version in “references/RFCalc.cpp”, implies a dedicated component to calculate the RF values from processed image data.
- Reference/Support Files:
- “references” directory (including Jupyter notebooks) shows examples or baseline implementations. These can be seen as documentation or experimental work that informed the design.
- Configuration and Dependency Management:
- “requirements.txt” and conda environment instructions indicate dependency management and setup guidelines.

##### Interactions Between Components
- The user interacts with the frontend (via a web browser) and uploads an image.
- The backend (app.py) receives this image and possibly stores it in the “uploads” directory.
- The backend then calls the image processing modules (Detection/DocScan.py and related functions) to analyze the image and extract regions or features.
- The processed data is passed to the RF calculation logic in RFCalc.py, which computes the RF values.
- The final results are saved (possibly in “outputs”) and returned/displayed via the frontend.
- The design also suggests potential support for debugging or verification using reference files.

##### Architectural Patterns and Design Principles
- The structure suggests a monolithic web application design, separating concerns into frontend, processing, and computation modules.
- The clear separation of concerns (web server, image processing, RF calculations) is key.
- Using MVC-like separation or layered architecture, where:
- The view is represented by the templates,
- The controller is in the Flask routes (app.py),
- And the model comprises the processing/calculation modules.
- Dependency and environment isolation are managed via conda and pip.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    USER["User / Client"]:::user

    %% Web Frontend Subgraph
    subgraph "Web Frontend"
        FE_HTML["Index Template"]:::frontend
        FE_UPLOADS["Uploads Directory"]:::frontend
    end

    %% Web Backend / Server Subgraph
    subgraph "Web Backend/Server"
        BE_APP["app.py"]:::backend
        BE_MAIN["main.py"]:::backend
    end

    %% Image Processing Module Subgraph
    subgraph "Image Processing Module"
        IP_DOCSCAN["DocScan.py"]:::processing
        IP_UTLIS["utlis.py"]:::processing
    end

    %% RF Calculation Module Subgraph
    subgraph "RF Calculation Module"
        RF_RFPY["RFCalc.py"]:::processing
        RF_RFCPP["RFCalc (C++)"]:::processing
    end

    %% Data Storage Subgraph
    subgraph "Data Storage"
        DS_OUTPUTS["outputs Directory"]:::storage
        DS_IMAGES["images Directory"]:::storage
    end

    %% Reference and Documentation Subgraph
    subgraph "Reference & Documentation"
        RD_REF["References"]:::reference
    end

    %% Connections
    USER -->|"ImageUpload"| FE_HTML
    FE_HTML -->|"Submit"| BE_APP
    BE_APP -->|"ProcessImage"| IP_DOCSCAN
    IP_DOCSCAN -->|"UtilizeUtils"| IP_UTLIS
    IP_UTLIS -->|"ExtractFeatures"| RF_RFPY
    RF_RFPY -->|"AlternativeCalc"| RF_RFCPP
    RF_RFCPP -->|"ReturnResults"| BE_APP
    BE_APP -->|"StoreOutput"| DS_OUTPUTS
    BE_APP -->|"SaveImage"| DS_IMAGES
    BE_APP -->|"DisplayResults"| FE_HTML
    BE_APP -.->|"AlternateEntry"| BE_MAIN
    BE_APP -.->|"Reference"| RD_REF

    %% Click Events
    click FE_HTML "https://github.com/arinzingade/tlc-with-image-processing/blob/main/templates/index.html"
    click FE_UPLOADS "https://github.com/arinzingade/tlc-with-image-processing/tree/main/uploads"
    click BE_APP "https://github.com/arinzingade/tlc-with-image-processing/blob/main/app.py"
    click BE_MAIN "https://github.com/arinzingade/tlc-with-image-processing/blob/main/main.py"
    click IP_DOCSCAN "https://github.com/arinzingade/tlc-with-image-processing/blob/main/Detection/DocScan.py"
    click IP_UTLIS "https://github.com/arinzingade/tlc-with-image-processing/blob/main/Detection/utlis.py"
    click RF_RFPY "https://github.com/arinzingade/tlc-with-image-processing/blob/main/RFCalc.py"
    click RF_RFCPP "https://github.com/arinzingade/tlc-with-image-processing/blob/main/references/RFCalc.cpp"
    click DS_OUTPUTS "https://github.com/arinzingade/tlc-with-image-processing/tree/main/outputs"
    click DS_IMAGES "https://github.com/arinzingade/tlc-with-image-processing/tree/main/images"
    click RD_REF "https://github.com/arinzingade/tlc-with-image-processing/tree/main/references"

    %% Styles
    classDef user fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef processing fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef reference fill:#FFA07A,stroke:#333,stroke-width:2px;
```
