claudiosw/python-clean-architecture-example
61.4
Adequate · 22 September 2026
2.1k
lines of production code
JavaScript
with Python
7
measurements over time
What this system is
This system is a Python-based application designed to manage professional roles, specifically supporting the creation and storage of 'Profession' entities. It provides a dual-layered architecture that allows data persistence via either an in-memory store or a PostgreSQL database, with database migrations managed by Alembic. The application exposes this functionality through both a Flask API and a Command Line Interface (CLI), utilizing a clean architecture with distinct layers for domain logic, infrastructure, and user interfaces.
Features
Add CLI memory-based profession creation workflow
Users can now create a new profession via the command-line interface. This change introduces the complete CLI memory stack for this feature, including the \CreateProfessionController\ to handle input and orchestration, a \CreateProfessionPresenter\ to format the output, and a \CreateProfessionView\ to display the result. The implementation uses an in-memory repository for data storage during the session.
_src/app/cli\memory · high confidence
Add CreateProfession DTOs and tests
Introduced new data transfer objects for the CreateProfession use case, including CreateProfessionInputDto with a to\_dict conversion method and CreateProfessionOutputDto. Added corresponding unit tests to verify the input DTO's structure and dictionary conversion.
src/interactor/dtos · high confidence
Add default Python logging implementation
A new LoggerDefault class has been introduced in src/infra/loggers/logger\_default.py, providing a standard Python logging implementation that supports debug, info, warning, error, critical, and exception log levels. The module configures logging to write to 'app.log' with a specific date format and message structure. Corresponding unit tests have been added in logger\_default\_test.py to verify that each log method correctly delegates to the underlying logging functions.
src/infra/loggers · high confidence
Added Alembic configuration and initial migration for the professions table
The project now includes the standard Alembic setup files (README, env.py, script.py.mako) to support database migrations. A new initial migration has been added that creates the 'professions' table, defining fields for profession\_id, name, and description, with a corresponding downgrade to drop the table.
alembic · high confidence
Added Create Profession blueprint endpoint
A new Flask blueprint named 'create\_profession' has been introduced to handle POST requests at the '/profession/' route. This endpoint accepts JSON input, retrieves a logger from the application configuration, and delegates processing to the CreateProfessionController, returning a 201 Created response with the processed result.
_src/app/flask\postgresql/blueprints · high confidence
Added CreateProfessionController to handle profession creation requests
A new CreateProfessionController has been introduced in the Flask application to manage profession creation requests. This controller validates incoming data for required fields (name and description) and orchestrates the creation process by interacting with the underlying use case and repository layers. The implementation includes corresponding unit tests that verify the controller's behavior, including validation errors for missing inputs.
_src/app/flask\postgresql/controllers · high confidence
Added CreateProfessionPresenter to format profession creation responses
Users creating a new profession will now see a structured response containing the profession's ID, name, and description. This is enabled by the new CreateProfessionPresenter, which maps the internal CreateProfessionOutputDto to a dictionary with keys 'profession\_id', 'name', and 'description'. A corresponding test ensures the presenter correctly formats the output.
_src/app/flask\postgresql/presenters · high confidence
Added Flask PostgreSQL app factory and controller interface
Introduced a new \create\_flask\_postgresql\_app\ factory function that configures a Flask application with a \/v1\ blueprint for profession management, along with global error handlers for HTTP, value, and unique violation errors. The \FlaskPostgresqlControllerInterface\ was also added to support the application's controller layer. A comprehensive test suite was added to verify the app's error handling and request processing.
_src/app/flask\postgresql · high confidence
Added FlaskMemoryControllerInterface abstract class
A new abstract base class, FlaskMemoryControllerInterface, has been introduced in the src/app/flask\_memory/interfaces package. This interface defines the contract for the Flask memory controller, including an execute method that returns a dictionary and a get\_profession\_info method for handling input validation.
_src/app/flask\memory/interfaces · high confidence
Added FlaskPostgresqlControllerInterface
A new abstract interface, FlaskPostgresqlControllerInterface, has been introduced to define the contract for the Flask PostgreSQL controller. This interface specifies the expected methods, including get\_profession\_info and execute, ensuring consistent implementation across controllers.
_src/app/flask\postgresql/interfaces · high confidence
Added Profession entity and interactor infrastructure
The codebase now includes a new Profession entity and its associated use-case interactor, establishing the foundation for managing professional roles. This includes a pytest fixture for testing the Profession model and the creation of the interactor module, enabling the application to handle profession-related business logic.
src · high confidence
Added Profession entity and supporting value objects
Introduced a new Profession entity within the domain layer, including its core dataclass definition with id, name, and description fields, along with serialization helpers. This change also adds the ProfessionId value object and initializes the relevant package modules to support the new domain model.
src/domain · high confidence
Added SQLAlchemy database models and base configuration
Introduced the foundational database layer for the application. The \db\_base.py\ file establishes the SQLAlchemy declarative base, engine, and scoped session, configured via \config.DB\_URI\. Additionally, a new \ProfessionsDBModel\ is defined in \profession\_db\_model.py\, mapping to a 'professions' table with fields for a UUID primary key, a unique name, and a description.
_src/infra/db\models · high confidence
Added create\_profession blueprint for profession creation endpoint
A new Flask blueprint named 'create\_profession' has been introduced in the application's blueprints directory. This blueprint defines a POST endpoint at '/profession/' which accepts JSON input and delegates processing to the CreateProfessionController. This change adds the routing and request handling layer for creating professions, separating this functionality into its own modular component within the Flask application structure.
_src/app/flask\memory/blueprints · high confidence
Added custom exception classes for use-case validation
New exception classes have been introduced to the interactor layer to handle specific business rule violations. FieldValueNotPermittedException is raised when a field value is empty or not permitted, while ItemNotCreatedException signals failures in item creation. Additionally, a UniqueViolationError class has been added to handle unique constraint violations. These changes provide more granular error handling for use-case interactions.
src/interactor/errors · high confidence
Added in-memory and PostgreSQL repositories for managing professions
Introduced two new repository implementations for the Profession domain entity: an in-memory store for lightweight or testing scenarios, and a PostgreSQL-backed repository that persists profession data to a database. The PostgreSQL implementation includes logic to handle unique constraint violations by raising a specific UniqueViolationError. Both repositories implement the ProfessionRepositoryInterface, and each is accompanied by a dedicated test suite verifying create, read, update, and error-handling behaviors.
src/infra/repositories · high confidence
Added in-memory profession creation capability
Users can now create new professions using an in-memory storage system. This change introduces a new controller, presenter, and associated tests to handle the creation of profession records in memory, allowing for temporary, non-persistent storage of profession data during the application's runtime.
_src/app/flask\memory/controllers · high confidence
Added input validation for creating professions
Users can now have their profession creation data validated against a defined schema. A new base validator class (BaseInputValidator) using Cerberus enforces field requirements, length limits, and empty value checks. A specific validator for the 'create profession' flow enforces name and description constraints and blocks the reserved name 'Profession'.
src/interactor/validations · high confidence
Added profession creation use case
A new use case for creating a profession has been introduced, featuring input validation, repository interaction, and error handling for failed creations. The implementation includes a dedicated module, its corresponding unit tests, and an empty package initializer to support the new structure.
_src/interactor/use\cases · high confidence
Added support for PostgreSQL-backed Flask API and CLI tools
Users can now run the application using a PostgreSQL database via the new \flask\_postgresql\_process\_handler.py\ script, which initializes the Flask app with database support. The repository also includes a \.env.example\ file to configure database credentials, an \alembic.ini\ configuration for managing database migrations, and a \cli\_memory\_process\_handler.py\ script for the in-memory CLI. Additionally, a \.gitignore\ file was added to exclude generated files like \.env\ and \app.log\ from version control.
(repo-wide) · high confidence
Introduce in-memory Flask application with profession endpoints
Added a new in-memory Flask application entry point that registers the profession blueprint at /v1 and configures error handling for HTTP, value, and general exceptions. The change includes the application factory, an empty init file, and a test suite verifying successful requests, missing/invalid name errors, 404 handling, and 500 error responses.
_src/app/flask\memory · high confidence
Introduced interface contracts for logging, presenters, and repositories
New abstract interface classes have been added to define the structure for logging, presenters, and repositories. Specifically, a LoggerInterface is provided with methods for various log levels and exception logging. A CreateProfessionPresenterInterface is introduced to handle the presentation of profession data, and a ProfessionRepositoryInterface is added to define operations for retrieving, creating, and updating Profession entities. These interfaces establish the contracts that implementing classes must follow.
src/interactor/interfaces · high confidence
Behavioural changes
Added CreateProfessionPresenter for profession creation responses
A new CreateProfessionPresenter has been introduced to handle the presentation of profession creation results. This component maps the internal CreateProfessionOutputDto into a dictionary containing the profession's ID, name, and description, and includes corresponding unit tests to verify the correct transformation of these fields.
_src/app/flask\memory/presenters · medium confidence
Centralized database configuration via environment variables
The application now uses a dedicated configuration module (configs/config.py) to manage database connection settings. It loads environment variables (DATABASE\_USER, DATABASE\_PASSWORD, DATABASE\_NAME, DATABASE\_HOST, DATABASE\_PORT) and constructs a PostgreSQL connection URI using the psycopg2 driver. This change supports environment-based configuration, allowing users to set database credentials via .env files rather than hardcoding them.
configs · medium confidence
Dependencies
Initial project dependencies added
A new requirements.txt file has been added to the project, establishing the initial set of Python dependencies. This includes the Flask web framework, SQLAlchemy for database interactions, and various testing and linting tools such as pytest, pylint, and pre-commit.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 56 → 61 (+5.9)
- Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 98 → 97 (-1.2)
- Architecture 100 → 81 (-19.2)
- Maturity 53 → 55 (+2.8)
- Readiness 55 → 53 (-1.9)
- Security 44 → 71 (+27.2)
- Domain Modelling 100 → 100 (+0.0)
Resolved (30)
- Coverage not included — suite not readable by the collector
- Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
- Duplicated block (14 lines × 2) (src/app/flask_memory/create_flask_memory_app.py)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- Medium CVE: [GHSA redacted] (requirements.txt)
- Medium CVE: [GHSA redacted] (requirements.txt)
- Medium CVE: [GHSA redacted] (requirements.txt)
- Medium CVE: [GHSA redacted] (requirements.txt)
- …and 10 more
New (102)
- Banned license: pylint
- Documentation: no installation or build instructions (README.md)
- Documentation: no licence statement (README.md)
- Documentation: no usage examples (README.md)
- Duplicated block (13 lines × 2) (src/app/flask_memory/controllers/create_profession_controller.py)
- Duplicated block (23–24 lines × 2) (src/app/flask_memory/create_flask_memory_app.py)
- Duplicated block (8 lines × 2) (src/app/flask_memory/controllers/create_profession_controller.py)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High CVE: [GHSA redacted] (requirements.txt)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- …and 82 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
claudiosw/python-clean-architecture-example was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 22 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 2050a235efe2d62a282fb6a11e8400ce1b65629f — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-821afab8930d.