architectonics 0.0.22__tar.gz → 0.0.24__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: architectonics
3
- Version: 0.0.22
3
+ Version: 0.0.24
4
4
  Summary:
5
5
  Author: Your Name
6
6
  Author-email: you@example.com
@@ -0,0 +1,15 @@
1
+ from datetime import datetime
2
+ from typing import ClassVar, Protocol
3
+
4
+
5
+ class BaseEntityInterface(Protocol):
6
+ PK_FIELD: ClassVar[str]
7
+
8
+ @property
9
+ def id(self) -> str: ...
10
+
11
+ @property
12
+ def created_at(self) -> datetime: ...
13
+
14
+ @property
15
+ def updated_at(self) -> datetime: ...
@@ -0,0 +1,5 @@
1
+ import datetime
2
+
3
+
4
+ def get_current_datetime():
5
+ return datetime.datetime.utcnow()
@@ -4,7 +4,7 @@ from fastapi.middleware.cors import CORSMiddleware
4
4
  from architectonics.core.config.application_settings import application_settings
5
5
 
6
6
 
7
- class BaseAppFactory:
7
+ class BaseApplicationFactory:
8
8
  @classmethod
9
9
  def create(cls, title) -> FastAPI:
10
10
  app = FastAPI(
@@ -0,0 +1,20 @@
1
+ from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, create_async_engine
2
+ from sqlalchemy.orm import sessionmaker
3
+
4
+ from architectonics.infrastructure.config.database_settings import database_settings
5
+
6
+
7
+ def get_engine() -> AsyncEngine:
8
+ return create_async_engine(
9
+ database_settings.DATABASE_CONNECTION_STRING,
10
+ future=True,
11
+ echo=False,
12
+ )
13
+
14
+
15
+ def get_session(engine: AsyncEngine) -> sessionmaker:
16
+ return sessionmaker(
17
+ bind=engine,
18
+ class_=AsyncSession,
19
+ expire_on_commit=False,
20
+ )
@@ -0,0 +1,23 @@
1
+ import os
2
+
3
+ from dotenv import load_dotenv
4
+ from pydantic import BaseModel
5
+
6
+ load_dotenv()
7
+
8
+
9
+ class DatabaseSettings(BaseModel):
10
+ DATABASE_PREFIX: str = "postgresql+asyncpg"
11
+
12
+ POSTGRES_USER: str = os.getenv("POSTGRES_USER")
13
+ POSTGRES_PASSWORD: str = os.getenv("POSTGRES_PASSWORD")
14
+ POSTGRES_HOST: str = os.getenv("POSTGRES_HOST")
15
+ POSTGRES_PORT: int = os.getenv("POSTGRES_PORT")
16
+ POSTGRES_DATABASE_NAME: str = os.getenv("POSTGRES_DATABASE_NAME")
17
+
18
+ DATABASE_CONNECTION_STRING: str = (
19
+ f"{DATABASE_PREFIX}://{POSTGRES_USER}:" f"{POSTGRES_PASSWORD}@{POSTGRES_HOST}:{POSTGRES_PORT}/{POSTGRES_DATABASE_NAME}"
20
+ )
21
+
22
+
23
+ database_settings = DatabaseSettings()
@@ -0,0 +1,31 @@
1
+ import uuid
2
+
3
+ from sqlalchemy import Column, DateTime, String
4
+ from sqlalchemy.orm import as_declarative
5
+
6
+ from architectonics.common.interfaces.base_entity_interface import BaseEntityInterface
7
+ from architectonics.common.utils.utils import get_current_datetime
8
+
9
+
10
+ @as_declarative()
11
+ class BaseEntity(BaseEntityInterface):
12
+ __abstract__ = True
13
+
14
+ id = Column(
15
+ String,
16
+ primary_key=True,
17
+ default=lambda: str(uuid.uuid4()),
18
+ )
19
+
20
+ created_at = Column(
21
+ DateTime,
22
+ default=get_current_datetime,
23
+ )
24
+
25
+ updated_at = Column(
26
+ DateTime,
27
+ default=get_current_datetime,
28
+ onupdate=get_current_datetime,
29
+ )
30
+
31
+ PK_FIELD = "id"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "architectonics"
3
- version = "0.0.22"
3
+ version = "0.0.24"
4
4
  description = ""
5
5
  authors = ["Your Name <you@example.com>"]
6
6
 
@@ -3,9 +3,15 @@ from setuptools import setup
3
3
 
4
4
  packages = \
5
5
  ['architectonics',
6
+ 'architectonics.common',
7
+ 'architectonics.common.interfaces',
8
+ 'architectonics.common.utils',
6
9
  'architectonics.core',
7
10
  'architectonics.core.config',
8
- 'architectonics.core.factory']
11
+ 'architectonics.core.factory',
12
+ 'architectonics.infrastructure',
13
+ 'architectonics.infrastructure.config',
14
+ 'architectonics.infrastructure.entities']
9
15
 
10
16
  package_data = \
11
17
  {'': ['*']}
@@ -22,7 +28,7 @@ install_requires = \
22
28
 
23
29
  setup_kwargs = {
24
30
  'name': 'architectonics',
25
- 'version': '0.0.22',
31
+ 'version': '0.0.24',
26
32
  'description': '',
27
33
  'long_description': None,
28
34
  'author': 'Your Name',