diff --git a/pyproject.toml b/pyproject.toml index be6156b..7acb679 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,3 +18,13 @@ allmende-payment-system = "allmende_payment_system:main" [build-system] requires = ["uv_build>=0.9.2,<0.10.0"] build-backend = "uv_build" + +[dependency-groups] +dev = [ + "black>=25.9.0", + "isort>=7.0.0", + "pytest>=8.4.2", +] + +[tool.isort] +profile = "black" \ No newline at end of file diff --git a/src/allmende_payment_system/api/__init__.py b/src/allmende_payment_system/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/allmende_payment_system/app.py b/src/allmende_payment_system/app.py index 126054b..946fbac 100644 --- a/src/allmende_payment_system/app.py +++ b/src/allmende_payment_system/app.py @@ -1,11 +1,16 @@ # backend/app/main.py from fastapi import FastAPI, Request -from fastapi.templating import Jinja2Templates from fastapi.staticfiles import StaticFiles +from fastapi.templating import Jinja2Templates app = FastAPI() templates = Jinja2Templates(directory="src/allmende_payment_system/templates") -app.mount("/static", StaticFiles(directory="src/allmende_payment_system/static"), name="static") +app.mount( + "/static", + StaticFiles(directory="src/allmende_payment_system/static"), + name="static", +) + @app.get("/") async def landing_page(request: Request): diff --git a/src/allmende_payment_system/database.py b/src/allmende_payment_system/database.py new file mode 100644 index 0000000..3139eec --- /dev/null +++ b/src/allmende_payment_system/database.py @@ -0,0 +1,6 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker + +SQLALCHEMY_DATABASE_URL = "sqlite:///./aps_db.db" +engine = create_engine(SQLALCHEMY_DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/src/allmende_payment_system/models.py b/src/allmende_payment_system/models.py new file mode 100644 index 0000000..64d53aa --- /dev/null +++ b/src/allmende_payment_system/models.py @@ -0,0 +1,39 @@ +from sqlalchemy import Column, ForeignKey, Table +from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship + +TABLE_PREFIX = "aps_" + + +class Base(DeclarativeBase): + pass + + +class Account(Base): + __tablename__ = TABLE_PREFIX + "account" + id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) + name: Mapped[str] = mapped_column(nullable=False, unique=True) + + users: Mapped[list["User"]] = relationship( + "User", + secondary=TABLE_PREFIX + "user_account_association", + back_populates="accounts", + ) + + +user_account_association = Table( + TABLE_PREFIX + "user_account_association", + Base.metadata, + Column("user_id", ForeignKey(TABLE_PREFIX + "user.id"), primary_key=True), + Column("account_id", ForeignKey(TABLE_PREFIX + "account.id"), primary_key=True), +) + + +class User(Base): + __tablename__ = TABLE_PREFIX + "user" + id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) + username: Mapped[str] = mapped_column(nullable=False, unique=True) + display_name: Mapped[str] = mapped_column(nullable=False) + + accounts: Mapped[list["Account"]] = relationship( + "Account", secondary=user_account_association, back_populates="users" + ) diff --git a/src/allmende_payment_system/static/img/Logo.png b/src/allmende_payment_system/static/img/Logo.png new file mode 100644 index 0000000..2b44bc4 Binary files /dev/null and b/src/allmende_payment_system/static/img/Logo.png differ diff --git a/src/allmende_payment_system/templates/base.html.jinja b/src/allmende_payment_system/templates/base.html.jinja index b8f6c24..895a22a 100644 --- a/src/allmende_payment_system/templates/base.html.jinja +++ b/src/allmende_payment_system/templates/base.html.jinja @@ -15,7 +15,7 @@