chore: Initial commit

This commit is contained in:
2026-04-01 14:30:07 +01:00
commit 91cdd6523f
9 changed files with 141 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
**__pycache__/
**.egg-info/
instance/
build/

13
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.0
hooks:
- id: ruff-check
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: mypy
args: [--strict]
additional_dependencies: [flask, sqlalchemy, qrcode]

18
app/__init__.py Normal file
View File

@@ -0,0 +1,18 @@
from flask import Flask
from .db import init_db
def create_app() -> Flask:
app = Flask(__name__, instance_relative_config=True)
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///app.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
init_db(app)
from .routes import bp # noqa: PLC0415
app.register_blueprint(bp)
return app

21
app/db.py Normal file
View File

@@ -0,0 +1,21 @@
from flask import Flask
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, scoped_session, sessionmaker
engine = None
SessionLocal = None
class Base(DeclarativeBase):
pass
def init_db(app: Flask) -> None: # noqa: ARG001
global engine, SessionLocal # noqa: PLW0603
engine = create_engine("sqlite:///instance/app.db", echo=True, future=True)
SessionLocal = scoped_session(sessionmaker(bind=engine))
from . import models # noqa: F401, PLC0415
Base.metadata.create_all(bind=engine)

6
app/main.py Normal file
View File

@@ -0,0 +1,6 @@
from app import create_app
app = create_app()
if __name__ == "__main__":
app.run(debug=True)

11
app/models.py Normal file
View File

@@ -0,0 +1,11 @@
from sqlalchemy import Integer, String
from sqlalchemy.orm import Mapped, mapped_column
from .db import Base
class Drink(Base):
__tablename__ = "drinks"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String)

8
app/routes.py Normal file
View File

@@ -0,0 +1,8 @@
from flask import Blueprint, render_template
bp = Blueprint("main", __name__)
@bp.route("/")
def index() -> str:
return render_template("index.html")

10
app/templates/index.html Normal file
View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Fridge Tracker</title>
</head>
<body>
<h1>Fridge Tracker</h1>
<p>Welcome. System is running.</p>
</body>
</html>

50
pyproject.toml Normal file
View File

@@ -0,0 +1,50 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "fridge-tracker"
version = "0.1.0"
description = "Simple fridge tracking web app"
requires-python = ">=3.11"
dependencies = [ "flask>=3.0.0", "sqlalchemy>=2.0.0", "qrcode[pil]>=7.4.2" ]
[tool.ruff]
line-length = 120
indent-width = 4
[tool.ruff.lint]
select = ["ALL"]
ignore = [
# Conflicting
"D203",
"D212",
"COM812",
# Allow 'TODO' and 'HACK' in code
"FIX002",
"TD002",
"TD003",
"FIX004",
# Others I dont care about
"D"
]
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
[tool.mypy]
strict = true
warn_unused_configs = true
warn_return_any = true
warn_unused_ignores = true
no_implicit_optional = true
show_error_codes = true
pretty = true
disable_error_code = [
"attr-defined"
]