# maciejgornicz/ifirma_docs architecture

> Architecture diagram of the GitHub repository maciejgornicz/ifirma_docs, 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/maciejgornicz/ifirma_docs
- Repository: https://github.com/maciejgornicz/ifirma_docs

## Overview

##### Project Type and Purpose
- This is a microservice application named “ifirma-docs” designed to automate the uploading of scanned documents to an ifirma.pl user account.
- It does not use an official API; instead, it automates tasks by driving a Chrome browser through Selenium.
- It is built with Python (3.11) and containerized with Docker (using docker-compose). There’s also an FTP service provided for incoming scanned documents.

##### Analyzing the File Structure
- Top-level components: There are configuration and environment files (Dockerfile, docker-compose.yaml, Makefile, env folder), source code within “src”, and unit tests under “tests”.
- In “src”, the project is organized into a config directory (with config.yaml) and a modules directory that encapsulates different functionalities (e.g., health check, logger, settings, uploader).
- The main entry point (src/main.py) likely orchestrates the service functions, tying together configuration, monitoring of the FTP folder, and triggering the Selenium-driven upload process.
- The Docker-related files (.github workflows, Dockerfile, docker-compose) indicate that this service is meant to run in a containerized environment with linked external services (FTP, Selenium Chrome service).

##### Key Components
a. ifirma-docs Microservice:
- Ifirma-docs service as a central component, outlining its responsibilities: monitoring a shared directory for new files, invoking the Selenium Chrome service to perform document upload tasks, and performing logging and settings management.

b. FTP Service:
- A “Simple FTP Service” as an external component. It acts as a drop point where scanned files are uploaded and later picked up by the ifirma-docs service.
- Default credentials (user: user, pass: 123) in annotations if needed.

c. Selenium Chrome Browser Service:

d. Configuration & Environment:
- Use of Docker and docker-compose, which tie all components together in an orchestrated containerized solution.
- You could highlight configuration files (like the YAML config in “src/config”) and environment files, which define runtime behavior and staging (test/prod) differences.

##### Relationships and Interactions
- Data flows from the FTP Service (where scanned document files are deposited) to the ifirma-docs service.
- The ifirma-docs service, upon detecting new files, interacts with the Selenium Chrome Service to perform the browser-driven upload.
- Optionally, indicate feedback loops like logging and health checking back to a monitoring or logging infrastructure.

##### Architectural Patterns and Design Elements
- Microservice approach—each external service (FTP, Selenium Chrome) is containerized and managed via docker-compose.
- Separation of concerns within the ifirma-docs service (dividing responsibilities using internal modules).
- Use of automation (e.g., Selenium) in the absence of a formal API, which is an interesting design point.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "ifirma-docs Service"
        direction TB
        MA["Main Application"]:::internal
        UP["Uploader Module"]:::internal
        HT["Health Module"]:::internal
        LG["Logger Module"]:::internal
        ST["Settings Module"]:::internal
    end

    FTP["FTP Service (user: user,pass: 123)"]:::external
    SEL["Selenium Chrome Service"]:::external

    subgraph "Config & Environment"
        CFG["Configuration"]:::environment
        subgraph "Docker & Env Files"
            DF["Dockerfile"]:::environment
            DC["docker-compose.yaml"]:::environment
            EN["env (.env.default)"]:::environment
            MK["Makefile"]:::environment
        end
    end

    FTP -->|"FileUpload"| MA
    MA -->|"BrowserAutomationRequest"| SEL
    CFG -->|"Settings"| MA
    DC -->|"Deployment"| MA

    click MA "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/main.py"
    click UP "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/modules/uploader.py"
    click HT "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/modules/health.py"
    click LG "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/modules/logger.py"
    click ST "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/modules/settings.py"
    click CFG "https://github.com/maciejgornicz/ifirma_docs/blob/main/src/config/config.yaml"
    click DF "https://github.com/maciejgornicz/ifirma_docs/tree/main/Dockerfile"
    click DC "https://github.com/maciejgornicz/ifirma_docs/blob/main/docker-compose.yaml"
    click EN "https://github.com/maciejgornicz/ifirma_docs/blob/main/env/.env.default"
    click MK "https://github.com/maciejgornicz/ifirma_docs/tree/main/Makefile"

    classDef internal fill:#BDE0FE,stroke:#000,stroke-width:1px;
    classDef external fill:#FFDFBA,stroke:#000,stroke-width:1px;
    classDef environment fill:#CFFFE5,stroke:#000,stroke-width:1px;
```
