How lucasls02/api_validacao_senha works
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