# inakilozano01/firmador architecture

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

- Interactive diagram: https://gitdiagram.com/inakilozano01/firmador
- Repository: https://github.com/inakilozano01/firmador

## Overview

- A Python-based service (using Flask) that handles document signing, validation, and other business logic.
- A Java-based service (using Spring Boot and DSS libraries) that provides advanced Digital Signature Services.

##### Main Components
- Python Service:
- Built with Flask.
- Located in the “firmar_python” directory.
- Contains controllers, routes, services, and utility modules.
- Handles certificate management, PDF/JSON signing, document validations, and integration with external systems.
- Java Service:
- Located under the “dssapp” directory.
- Based on Spring Boot and DSS libraries.
- Acts as a robust backend for advanced Digital Signature Services.
- Provides REST/Soap endpoints for processes such as certificate validation, document signature, timestamping, etc.
- Database:
- PostgreSQL is indicated in the README.
- Likely used for storing logs, user data, and record keeping.
- Docker Environment:
- Uses Docker Compose (docker-compose.yml and docker-compose.test.yml) for orchestration.
- Both services have their Dockerfiles, indicating containerized deployment.
- File Storage / Volumes:
- The README and file tree refer to mounted volumes (e.g., /qnap/documentos_firmados, /var/documentos) that manage document storage and serve as shared file repositories for signed files.
- External Dependencies:
- External certificate authorities, cryptographic tokens, and possibly third-party APIs for OCSP/CRL validations.

##### Relationships and Interactions
- The Python service likely is the entry point or coordinator of signing operations, handling incoming requests (both file uploads and JSON data for signing).
- It communicates with the Java service to perform more complex digital signing operations using DSS libraries.
- Both services log operations separately (the Python service using mod-wsgi error logs and the Java service via Tomcat logs) and may store operation details in the PostgreSQL database.
- Docker Compose orchestrates the overall service deployment – include a container grouping or a “Docker Host” label to denote the containerized environment.

##### Architectural Patterns and Design Principles
- Service-Oriented / Microservice: Two decoupled services (Python and Java) that expose REST or SOAP endpoints.
- Containerized Deployment: Using Docker Compose to deploy and manage dependencies.
- Modular Design: With clearly separated controllers, services, and utility modules in both the Python and Java projects.
- Security: Emphasis on certificate management, secure key handling, and cryptographic validations.
- Separation of Concerns: The Python service handles the orchestration/logic while the Java service provides the DSS capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Client Layer
    Client["Client/API Requests"]:::client

    %% Docker Compose Orchestration
    subgraph "Docker Compose Orchestration"
        direction TB
        DC["Docker Compose Environment"]:::docker

        %% Python Service Subgraph
        subgraph "Python Service (Flask)"
            direction TB
            py["Python Service"]:::service
            py1["Controllers"]:::component
            py2["Routes"]:::component
            py3["Services"]:::component
            py4["Utilities"]:::component
        end

        %% Java Service Subgraph
        subgraph "Java Service (Spring Boot & DSS)"
            direction TB
            java["Java Service"]:::service
            java_main["Main Application & Controllers"]:::component
            java_config["Configuration"]:::component
            java_ctrl["REST/Soap Endpoints"]:::component
        end

        %% Deployment Files Subgraph
        subgraph "Deployment Files"
            direction TB
            dc1["docker-compose.yml"]:::config
            dc2["docker-compose.test.yml"]:::config
            pyDocker["Python Dockerfile"]:::config
            javaDocker["Java Dockerfile"]:::config
        end
    end

    %% External Data Stores
    DB["PostgreSQL Database"]:::database
    FS["File Storage Volumes"]:::storage

    %% Connections
    Client -->|"sends request"| py
    py -->|"API call"| java
    py -->|"logs & data"| DB
    java -->|"logs & data"| DB
    py -->|"file storage"| FS
    java -->|"file storage"| FS

    %% Internal Service Links
    py --> py1
    py --> py2
    py --> py3
    py --> py4

    java --> java_main
    java --> java_config
    java --> java_ctrl

    %% Click Events for Python Service Components
    click py "https://github.com/inakilozano01/firmador/tree/master/firmar_python"
    click py1 "https://github.com/inakilozano01/firmador/tree/master/firmar_python/app/controllers"
    click py2 "https://github.com/inakilozano01/firmador/blob/master/firmar_python/app/routes/routes.py"
    click py3 "https://github.com/inakilozano01/firmador/tree/master/firmar_python/app/services"
    click py4 "https://github.com/inakilozano01/firmador/tree/master/firmar_python/app/utils"

    %% Click Events for Java Service Components
    click java_main "https://github.com/inakilozano01/firmador/tree/master/dssapp/dss-demo-webapp/src/main/java/eu/europa/esig/dss/web"
    click java_config "https://github.com/inakilozano01/firmador/tree/master/dssapp/dss-demo-webapp/src/main/java/eu/europa/esig/dss/web/config"
    click java_ctrl "https://github.com/inakilozano01/firmador/tree/master/dssapp/dss-demo-webapp/src/main/java/eu/europa/esig/dss/web/controller"

    %% Click Events for Docker Environment Components
    click dc1 "https://github.com/inakilozano01/firmador/blob/master/docker-compose.yml"
    click dc2 "https://github.com/inakilozano01/firmador/blob/master/docker-compose.test.yml"
    click pyDocker "https://github.com/inakilozano01/firmador/tree/master/firmar_python/app/Dockerfile"
    click javaDocker "https://github.com/inakilozano01/firmador/tree/master/dssapp/Dockerfile"

    %% Styles
    classDef client fill:#FFE599,stroke:#BF9000,stroke-width:2px;
    classDef service fill:#C9DAF8,stroke:#003399,stroke-width:2px;
    classDef component fill:#D9EAD3,stroke:#6AA84F,stroke-width:2px;
    classDef docker fill:#EAD1DC,stroke:#B854A7,stroke-width:2px;
    classDef config fill:#F4CCCC,stroke:#B45F06,stroke-width:2px;
    classDef database fill:#FCE5CD,stroke:#E69138,stroke-width:2px;
    classDef storage fill:#DDEBF7,stroke:#0B5394,stroke-width:2px;
```
