Files
CIAgent/apps/api/app/models/snapshot.py
T
saksham 1a4c80958f Initial commit: CI Agent competitive-intelligence monitoring app
FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring,
source collection, LLM-based change analysis, enrichment, and account
security (Turnstile, escalating lockout, email verification).
2026-08-05 10:48:20 -04:00

32 lines
1.2 KiB
Python

from __future__ import annotations
import uuid
from typing import Any
from sqlalchemy import JSON, ForeignKey, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.db.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
class Snapshot(Base, UUIDPrimaryKeyMixin, TimestampMixin):
"""A structured, comparable summary of a source's state at a point in
time - what change detection (Phase 6) diffs against the prior snapshot
for the same source."""
__tablename__ = "snapshots"
company_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("companies.id", ondelete="CASCADE"), index=True
)
source_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("sources.id", ondelete="CASCADE"), index=True
)
snapshot_type: Mapped[str] = mapped_column(String(50))
hash: Mapped[str] = mapped_column(String(64), index=True)
structured_summary: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict)
text_summary: Mapped[str | None] = mapped_column(Text, nullable=True)
monitoring_run_id: Mapped[uuid.UUID | None] = mapped_column(
ForeignKey("monitoring_runs.id", ondelete="SET NULL"), nullable=True, index=True
)