# lucasls02/api_validacao_senha architecture

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

- Interactive diagram: https://gitdiagram.com/lucasls02/api_validacao_senha
- Repository: https://github.com/lucasls02/api_validacao_senha

## Overview

##### Project type and purpose
- This is a single‐service REST API (“API Validação de Senha”) written in Python using Flask.
- It validates passwords against user‐provided rules (min size, uppercase, digits, etc.).
- It’s containerized with Docker and orchestrated via Docker Compose for easy deployment.

##### File structure
- Top‐level artifacts:
- Dockerfile, docker-compose.yaml, Makefile → container/build orchestration
- requirements.txt → Python dependencies
- src/ → application source code
- Inside src/:
- __main__.py & app.py → entrypoint and Flask application instantiation
- controllers/password_controller.py → HTTP endpoint logic
- schemas/password_schema.py → request payload validation schemas

##### README for additional insights
- Confirms Flask microframework is used to expose a POST /verify endpoint.
- No external database or message broker—purely in‐memory business logic.
- Makefile targets to build and run containers on Unix; docker-compose commands for all platforms.

##### Main components
a. External Client (User or Service)
b. Docker Compose orchestration layer
c. Docker Container running the Flask service
d. Flask Application (app.py) – routing layer
e. Controller layer (password_controller.py) – endpoint implementation & business logic
f. Schema layer (password_schema.py) – request validation using Marshmallow (or similar)

##### Relationships and interactions
- Client → HTTP POST /verify on host:8080 (mapped in docker-compose)
- Docker Compose maps port 8080 → Container
- Container launches Flask app (__main__.py loads app.py)
- Flask routes request to PasswordController.verify_password()
- Controller invokes Schema.load() to validate the JSON payload
- If validation passes, controller applies each “rule” to the “password”
- Controller returns JSON response (200 / 422 / 500) back to client

##### Architectural patterns & design principles
- Layered architecture: Presentation (HTTP) → Controllers → Validation Schemas → Business logic
- Separation of concerns: routing vs. validation vs. core logic
- Single microservice, stateless, easy to scale horizontally
- Containerization for environment consistency and portability

##### Technologies, frameworks & libraries
- Python 3.x
- Flask (micro web framework)
- Marshmallow (or Flask-Marshmallow) for schemas/validation
- Docker & Docker Compose for container build and orchestration
- Makefile for Unix convenience scripting

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Client
    Client["External Client (User/Service)"]:::external

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        DC["Docker Compose"]:::orchestration
        DF["Dockerfile"]:::orchestration
        MF["Makefile"]:::orchestration
        REQ["requirements.txt"]:::orchestration
    end

    %% Container Layer
    subgraph "Docker Container" 
        direction TB
        ENTRY["Entrypoint (__main__.py)"]:::container
        APP["Flask App (app.py)"]:::routing
        CTRL["PasswordController (password_controller.py)"]:::business
        SCHEMA["PasswordSchema (password_schema.py)"]:::business
    end

    %% Request Flow
    Client -->|"POST /verify on port 8080"| DC
    DC -->|"build image"| DF
    DC -->|"run scripts"| MF
    DC -->|"install deps"| REQ
    DC -->|"launch container"| ENTRY

    ENTRY -->|"loads app"| APP
    Client -->|"HTTP POST /verify"| APP
    APP -->|"route to verify_password()"| CTRL
    CTRL -->|"validate payload"| SCHEMA
    SCHEMA -->|"validation result"| CTRL
    CTRL -->|"create JSON response"| APP
    APP -->|"HTTP response"| Client

    %% Click Events
    click DC "https://github.com/lucasls02/api_validacao_senha/blob/main/docker-compose.yaml"
    click DF "https://github.com/lucasls02/api_validacao_senha/tree/main/Dockerfile"
    click MF "https://github.com/lucasls02/api_validacao_senha/tree/main/Makefile"
    click REQ "https://github.com/lucasls02/api_validacao_senha/blob/main/requirements.txt"
    click ENTRY "https://github.com/lucasls02/api_validacao_senha/blob/main/src/__main__.py"
    click APP "https://github.com/lucasls02/api_validacao_senha/blob/main/src/app.py"
    click CTRL "https://github.com/lucasls02/api_validacao_senha/blob/main/src/controllers/password_controller.py"
    click SCHEMA "https://github.com/lucasls02/api_validacao_senha/blob/main/src/schemas/password_schema.py"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000,color:#000
    classDef orchestration fill:#90EE90,stroke:#000,color:#000
    classDef container fill:#98FB98,stroke:#000,color:#000
    classDef routing fill:#FFA500,stroke:#000,color:#000
    classDef business fill:#FFD700,stroke:#000,color:#000
```
