No project description provided
Project description
Clean Architecture
This project is described a clean architecture written by Robert C. Martine. Architecture is fellow a clean architecture
Table of contents
DirectoryStructure
|-- clean_architecture
| |-- domain
| | |-request_object.py
| | |-response_object.py
| | `-use_case.py
| |-- entity
| | `-entity.py
| |-- exception
| | |-exception.py
| | `- *_exception.py
| |-- serializer
| `-serializer.py
Installation
pip install clean-architecture
Example
- Entity
from clean_architecture.entity import Entity
class UserEntity(Entity):
def __init__(
self,
user_id,
name,
created_at,
updated_at
):
self.id = user_id
self.name = name
self.created_at = created_at
self.updated_at = updated_at
@classmethod
def from_dict(cls, adict):
user = UserEntity(
user_id=adict.get("id"),
name=adict.get("name"),
created_at=adict.get("created_at"),
updated_at=adict.get("updated_at")
)
return user
-
Domain
- ValidRequestObject
from clean_architecture.domain import ( ValidRequestObject, InvalidRequestObject, UseCase, ResponseSuccess ) class CreateUserRequestObject(ValidRequestObject): def __init__(self, user): self.user = user if invalid_req.has_errors(): return invalid_req return CreateUserRequestObject( user=UserEntity.from_dict(adict) )
- UseCase
class CreatedUser(UseCase): def __init__(self, user_repository): self.user_repository = user_repository def process_request(self, request_object): user = self.user_repository.create(user=request_object.user) return ResponseSuccess(201, user)
-
Serializer
from schema import Schema
from clean_architecture.serializer import Serializer
class CreateUserEncoder(Serializer):
schema = Schema(
{
"name": str
},
ignore_extra_keys=True
)
Testing
$ pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clean-architecture-0.0.3.tar.gz.
File metadata
- Download URL: clean-architecture-0.0.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/2.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d563326c11c0160b82c07bb4edcef86e7bcddc25fa1b9f73ddc8bdbd2022fb32
|
|
| MD5 |
01aaeb3eb736d02c3c56477d30c17e64
|
|
| BLAKE2b-256 |
10710a3f1c96a4ca6ed725bb6aabbdb6ffd39861736430ec9cc7d12a5ce4dd68
|
File details
Details for the file clean_architecture-0.0.3-py2-none-any.whl.
File metadata
- Download URL: clean_architecture-0.0.3-py2-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/2.7.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8567774d3953c2aa06ebf0651607b6a41b5a13b92e2a3db77860ae983b1a10b9
|
|
| MD5 |
c78da59d22754056cb74ed75bf80bb0e
|
|
| BLAKE2b-256 |
e9972db7c48855ab2bb3a52d056cd546e71593f18f0206a925427745d9e617ef
|