Self-hosted knowledge management for SMEs: a split-screen Markdown editor whose sections an LLM refines while you write, and RAG question answering over the documents that result. FastAPI + Postgres/pgvector on the back, SvelteKit on the front, everything OpenAI-compatible and self-hostable. Squashed into a single commit; the development history stays local. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CA43ZJda8Rbp2hKXNy8f6b
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
import uuid
|
|
|
|
from sqlalchemy import Enum, ForeignKey, String
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
from app.models.department import Department
|
|
from app.models.enums import UserRole
|
|
|
|
|
|
class User(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "users"
|
|
|
|
email: Mapped[str] = mapped_column(String(320), unique=True, index=True)
|
|
name: Mapped[str] = mapped_column(String(200))
|
|
role: Mapped[UserRole] = mapped_column(
|
|
Enum(UserRole, native_enum=False, length=32), default=UserRole.member
|
|
)
|
|
password_hash: Mapped[str] = mapped_column(String(255))
|
|
# Interface language. NULL follows the browser's Accept-Language; a value
|
|
# pins it. One column rather than a preferences table: this is the only
|
|
# preference that has to follow the person across devices — the theme is
|
|
# per-device and lives in localStorage.
|
|
locale: Mapped[str | None] = mapped_column(String(5))
|
|
department_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
ForeignKey("departments.id", ondelete="SET NULL")
|
|
)
|
|
|
|
department: Mapped[Department | None] = relationship(lazy="joined")
|