Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccb53d87a2 | ||
|
|
58c3e76c08 | ||
|
|
4c856b1b3e | ||
|
|
74451c1cdb | ||
|
|
4feedc4ab5 | ||
|
|
5f7e52d5a0 | ||
|
|
56e43746c9 | ||
|
|
5bab3ebf68 |
No files matched your search
+45
@@ -0,0 +1,45 @@
|
|||||||
|
# --- Local Environments & Secrets ---
|
||||||
|
.venv/
|
||||||
|
.env
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.pytest_cache/
|
||||||
|
.mypy_cache/
|
||||||
|
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example # Keep templates tracked
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
client_secret*.json
|
||||||
|
|
||||||
|
# --- Python & Build ---
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.mypy_cache/
|
||||||
|
.pytest_cache/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
|
||||||
|
# --- IDE & Editor Settings ---
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# --- Agentic & Cloud CLI Tools ---
|
||||||
|
# Global/Local agent configuration & memory files
|
||||||
|
.claude/
|
||||||
|
.gemini/
|
||||||
|
.cursor/
|
||||||
|
.windsurf/
|
||||||
|
.aider*/
|
||||||
|
.codex/
|
||||||
|
.antigravity*/
|
||||||
|
|
||||||
|
# Tool-specific session/memory/metadata
|
||||||
|
*.session
|
||||||
|
*.log
|
||||||
|
memory.json
|
||||||
|
agents.json
|
||||||
|
MCP/
|
||||||
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Novias del Gato - Agent Guidelines & Workflow Rules
|
||||||
|
|
||||||
|
This document specifies the mandatory workflows, constraints, and quality gates for AI agents operating in this repository.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Core Operating Constraints
|
||||||
|
|
||||||
|
- **No Direct Commits to `main`**: Agents must never commit directly to the `main` or `master` branches. All changes must be developed on descriptive feature, bugfix, or documentation branches (`feat/*`, `fix/*`, `docs/*`).
|
||||||
|
- **No Destructive Git Actions**: Commands such as `git reset --hard`, `git restore <file>`, `git clean -fd`, and force-pushes (`git push --force`) are strictly prohibited without the user's explicit written approval.
|
||||||
|
- **Secret Redaction**: Never print, commit, or log sensitive information (tokens, secrets, private keys, database passwords, API credentials). Use environment variables and `.env` files (which must be ignored in `.gitignore`).
|
||||||
|
- **Session Modes**:
|
||||||
|
- `learning`: The user drives and writes the reasoning, the agent asks guiding questions.
|
||||||
|
- `delivery`: The agent may draft code and plans, presenting rationale and trade-offs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Verification Gates (Pre-Commit Checklist)
|
||||||
|
|
||||||
|
Before any commit is proposed or executed, agents must execute and verify the following commands from the repository or `api/` directory:
|
||||||
|
|
||||||
|
1. **Ruff Formatting**:
|
||||||
|
```bash
|
||||||
|
uv run ruff format --check .
|
||||||
|
```
|
||||||
|
2. **Ruff Linting**:
|
||||||
|
```bash
|
||||||
|
uv run ruff check .
|
||||||
|
```
|
||||||
|
3. **Static Type Checking (Pyright)**:
|
||||||
|
```bash
|
||||||
|
uv run pyright
|
||||||
|
```
|
||||||
|
4. **Automated Test Suite (Pytest)**:
|
||||||
|
```bash
|
||||||
|
uv run pytest
|
||||||
|
```
|
||||||
|
|
||||||
|
No commit may be generated if any of these checks fail or report unhandled errors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Architecture & Domain Directives
|
||||||
|
|
||||||
|
- **API-First Architecture**: Endpoints and schemas in `api/` must stay aligned with `docs/openapi_unified.yaml`.
|
||||||
|
- **SSO Identity Provider Pattern**: Authentication logic must be decoupled behind the `IdentityProvider` interface/adapter protocol. Do not hardcode vendor-specific auth checks in core routes.
|
||||||
|
- **Edge Inference Model Invariant**: Vector embeddings (1280 floats via MobileNetV2) are generated on client devices (WebAssembly/WebGL via ONNX Runtime Web). The backend never runs heavy deep learning inference on check-ins; it performs spatial proximity checks (PostGIS) and cosine similarity queries (`pgvector`).
|
||||||
|
- **Spatial & Vector Integrity**: Coordinates must use EPSG:4326 (WGS84). Embeddings must be 1280-dimension L2-normalized float vectors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Agent Directory & Delegation
|
||||||
|
|
||||||
|
When working on specialized sub-domains:
|
||||||
|
- **Anne Droid** (`profile/agents/anne-droid.md`): Consult for UX flow, client accessibility, or backend API contract changes that impact the UI. Delegate to Anne for frontend component styling, PWA camera/canvas interaction, or client-side tests on `feat/anne/*` branches.
|
||||||
|
- Do not invoke Anne Droid for backend-only logic, database migrations, or Docker infrastructure.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
source .venv/bin/activate
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
3.14
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV UV_COMPILE_BYTECODE=1
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
# Copy dependency files
|
||||||
|
COPY api/pyproject.toml api/uv.lock /app/
|
||||||
|
|
||||||
|
# Install dependencies without installing the project itself
|
||||||
|
RUN uv sync --frozen --no-dev --no-install-project
|
||||||
|
|
||||||
|
# Copy application code
|
||||||
|
COPY api /app
|
||||||
|
|
||||||
|
# Install the application package
|
||||||
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
|
# Add virtual environment to PATH
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
|
|
||||||
|
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
Whitespace-only changes.
@@ -0,0 +1,57 @@
|
|||||||
|
[project]
|
||||||
|
name = "novias-del-gato-api"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "FastAPI backend for Novias del Gato: digital ecosystem for Cali's public art"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.14"
|
||||||
|
dependencies = [
|
||||||
|
"fastapi>=0.115.0",
|
||||||
|
"uvicorn[standard]>=0.30.0",
|
||||||
|
"pydantic>=2.7.0",
|
||||||
|
"pydantic-settings>=2.2.0",
|
||||||
|
"email-validator>=2.1.0",
|
||||||
|
"sqlalchemy[asyncio]>=2.0.30",
|
||||||
|
"asyncpg>=0.29.0",
|
||||||
|
"psycopg[binary]>=3.1.18",
|
||||||
|
"geoalchemy2>=0.15.0",
|
||||||
|
"pgvector>=0.3.0",
|
||||||
|
"alembic>=1.13.0",
|
||||||
|
"pyjwt>=2.8.0",
|
||||||
|
"python-multipart>=0.0.9",
|
||||||
|
"httpx>=0.27.0"
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = [
|
||||||
|
"pytest>=8.0.0",
|
||||||
|
"pytest-asyncio>=0.24.0",
|
||||||
|
"ruff>=0.6.0",
|
||||||
|
"pyright>=1.1.380"
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
line-length = 100
|
||||||
|
target-version = "py312"
|
||||||
|
|
||||||
|
[tool.ruff.lint]
|
||||||
|
select = ["E", "F", "I", "UP", "B", "SIM"]
|
||||||
|
ignore = ["E501"]
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
pythonVersion = "3.14"
|
||||||
|
typeCheckingMode = "standard"
|
||||||
|
include = ["src", "tests"]
|
||||||
|
exclude = ["**/__pycache__", ".venv"]
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
asyncio_mode = "auto"
|
||||||
|
asyncio_default_fixture_loop_scope = "function"
|
||||||
|
testpaths = ["tests"]
|
||||||
|
pythonpath = ["src"]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["hatchling"]
|
||||||
|
build-backend = "hatchling.build"
|
||||||
|
|
||||||
|
[tool.hatch.build.targets.wheel]
|
||||||
|
packages = ["src/api"]
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
"""
|
||||||
|
Novias del Gato API package.
|
||||||
|
"""
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
class Settings(BaseSettings):
|
||||||
|
"""
|
||||||
|
Application configuration loaded from environment variables.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ENV: str = "development"
|
||||||
|
PROJECT_NAME: str = "Novias del Gato API"
|
||||||
|
VERSION: str = "0.1.0"
|
||||||
|
|
||||||
|
# Database
|
||||||
|
DATABASE_URL: str = "postgresql+asyncpg://postgres:postgres@localhost:5432/novias_db"
|
||||||
|
|
||||||
|
# JWT
|
||||||
|
JWT_SECRET: str = "insecure_dev_secret_change_in_production"
|
||||||
|
JWT_ALGORITHM: str = "HS256"
|
||||||
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440
|
||||||
|
|
||||||
|
# OAuth / SSO
|
||||||
|
GOOGLE_CLIENT_ID: str | None = None
|
||||||
|
GOOGLE_CLIENT_SECRET: str | None = None
|
||||||
|
GOOGLE_REDIRECT_URI: str | None = None
|
||||||
|
|
||||||
|
# Recognition and Spatial Rules
|
||||||
|
SIMILARITY_THRESHOLD: float = 0.65
|
||||||
|
PROXIMITY_RADIUS_METERS: float = 15.0
|
||||||
|
|
||||||
|
# Consensus Engine Thresholds
|
||||||
|
CONSENSUS_CLUSTER_RADIUS_METERS: float = 20.0
|
||||||
|
CONSENSUS_CONFIDENCE_THRESHOLD: float = 3.0
|
||||||
|
CONSENSUS_MIN_REPORTERS: int = 3
|
||||||
|
MAX_PLAUSIBLE_VELOCITY_KMH: float = 120.0
|
||||||
|
|
||||||
|
model_config = SettingsConfigDict(
|
||||||
|
env_file=".env",
|
||||||
|
env_file_encoding="utf-8",
|
||||||
|
extra="ignore",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
settings = Settings()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
from sqlalchemy.orm import DeclarativeBase
|
||||||
|
|
||||||
|
|
||||||
|
class Base(DeclarativeBase):
|
||||||
|
"""
|
||||||
|
Base class for all SQLAlchemy database models.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
from collections.abc import AsyncGenerator
|
||||||
|
|
||||||
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||||
|
|
||||||
|
from api.core.config import settings
|
||||||
|
|
||||||
|
# Create async engine
|
||||||
|
engine = create_async_engine(
|
||||||
|
settings.DATABASE_URL,
|
||||||
|
echo=(settings.ENV == "development"),
|
||||||
|
future=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Async session factory
|
||||||
|
AsyncSessionLocal = async_sessionmaker(
|
||||||
|
bind=engine,
|
||||||
|
class_=AsyncSession,
|
||||||
|
expire_on_commit=False,
|
||||||
|
autocommit=False,
|
||||||
|
autoflush=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def get_db_session() -> AsyncGenerator[AsyncSession, None]:
|
||||||
|
"""
|
||||||
|
FastAPI dependency yielding an async database session.
|
||||||
|
"""
|
||||||
|
async with AsyncSessionLocal() as session:
|
||||||
|
try:
|
||||||
|
yield session
|
||||||
|
finally:
|
||||||
|
await session.close()
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
from api.db_models.checkin import CheckInDB
|
||||||
|
from api.db_models.sculpture import SculptureDB
|
||||||
|
from api.db_models.ticket import TicketDB
|
||||||
|
from api.db_models.user import UserDB
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"UserDB",
|
||||||
|
"SculptureDB",
|
||||||
|
"CheckInDB",
|
||||||
|
"TicketDB",
|
||||||
|
]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
|
from sqlalchemy import DateTime, Float, ForeignKey, String, UniqueConstraint
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from api.database.base import Base
|
||||||
|
|
||||||
|
|
||||||
|
class CheckInDB(Base):
|
||||||
|
"""
|
||||||
|
SQLAlchemy model for user check-in captures.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__tablename__ = "check_ins"
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint("user_id", "sculpture_id", name="uq_user_sculpture_checkin"),
|
||||||
|
)
|
||||||
|
|
||||||
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True
|
||||||
|
)
|
||||||
|
sculpture_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(as_uuid=True),
|
||||||
|
ForeignKey("sculptures.id", ondelete="CASCADE"),
|
||||||
|
nullable=False,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
captured_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False
|
||||||
|
)
|
||||||
|
photo_url: Mapped[str] = mapped_column(String(512), nullable=False)
|
||||||
|
similarity_score: Mapped[float] = mapped_column(Float, nullable=False)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# Relationships
|
||||||
|
user = relationship("UserDB", back_populates="check_ins")
|
||||||
|
sculpture = relationship("SculptureDB", back_populates="check_ins")
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
|
from geoalchemy2 import Geometry
|
||||||
|
from pgvector.sqlalchemy import Vector
|
||||||
|
from sqlalchemy import DateTime, Integer, String, Text
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from api.database.base import Base
|
||||||
|
|
||||||
|
|
||||||
|
class SculptureDB(Base):
|
||||||
|
"""
|
||||||
|
SQLAlchemy model for cat sculptures (The Oracle SSOT).
|
||||||
|
"""
|
||||||
|
|
||||||
|
__tablename__ = "sculptures"
|
||||||
|
|
||||||
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
|
artist: Mapped[str] = mapped_column(String(255), nullable=False)
|
||||||
|
year: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||||
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
|
audio_url: Mapped[str | None] = mapped_column(String(512), nullable=True)
|
||||||
|
unlocked_content: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
|
status: Mapped[str] = mapped_column(String(50), default="on-site", nullable=False)
|
||||||
|
|
||||||
|
# PostGIS spatial point (SRID 4326: WGS84)
|
||||||
|
location = mapped_column(
|
||||||
|
Geometry(geometry_type="POINT", srid=4326, spatial_index=True), nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
# pgvector 1280-dimension embedding (MobileNetV2 feature vector)
|
||||||
|
embedding = mapped_column(Vector(1280), nullable=False)
|
||||||
|
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False
|
||||||
|
)
|
||||||
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True),
|
||||||
|
default=lambda: datetime.now(UTC),
|
||||||
|
onupdate=lambda: datetime.now(UTC),
|
||||||
|
nullable=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Relationships
|
||||||
|
check_ins = relationship("CheckInDB", back_populates="sculpture", cascade="all, delete-orphan")
|
||||||
|
tickets = relationship("TicketDB", back_populates="sculpture", cascade="all, delete-orphan")
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
|
from geoalchemy2 import Geometry
|
||||||
|
from sqlalchemy import DateTime, Float, ForeignKey, Index, String, Text
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from api.database.base import Base
|
||||||
|
|
||||||
|
|
||||||
|
class TicketDB(Base):
|
||||||
|
"""
|
||||||
|
SQLAlchemy model for crowdsourced status report tickets.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__tablename__ = "tickets"
|
||||||
|
__table_args__ = (Index("idx_tickets_sculpture_status", "sculpture_id", "status"),)
|
||||||
|
|
||||||
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
reporter_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True
|
||||||
|
)
|
||||||
|
sculpture_id: Mapped[uuid.UUID] = mapped_column(
|
||||||
|
UUID(as_uuid=True),
|
||||||
|
ForeignKey("sculptures.id", ondelete="CASCADE"),
|
||||||
|
nullable=False,
|
||||||
|
index=True,
|
||||||
|
)
|
||||||
|
reported_status: Mapped[str] = mapped_column(String(50), nullable=False)
|
||||||
|
|
||||||
|
# PostGIS spatial point for the reported location
|
||||||
|
location = mapped_column(
|
||||||
|
Geometry(geometry_type="POINT", srid=4326, spatial_index=True), nullable=False
|
||||||
|
)
|
||||||
|
|
||||||
|
photo_url: Mapped[str | None] = mapped_column(String(512), nullable=True)
|
||||||
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||||
|
status: Mapped[str] = mapped_column(String(50), default="pending", nullable=False)
|
||||||
|
reporter_trust_score: Mapped[float] = mapped_column(Float, nullable=False)
|
||||||
|
notes: Mapped[str | None] = mapped_column(String(300), nullable=True)
|
||||||
|
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False
|
||||||
|
)
|
||||||
|
resolved_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||||
|
|
||||||
|
# Relationships
|
||||||
|
reporter = relationship("UserDB", back_populates="tickets")
|
||||||
|
sculpture = relationship("SculptureDB", back_populates="tickets")
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
|
from sqlalchemy import DateTime, Float, String
|
||||||
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
from api.database.base import Base
|
||||||
|
|
||||||
|
|
||||||
|
class UserDB(Base):
|
||||||
|
"""
|
||||||
|
SQLAlchemy model for application users / explorers.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__tablename__ = "users"
|
||||||
|
|
||||||
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
||||||
|
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||||
|
email: Mapped[str] = mapped_column(String(255), unique=True, index=True, nullable=False)
|
||||||
|
trust_score: Mapped[float] = mapped_column(Float, default=0.5, nullable=False)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True), default=lambda: datetime.now(UTC), nullable=False
|
||||||
|
)
|
||||||
|
updated_at: Mapped[datetime] = mapped_column(
|
||||||
|
DateTime(timezone=True),
|
||||||
|
default=lambda: datetime.now(UTC),
|
||||||
|
onupdate=lambda: datetime.now(UTC),
|
||||||
|
nullable=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Relationships
|
||||||
|
check_ins = relationship("CheckInDB", back_populates="user", cascade="all, delete-orphan")
|
||||||
|
tickets = relationship("TicketDB", back_populates="reporter", cascade="all, delete-orphan")
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
from fastapi import FastAPI, HTTPException, status
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
from api.core.config import settings
|
||||||
|
from api.models.auth import DevTokenRequest, LoginResponse
|
||||||
|
from api.services.auth.service import AuthService
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title=settings.PROJECT_NAME,
|
||||||
|
version=settings.VERSION,
|
||||||
|
description="Digital ecosystem backend for Cali's public art (Novias del Gato).",
|
||||||
|
)
|
||||||
|
|
||||||
|
# CORS middleware
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["*"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
auth_service = AuthService()
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/health", tags=["System"])
|
||||||
|
async def health_check() -> dict[str, str]:
|
||||||
|
"""
|
||||||
|
Service health check endpoint.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"status": "healthy",
|
||||||
|
"service": settings.PROJECT_NAME,
|
||||||
|
"version": settings.VERSION,
|
||||||
|
"env": settings.ENV,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post(
|
||||||
|
"/auth/dev-token",
|
||||||
|
response_model=LoginResponse,
|
||||||
|
tags=["Authentication"],
|
||||||
|
summary="Development SSO Bypass Token Generation",
|
||||||
|
)
|
||||||
|
async def generate_dev_token(payload: DevTokenRequest) -> LoginResponse:
|
||||||
|
"""
|
||||||
|
Generate signed JWT for testing without contacting external OAuth providers.
|
||||||
|
Available only when ENV is not 'production'.
|
||||||
|
"""
|
||||||
|
if settings.ENV == "production":
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Development token generation disabled in production environment.",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Use deterministic mock ID based on email
|
||||||
|
import hashlib
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
deterministic_uuid = uuid.UUID(hashlib.md5(payload.email.encode("utf-8")).hexdigest())
|
||||||
|
|
||||||
|
return auth_service.create_access_token(
|
||||||
|
user_id=str(deterministic_uuid),
|
||||||
|
email=payload.email,
|
||||||
|
)
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
from api.models.auth import DevTokenRequest, LoginRequest, LoginResponse
|
||||||
|
from api.models.checkin import CheckInRecord, CheckInResponse
|
||||||
|
from api.models.sculpture import Sculpture, SculptureDetails, SculptureStatus
|
||||||
|
from api.models.ticket import ReportVerificationRequest, Ticket, TicketStatus
|
||||||
|
from api.models.user import User
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"User",
|
||||||
|
"SculptureStatus",
|
||||||
|
"Sculpture",
|
||||||
|
"SculptureDetails",
|
||||||
|
"CheckInRecord",
|
||||||
|
"CheckInResponse",
|
||||||
|
"TicketStatus",
|
||||||
|
"Ticket",
|
||||||
|
"ReportVerificationRequest",
|
||||||
|
"LoginRequest",
|
||||||
|
"LoginResponse",
|
||||||
|
"DevTokenRequest",
|
||||||
|
]
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
|
||||||
|
class LoginRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
Request model for Google SSO Authentication.
|
||||||
|
"""
|
||||||
|
|
||||||
|
id_token: str = Field(..., description="The ID token returned by Google OAuth flow.")
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJzdWIiOiIxMjM0NTY3ODkwIiwiYXVkIjoiY2xpZW50X2lkIiwiZXhwIjoxNDY5NDkwMDAwfQ..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class LoginResponse(BaseModel):
|
||||||
|
"""
|
||||||
|
Response model containing authentication JWT token details.
|
||||||
|
"""
|
||||||
|
|
||||||
|
access_token: str = Field(
|
||||||
|
..., description="JWT access token for subsequent authenticated API requests."
|
||||||
|
)
|
||||||
|
token_type: str = Field("Bearer", description="The type of the returned access token.")
|
||||||
|
expires_in: int = Field(..., description="The lifetime of the access token in seconds.")
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ...",
|
||||||
|
"token_type": "Bearer",
|
||||||
|
"expires_in": 3600,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DevTokenRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
Request model for development/testing SSO bypass.
|
||||||
|
"""
|
||||||
|
|
||||||
|
email: str = Field(..., description="Email address for the mock test user.")
|
||||||
|
name: str = Field("Local Explorer", description="Display name for the mock test user.")
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field, HttpUrl
|
||||||
|
|
||||||
|
|
||||||
|
class CheckInRecord(BaseModel):
|
||||||
|
"""
|
||||||
|
CheckInRecord representing a successful user capture of a sculpture.
|
||||||
|
"""
|
||||||
|
|
||||||
|
sculpture_id: UUID = Field(..., description="The ID of the sculpture captured.")
|
||||||
|
unlocked_at: datetime = Field(..., description="Timestamp of when the sculpture was captured.")
|
||||||
|
checkin_photo_url: HttpUrl | None = Field(
|
||||||
|
default=None, description="URL of the photo uploaded during check-in."
|
||||||
|
)
|
||||||
|
similarity_score: float = Field(
|
||||||
|
...,
|
||||||
|
description="Visual recognition similarity score between the uploaded photo and the target model.",
|
||||||
|
ge=0.0,
|
||||||
|
le=1.0,
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"sculpture_id": "234e5678-e89b-12d3-a456-426614174000",
|
||||||
|
"unlocked_at": "2026-05-30T10:15:30Z",
|
||||||
|
"checkin_photo_url": "https://cdn.gatos.cali.gov.co/uploads/checkin_9823.jpg",
|
||||||
|
"similarity_score": 0.92,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class CheckInResponse(BaseModel):
|
||||||
|
"""
|
||||||
|
Response model returned after a check-in verification request.
|
||||||
|
"""
|
||||||
|
|
||||||
|
success: bool = Field(
|
||||||
|
..., description="Indicates if the visual check-in met threshold requirements."
|
||||||
|
)
|
||||||
|
similarity_score: float = Field(
|
||||||
|
..., description="The visual similarity rating from the recognition engine.", ge=0.0, le=1.0
|
||||||
|
)
|
||||||
|
unlocked_content: str | None = Field(
|
||||||
|
default=None, description="Unlocked cultural details of the sculpture, if success is true."
|
||||||
|
)
|
||||||
|
reward_badge: str | None = Field(
|
||||||
|
default=None, description="Name of the badge unlocked by this capture, if any."
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"success": True,
|
||||||
|
"similarity_score": 0.92,
|
||||||
|
"unlocked_content": "This sculpture was crafted in tribute to the traditional festival of Macetas.",
|
||||||
|
"reward_badge": "First Sighting",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
from enum import StrEnum
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field, HttpUrl
|
||||||
|
|
||||||
|
|
||||||
|
class SculptureStatus(StrEnum):
|
||||||
|
ON_SITE = "on-site"
|
||||||
|
MOVED = "moved"
|
||||||
|
MISSING = "missing"
|
||||||
|
|
||||||
|
|
||||||
|
class Sculpture(BaseModel):
|
||||||
|
"""
|
||||||
|
Sculpture base model representing a public cat monument.
|
||||||
|
"""
|
||||||
|
|
||||||
|
id: UUID = Field(..., description="Unique identifier for the sculpture.")
|
||||||
|
name: str = Field(..., description="Name of the sculpture.", min_length=1)
|
||||||
|
artist: str = Field(..., description="Artist who created the sculpture.", min_length=1)
|
||||||
|
year: int = Field(..., description="Year the sculpture was created / installed.", ge=1900)
|
||||||
|
latitude: float = Field(
|
||||||
|
..., description="GPS Latitude coordinate of the sculpture.", ge=-90.0, le=90.0
|
||||||
|
)
|
||||||
|
longitude: float = Field(
|
||||||
|
..., description="GPS Longitude coordinate of the sculpture.", ge=-180.0, le=180.0
|
||||||
|
)
|
||||||
|
status: SculptureStatus = Field(..., description="Operational status of the sculpture.")
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"id": "234e5678-e89b-12d3-a456-426614174000",
|
||||||
|
"name": "La Novia Dulce",
|
||||||
|
"artist": "Lorena Espitia",
|
||||||
|
"year": 2006,
|
||||||
|
"latitude": 3.450143,
|
||||||
|
"longitude": -76.533282,
|
||||||
|
"status": "on-site",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class SculptureDetails(Sculpture):
|
||||||
|
"""
|
||||||
|
Extended sculpture model containing cultural details, unlocked content, and audio resources.
|
||||||
|
"""
|
||||||
|
|
||||||
|
description: str = Field(..., description="Public cultural description of the sculpture.")
|
||||||
|
audio_url: HttpUrl = Field(..., description="Direct link to the audio guide resource.")
|
||||||
|
unlocked_content: str = Field(
|
||||||
|
..., description="Extended history/curation unlocked upon checking in."
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"id": "234e5678-e89b-12d3-a456-426614174000",
|
||||||
|
"name": "La Novia Dulce",
|
||||||
|
"artist": "Lorena Espitia",
|
||||||
|
"year": 2006,
|
||||||
|
"latitude": 3.450143,
|
||||||
|
"longitude": -76.533282,
|
||||||
|
"status": "on-site",
|
||||||
|
"description": "Decorated with sweets and candies representing Cali's culinary traditions.",
|
||||||
|
"audio_url": "https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3",
|
||||||
|
"unlocked_content": "This sculpture was crafted in tribute to the traditional festival of Macetas.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from enum import StrEnum
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from pydantic import BaseModel, Field, HttpUrl
|
||||||
|
|
||||||
|
from api.models.sculpture import SculptureStatus
|
||||||
|
|
||||||
|
|
||||||
|
class TicketStatus(StrEnum):
|
||||||
|
PENDING = "pending"
|
||||||
|
APPROVED = "approved"
|
||||||
|
REJECTED = "rejected"
|
||||||
|
|
||||||
|
|
||||||
|
class Ticket(BaseModel):
|
||||||
|
"""
|
||||||
|
Ticket model representing a crowdsourced sculpture location report.
|
||||||
|
"""
|
||||||
|
|
||||||
|
id: UUID = Field(..., description="Unique identifier for the report ticket.")
|
||||||
|
reporter_id: UUID = Field(..., description="User ID of the reporter.")
|
||||||
|
sculpture_id: UUID = Field(..., description="ID of the reported sculpture.")
|
||||||
|
latitude: float = Field(..., description="GPS Latitude reported.", ge=-90.0, le=90.0)
|
||||||
|
longitude: float = Field(..., description="GPS Longitude reported.", ge=-180.0, le=180.0)
|
||||||
|
reported_status: SculptureStatus = Field(
|
||||||
|
..., description="The observed status of the sculpture."
|
||||||
|
)
|
||||||
|
photo_url: HttpUrl | None = Field(
|
||||||
|
default=None, description="Verification photo of the site / pedestal."
|
||||||
|
)
|
||||||
|
description: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Additional context or details regarding the status.",
|
||||||
|
max_length=500,
|
||||||
|
)
|
||||||
|
status: TicketStatus = Field(..., description="Resolution status of the ticket.")
|
||||||
|
created_at: datetime = Field(..., description="Timestamp of when the ticket was submitted.")
|
||||||
|
resolved_at: datetime | None = Field(
|
||||||
|
default=None, description="Timestamp of when the ticket was approved/rejected."
|
||||||
|
)
|
||||||
|
notes: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
description="Moderator resolution comments or verification notes.",
|
||||||
|
max_length=300,
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"id": "345e6789-e89b-12d3-a456-426614174000",
|
||||||
|
"reporter_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
"sculpture_id": "234e5678-e89b-12d3-a456-426614174000",
|
||||||
|
"latitude": 3.4515,
|
||||||
|
"longitude": -76.5320,
|
||||||
|
"reported_status": "moved",
|
||||||
|
"photo_url": "https://cdn.gatos.cali.gov.co/uploads/report_8321.jpg",
|
||||||
|
"description": "Under construction for street repairs. Pedestal is empty.",
|
||||||
|
"status": "pending",
|
||||||
|
"created_at": "2026-05-30T11:00:00Z",
|
||||||
|
"resolved_at": None,
|
||||||
|
"notes": None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ReportVerificationRequest(BaseModel):
|
||||||
|
"""
|
||||||
|
Request model used by moderators to resolve (verify) a report ticket.
|
||||||
|
"""
|
||||||
|
|
||||||
|
status: TicketStatus = Field(
|
||||||
|
..., description="New status to set for the ticket (approved or rejected)."
|
||||||
|
)
|
||||||
|
notes: str | None = Field(
|
||||||
|
default=None, description="Optional notes explaining the decision.", max_length=300
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"status": "approved",
|
||||||
|
"notes": "Verified via municipal service coordinates.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
from pydantic import BaseModel, EmailStr, Field
|
||||||
|
|
||||||
|
|
||||||
|
class User(BaseModel):
|
||||||
|
"""
|
||||||
|
User model representing an explorer in the Novias del Gato digital ecosystem.
|
||||||
|
"""
|
||||||
|
|
||||||
|
id: UUID = Field(..., description="Unique identifier for the user.")
|
||||||
|
name: str = Field(..., description="Full name of the user.", min_length=1, max_length=100)
|
||||||
|
email: EmailStr = Field(..., description="Email address of the user.")
|
||||||
|
trust_score: float = Field(
|
||||||
|
...,
|
||||||
|
description="Reputational metric scaling from 0.0 (untrusted) to 1.0 (highly reliable).",
|
||||||
|
ge=0.0,
|
||||||
|
le=1.0,
|
||||||
|
)
|
||||||
|
captured_count: int = Field(
|
||||||
|
..., description="Total number of unique sculptures verified by the user.", ge=0
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = {
|
||||||
|
"json_schema_extra": {
|
||||||
|
"example": {
|
||||||
|
"id": "123e4567-e89b-12d3-a456-426614174000",
|
||||||
|
"name": "Juan Perez",
|
||||||
|
"email": "juan.perez@gmail.com",
|
||||||
|
"trust_score": 0.85,
|
||||||
|
"captured_count": 12,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from api.services.auth.google import GoogleOAuthAdapter
|
||||||
|
from api.services.auth.mock import MockDevAdapter
|
||||||
|
from api.services.auth.provider import AuthUserIdentity, IdentityProvider
|
||||||
|
from api.services.auth.service import AuthService
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"AuthUserIdentity",
|
||||||
|
"IdentityProvider",
|
||||||
|
"MockDevAdapter",
|
||||||
|
"GoogleOAuthAdapter",
|
||||||
|
"AuthService",
|
||||||
|
]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import httpx
|
||||||
|
|
||||||
|
from api.services.auth.provider import AuthUserIdentity, IdentityProvider
|
||||||
|
|
||||||
|
|
||||||
|
class GoogleOAuthAdapter(IdentityProvider):
|
||||||
|
"""
|
||||||
|
Google OAuth token verification adapter.
|
||||||
|
"""
|
||||||
|
|
||||||
|
GOOGLE_TOKENINFO_URL = "https://oauth2.googleapis.com/tokeninfo"
|
||||||
|
|
||||||
|
def __init__(self, client_id: str | None = None):
|
||||||
|
self.client_id = client_id
|
||||||
|
|
||||||
|
async def verify_token(self, token: str) -> AuthUserIdentity:
|
||||||
|
async with httpx.AsyncClient(timeout=10.0) as client:
|
||||||
|
response = await client.get(self.GOOGLE_TOKENINFO_URL, params={"id_token": token})
|
||||||
|
|
||||||
|
if response.status_code != 200:
|
||||||
|
raise ValueError("Failed to verify Google ID token with upstream provider.")
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
# Verify audience if client_id is configured
|
||||||
|
if self.client_id and data.get("aud") != self.client_id:
|
||||||
|
raise ValueError("Google ID token audience mismatch.")
|
||||||
|
|
||||||
|
email = data.get("email")
|
||||||
|
if not email:
|
||||||
|
raise ValueError("Google ID token missing email address.")
|
||||||
|
|
||||||
|
name = data.get("name", email.split("@")[0])
|
||||||
|
sub = data.get("sub", "")
|
||||||
|
picture = data.get("picture")
|
||||||
|
|
||||||
|
return AuthUserIdentity(
|
||||||
|
email=email,
|
||||||
|
name=name,
|
||||||
|
provider_user_id=sub,
|
||||||
|
avatar_url=picture,
|
||||||
|
)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
from api.services.auth.provider import AuthUserIdentity, IdentityProvider
|
||||||
|
|
||||||
|
|
||||||
|
class MockDevAdapter(IdentityProvider):
|
||||||
|
"""
|
||||||
|
Mock identity provider for local development, tests, and CI.
|
||||||
|
Bypasses external network calls to Google/OAuth endpoints.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, default_email: str = "explorer@cali.gov.co", default_name: str = "Test Explorer"
|
||||||
|
):
|
||||||
|
self.default_email = default_email
|
||||||
|
self.default_name = default_name
|
||||||
|
|
||||||
|
async def verify_token(self, token: str) -> AuthUserIdentity:
|
||||||
|
if token == "invalid-token":
|
||||||
|
raise ValueError("Invalid mock authentication token provided.")
|
||||||
|
|
||||||
|
# In dev/mock mode, token can optionally be formatted as "email:name"
|
||||||
|
if ":" in token and "@" in token:
|
||||||
|
parts = token.split(":", 1)
|
||||||
|
email, name = parts[0], parts[1]
|
||||||
|
return AuthUserIdentity(
|
||||||
|
email=email,
|
||||||
|
name=name,
|
||||||
|
provider_user_id=f"mock-{email}",
|
||||||
|
)
|
||||||
|
|
||||||
|
return AuthUserIdentity(
|
||||||
|
email=self.default_email,
|
||||||
|
name=self.default_name,
|
||||||
|
provider_user_id="mock-user-12345",
|
||||||
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Protocol
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class AuthUserIdentity:
|
||||||
|
"""
|
||||||
|
Normalized user identity returned by any identity provider.
|
||||||
|
"""
|
||||||
|
|
||||||
|
email: str
|
||||||
|
name: str
|
||||||
|
provider_user_id: str
|
||||||
|
avatar_url: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class IdentityProvider(Protocol):
|
||||||
|
"""
|
||||||
|
Contract for pluggable SSO Identity Providers (Google, Authelia, Mock, etc.).
|
||||||
|
"""
|
||||||
|
|
||||||
|
async def verify_token(self, token: str) -> AuthUserIdentity:
|
||||||
|
"""
|
||||||
|
Verify external provider token and return normalized identity.
|
||||||
|
Raises ValueError or equivalent on invalid or expired token.
|
||||||
|
"""
|
||||||
|
...
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
from datetime import UTC, datetime, timedelta
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import jwt
|
||||||
|
|
||||||
|
from api.core.config import settings
|
||||||
|
from api.models.auth import LoginResponse
|
||||||
|
from api.services.auth.mock import MockDevAdapter
|
||||||
|
from api.services.auth.provider import AuthUserIdentity, IdentityProvider
|
||||||
|
|
||||||
|
|
||||||
|
class AuthService:
|
||||||
|
"""
|
||||||
|
Core authentication service responsible for token issuance, JWT verification,
|
||||||
|
and delegating SSO validation to an IdentityProvider adapter.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, provider: IdentityProvider | None = None):
|
||||||
|
if provider is not None:
|
||||||
|
self.provider = provider
|
||||||
|
elif settings.ENV in ("test", "development"):
|
||||||
|
self.provider = MockDevAdapter()
|
||||||
|
else:
|
||||||
|
from api.services.auth.google import GoogleOAuthAdapter
|
||||||
|
|
||||||
|
self.provider = GoogleOAuthAdapter(client_id=settings.GOOGLE_CLIENT_ID)
|
||||||
|
|
||||||
|
def create_access_token(self, user_id: str, email: str) -> LoginResponse:
|
||||||
|
"""
|
||||||
|
Create a signed JWT access token for the given user.
|
||||||
|
"""
|
||||||
|
expires_delta = timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||||
|
expire = datetime.now(UTC) + expires_delta
|
||||||
|
|
||||||
|
payload: dict[str, Any] = {
|
||||||
|
"sub": str(user_id),
|
||||||
|
"email": email,
|
||||||
|
"exp": expire,
|
||||||
|
"iat": datetime.now(UTC),
|
||||||
|
}
|
||||||
|
|
||||||
|
token = jwt.encode(payload, settings.JWT_SECRET, algorithm=settings.JWT_ALGORITHM)
|
||||||
|
|
||||||
|
return LoginResponse(
|
||||||
|
access_token=token,
|
||||||
|
token_type="Bearer",
|
||||||
|
expires_in=int(expires_delta.total_seconds()),
|
||||||
|
)
|
||||||
|
|
||||||
|
def decode_access_token(self, token: str) -> dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Decode and validate a JWT access token.
|
||||||
|
Raises jwt.PyJWTError on invalid or expired token.
|
||||||
|
"""
|
||||||
|
return jwt.decode(
|
||||||
|
token,
|
||||||
|
settings.JWT_SECRET,
|
||||||
|
algorithms=[settings.JWT_ALGORITHM],
|
||||||
|
)
|
||||||
|
|
||||||
|
async def authenticate_sso(self, id_token: str) -> AuthUserIdentity:
|
||||||
|
"""
|
||||||
|
Validate an external token using the configured IdentityProvider.
|
||||||
|
"""
|
||||||
|
return await self.provider.verify_token(id_token)
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import math
|
||||||
|
from collections.abc import Sequence
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from datetime import datetime
|
||||||
|
from enum import StrEnum
|
||||||
|
|
||||||
|
from api.core.config import settings
|
||||||
|
|
||||||
|
|
||||||
|
class ConsensusDecision(StrEnum):
|
||||||
|
AUTO_APPROVE = "auto_approve"
|
||||||
|
PENDING_MODERATION = "pending_moderation"
|
||||||
|
INSUFFICIENT_EVIDENCE = "insufficient_evidence"
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class SightingReport:
|
||||||
|
"""
|
||||||
|
Input data representing a single user report for consensus calculation.
|
||||||
|
"""
|
||||||
|
|
||||||
|
reporter_id: str
|
||||||
|
latitude: float
|
||||||
|
longitude: float
|
||||||
|
reported_status: str
|
||||||
|
trust_score: float
|
||||||
|
created_at: datetime
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class ConsensusResult:
|
||||||
|
"""
|
||||||
|
Outcome of evaluating a cluster of reports against the Oracle's consensus rules.
|
||||||
|
"""
|
||||||
|
|
||||||
|
decision: ConsensusDecision
|
||||||
|
confidence_score: float
|
||||||
|
distinct_reporters: int
|
||||||
|
centroid_latitude: float
|
||||||
|
centroid_longitude: float
|
||||||
|
consensus_status: str
|
||||||
|
|
||||||
|
|
||||||
|
def haversine_distance_meters(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
|
||||||
|
"""
|
||||||
|
Calculate the great-circle distance between two geographic points in meters.
|
||||||
|
"""
|
||||||
|
earth_radius_m = 6_371_000.0
|
||||||
|
|
||||||
|
phi1 = math.radians(lat1)
|
||||||
|
phi2 = math.radians(lat2)
|
||||||
|
delta_phi = math.radians(lat2 - lat1)
|
||||||
|
delta_lambda = math.radians(lon2 - lon1)
|
||||||
|
|
||||||
|
a = (
|
||||||
|
math.sin(delta_phi / 2.0) ** 2
|
||||||
|
+ math.cos(phi1) * math.cos(phi2) * math.sin(delta_lambda / 2.0) ** 2
|
||||||
|
)
|
||||||
|
c = 2.0 * math.atan2(math.sqrt(a), math.sqrt(1.0 - a))
|
||||||
|
|
||||||
|
return earth_radius_m * c
|
||||||
|
|
||||||
|
|
||||||
|
def verify_velocity(
|
||||||
|
lat1: float,
|
||||||
|
lon1: float,
|
||||||
|
t1: datetime,
|
||||||
|
lat2: float,
|
||||||
|
lon2: float,
|
||||||
|
t2: datetime,
|
||||||
|
max_kmh: float = settings.MAX_PLAUSIBLE_VELOCITY_KMH,
|
||||||
|
) -> bool:
|
||||||
|
"""
|
||||||
|
Verify that the speed required to travel between two consecutive submissions
|
||||||
|
does not exceed the maximum plausible urban velocity (default 120 km/h).
|
||||||
|
Returns True if physically plausible, False if likely spoofed.
|
||||||
|
"""
|
||||||
|
time_delta_seconds = abs((t2 - t1).total_seconds())
|
||||||
|
if time_delta_seconds <= 0:
|
||||||
|
# Simultaneous submissions at distinct locations are physically impossible
|
||||||
|
return (lat1 == lat2) and (lon1 == lon2)
|
||||||
|
|
||||||
|
distance_m = haversine_distance_meters(lat1, lon1, lat2, lon2)
|
||||||
|
speed_mps = distance_m / time_delta_seconds
|
||||||
|
speed_kmh = speed_mps * 3.6
|
||||||
|
|
||||||
|
return speed_kmh <= max_kmh
|
||||||
|
|
||||||
|
|
||||||
|
def evaluate_reports(
|
||||||
|
reports: Sequence[SightingReport],
|
||||||
|
cluster_radius_m: float = settings.CONSENSUS_CLUSTER_RADIUS_METERS,
|
||||||
|
confidence_threshold: float = settings.CONSENSUS_CONFIDENCE_THRESHOLD,
|
||||||
|
min_reporters: int = settings.CONSENSUS_MIN_REPORTERS,
|
||||||
|
) -> ConsensusResult:
|
||||||
|
"""
|
||||||
|
Evaluate a cluster of reports for a sculpture and decide if official state should transition.
|
||||||
|
"""
|
||||||
|
if not reports:
|
||||||
|
return ConsensusResult(
|
||||||
|
decision=ConsensusDecision.INSUFFICIENT_EVIDENCE,
|
||||||
|
confidence_score=0.0,
|
||||||
|
distinct_reporters=0,
|
||||||
|
centroid_latitude=0.0,
|
||||||
|
centroid_longitude=0.0,
|
||||||
|
consensus_status="unknown",
|
||||||
|
)
|
||||||
|
|
||||||
|
# Calculate centroid coordinates
|
||||||
|
avg_lat = sum(r.latitude for r in reports) / len(reports)
|
||||||
|
avg_lon = sum(r.longitude for r in reports) / len(reports)
|
||||||
|
|
||||||
|
# Filter reports that fall within the cluster radius of the centroid
|
||||||
|
valid_reports = [
|
||||||
|
r
|
||||||
|
for r in reports
|
||||||
|
if haversine_distance_meters(avg_lat, avg_lon, r.latitude, r.longitude) <= cluster_radius_m
|
||||||
|
]
|
||||||
|
|
||||||
|
distinct_reporters = len({r.reporter_id for r in valid_reports})
|
||||||
|
total_confidence = sum(r.trust_score for r in valid_reports)
|
||||||
|
|
||||||
|
# Find dominant status
|
||||||
|
status_weights: dict[str, float] = {}
|
||||||
|
for r in valid_reports:
|
||||||
|
status_weights[r.reported_status] = (
|
||||||
|
status_weights.get(r.reported_status, 0.0) + r.trust_score
|
||||||
|
)
|
||||||
|
|
||||||
|
dominant_status = (
|
||||||
|
max(status_weights, key=lambda k: status_weights[k]) if status_weights else "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Evaluate decision criteria
|
||||||
|
if (
|
||||||
|
total_confidence >= confidence_threshold
|
||||||
|
and distinct_reporters >= min_reporters
|
||||||
|
and status_weights.get(dominant_status, 0.0) >= (total_confidence * 0.75)
|
||||||
|
):
|
||||||
|
decision = ConsensusDecision.AUTO_APPROVE
|
||||||
|
elif total_confidence >= 1.5 or distinct_reporters >= 2:
|
||||||
|
decision = ConsensusDecision.PENDING_MODERATION
|
||||||
|
else:
|
||||||
|
decision = ConsensusDecision.INSUFFICIENT_EVIDENCE
|
||||||
|
|
||||||
|
return ConsensusResult(
|
||||||
|
decision=decision,
|
||||||
|
confidence_score=total_confidence,
|
||||||
|
distinct_reporters=distinct_reporters,
|
||||||
|
centroid_latitude=avg_lat,
|
||||||
|
centroid_longitude=avg_lon,
|
||||||
|
consensus_status=dominant_status,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def adjust_trust_score(
|
||||||
|
current_score: float,
|
||||||
|
verified_positive: bool,
|
||||||
|
boost: float = 0.05,
|
||||||
|
penalty: float = 0.15,
|
||||||
|
) -> float:
|
||||||
|
"""
|
||||||
|
Adjust a user's trust score based on report moderation outcome.
|
||||||
|
Clamped between 0.0 and 1.0.
|
||||||
|
"""
|
||||||
|
new_score = current_score + boost if verified_positive else current_score - penalty
|
||||||
|
|
||||||
|
return max(0.0, min(1.0, round(new_score, 4)))
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
from collections.abc import AsyncGenerator
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from httpx import ASGITransport, AsyncClient
|
||||||
|
|
||||||
|
from api.main import app
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
async def async_client() -> AsyncGenerator[AsyncClient, None]:
|
||||||
|
"""
|
||||||
|
Test client for FastAPI ASGI endpoints.
|
||||||
|
"""
|
||||||
|
transport = ASGITransport(app=app)
|
||||||
|
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||||||
|
yield client
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import pytest
|
||||||
|
from httpx import AsyncClient
|
||||||
|
|
||||||
|
from api.main import auth_service
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_health_check_endpoint(async_client: AsyncClient):
|
||||||
|
response = await async_client.get("/health")
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json()
|
||||||
|
assert data["status"] == "healthy"
|
||||||
|
assert "Novias del Gato" in data["service"]
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_dev_token_endpoint(async_client: AsyncClient):
|
||||||
|
payload = {"email": "carlos@example.com", "name": "Carlos Ruiz"}
|
||||||
|
response = await async_client.post("/auth/dev-token", json=payload)
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
assert "access_token" in data
|
||||||
|
assert data["token_type"] == "Bearer"
|
||||||
|
|
||||||
|
# Verify returned token with auth service
|
||||||
|
decoded = auth_service.decode_access_token(data["access_token"])
|
||||||
|
assert decoded["email"] == "carlos@example.com"
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from api.services.auth.mock import MockDevAdapter
|
||||||
|
from api.services.auth.service import AuthService
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_mock_dev_adapter_default():
|
||||||
|
adapter = MockDevAdapter()
|
||||||
|
identity = await adapter.verify_token("any-token")
|
||||||
|
assert identity.email == "explorer@cali.gov.co"
|
||||||
|
assert identity.provider_user_id == "mock-user-12345"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_mock_dev_adapter_custom_token():
|
||||||
|
adapter = MockDevAdapter()
|
||||||
|
identity = await adapter.verify_token("ana@gmail.com:Ana Gomez")
|
||||||
|
assert identity.email == "ana@gmail.com"
|
||||||
|
assert identity.name == "Ana Gomez"
|
||||||
|
assert identity.provider_user_id == "mock-ana@gmail.com"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_mock_dev_adapter_invalid_token():
|
||||||
|
adapter = MockDevAdapter()
|
||||||
|
with pytest.raises(ValueError, match="Invalid mock"):
|
||||||
|
await adapter.verify_token("invalid-token")
|
||||||
|
|
||||||
|
|
||||||
|
def test_auth_service_jwt_lifecycle():
|
||||||
|
auth_service = AuthService(provider=MockDevAdapter())
|
||||||
|
login_resp = auth_service.create_access_token(user_id="user-123", email="user@example.com")
|
||||||
|
|
||||||
|
assert login_resp.token_type == "Bearer"
|
||||||
|
assert login_resp.expires_in > 0
|
||||||
|
|
||||||
|
decoded = auth_service.decode_access_token(login_resp.access_token)
|
||||||
|
assert decoded["sub"] == "user-123"
|
||||||
|
assert decoded["email"] == "user@example.com"
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
from datetime import UTC, datetime
|
||||||
|
|
||||||
|
from api.services.consensus import (
|
||||||
|
ConsensusDecision,
|
||||||
|
SightingReport,
|
||||||
|
adjust_trust_score,
|
||||||
|
evaluate_reports,
|
||||||
|
haversine_distance_meters,
|
||||||
|
verify_velocity,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_haversine_distance():
|
||||||
|
# Distance between two nearby points on Boulevard del Río (~160 meters)
|
||||||
|
lat1, lon1 = 3.450143, -76.533282
|
||||||
|
lat2, lon2 = 3.451600, -76.532600
|
||||||
|
dist = haversine_distance_meters(lat1, lon1, lat2, lon2)
|
||||||
|
assert 150 < dist < 180
|
||||||
|
|
||||||
|
|
||||||
|
def test_verify_velocity_plausible():
|
||||||
|
# 200 meters in 60 seconds = 12 km/h (plausible walking/running speed)
|
||||||
|
t1 = datetime(2026, 10, 13, 10, 0, 0, tzinfo=UTC)
|
||||||
|
t2 = datetime(2026, 10, 13, 10, 1, 0, tzinfo=UTC)
|
||||||
|
lat1, lon1 = 3.450143, -76.533282
|
||||||
|
lat2, lon2 = 3.451600, -76.532600
|
||||||
|
|
||||||
|
assert verify_velocity(lat1, lon1, t1, lat2, lon2, t2, max_kmh=120.0) is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_verify_velocity_teleportation_rejected():
|
||||||
|
# 5 km in 10 seconds = 1800 km/h (impossible, GPS spoofing)
|
||||||
|
t1 = datetime(2026, 10, 13, 10, 0, 0, tzinfo=UTC)
|
||||||
|
t2 = datetime(2026, 10, 13, 10, 0, 10, tzinfo=UTC)
|
||||||
|
lat1, lon1 = 3.450143, -76.533282
|
||||||
|
lat2, lon2 = 3.490000, -76.533282
|
||||||
|
|
||||||
|
assert verify_velocity(lat1, lon1, t1, lat2, lon2, t2, max_kmh=120.0) is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_evaluate_reports_auto_approve():
|
||||||
|
# 4 distinct high-trust users reporting 'moved' within 10 meters of each other
|
||||||
|
now = datetime.now(UTC)
|
||||||
|
reports = [
|
||||||
|
SightingReport(
|
||||||
|
reporter_id=f"user-{i}",
|
||||||
|
latitude=3.45160 + (i * 0.00005),
|
||||||
|
longitude=-76.53260,
|
||||||
|
reported_status="moved",
|
||||||
|
trust_score=0.9,
|
||||||
|
created_at=now,
|
||||||
|
)
|
||||||
|
for i in range(4)
|
||||||
|
]
|
||||||
|
|
||||||
|
result = evaluate_reports(reports)
|
||||||
|
assert result.decision == ConsensusDecision.AUTO_APPROVE
|
||||||
|
assert result.distinct_reporters == 4
|
||||||
|
assert result.consensus_status == "moved"
|
||||||
|
assert result.confidence_score >= 3.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_evaluate_reports_pending_moderation():
|
||||||
|
# 2 users with moderate trust (total confidence ~1.6 < 3.0 threshold)
|
||||||
|
now = datetime.now(UTC)
|
||||||
|
reports = [
|
||||||
|
SightingReport(
|
||||||
|
reporter_id="user-1",
|
||||||
|
latitude=3.45160,
|
||||||
|
longitude=-76.53260,
|
||||||
|
reported_status="missing",
|
||||||
|
trust_score=0.8,
|
||||||
|
created_at=now,
|
||||||
|
),
|
||||||
|
SightingReport(
|
||||||
|
reporter_id="user-2",
|
||||||
|
latitude=3.45161,
|
||||||
|
longitude=-76.53261,
|
||||||
|
reported_status="missing",
|
||||||
|
trust_score=0.8,
|
||||||
|
created_at=now,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
result = evaluate_reports(reports)
|
||||||
|
assert result.decision == ConsensusDecision.PENDING_MODERATION
|
||||||
|
assert result.distinct_reporters == 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_adjust_trust_score_bounds():
|
||||||
|
# Boost clamping
|
||||||
|
assert adjust_trust_score(0.98, verified_positive=True, boost=0.05) == 1.0
|
||||||
|
|
||||||
|
# Penalty clamping
|
||||||
|
assert adjust_trust_score(0.10, verified_positive=False, penalty=0.15) == 0.0
|
||||||
|
|
||||||
|
# Normal increment
|
||||||
|
assert adjust_trust_score(0.50, verified_positive=True, boost=0.05) == 0.55
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import uuid
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
|
from api.models.checkin import CheckInResponse
|
||||||
|
from api.models.sculpture import Sculpture, SculptureDetails, SculptureStatus
|
||||||
|
from api.models.ticket import ReportVerificationRequest, Ticket, TicketStatus
|
||||||
|
from api.models.user import User
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_model_valid():
|
||||||
|
user = User(
|
||||||
|
id=uuid.uuid4(),
|
||||||
|
name="María del Rosario",
|
||||||
|
email="maria@example.com",
|
||||||
|
trust_score=0.8,
|
||||||
|
captured_count=5,
|
||||||
|
)
|
||||||
|
assert user.name == "María del Rosario"
|
||||||
|
assert user.trust_score == 0.8
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_model_invalid_trust_score():
|
||||||
|
with pytest.raises(ValidationError):
|
||||||
|
User(
|
||||||
|
id=uuid.uuid4(),
|
||||||
|
name="Test",
|
||||||
|
email="test@example.com",
|
||||||
|
trust_score=1.5, # Exceeds 1.0 limit
|
||||||
|
captured_count=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sculpture_model_valid():
|
||||||
|
sculpture = Sculpture(
|
||||||
|
id=uuid.uuid4(),
|
||||||
|
name="La Gata Ilustrada",
|
||||||
|
artist="Lucy Tejada",
|
||||||
|
year=2006,
|
||||||
|
latitude=3.4516,
|
||||||
|
longitude=-76.5326,
|
||||||
|
status=SculptureStatus.ON_SITE,
|
||||||
|
)
|
||||||
|
assert sculpture.name == "La Gata Ilustrada"
|
||||||
|
assert sculpture.status == SculptureStatus.ON_SITE
|
||||||
|
|
||||||
|
|
||||||
|
def test_sculpture_details_inheritance():
|
||||||
|
details = SculptureDetails(
|
||||||
|
id=uuid.uuid4(),
|
||||||
|
name="La Novia Dulce",
|
||||||
|
artist="Lorena Espitia",
|
||||||
|
year=2006,
|
||||||
|
latitude=3.4501,
|
||||||
|
longitude=-76.5332,
|
||||||
|
status=SculptureStatus.ON_SITE,
|
||||||
|
description="Sculpture decorated with sweets.",
|
||||||
|
audio_url="https://cdn.gatos.cali.gov.co/audio/novia.mp3", # type: ignore[arg-type]
|
||||||
|
unlocked_content="Cultural history unlocked.",
|
||||||
|
)
|
||||||
|
assert str(details.audio_url) == "https://cdn.gatos.cali.gov.co/audio/novia.mp3"
|
||||||
|
|
||||||
|
|
||||||
|
def test_checkin_similarity_bounds():
|
||||||
|
with pytest.raises(ValidationError):
|
||||||
|
CheckInResponse(
|
||||||
|
success=True,
|
||||||
|
similarity_score=1.2, # Exceeds 1.0 limit
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_ticket_model_and_verification():
|
||||||
|
ticket_id = uuid.uuid4()
|
||||||
|
reporter_id = uuid.uuid4()
|
||||||
|
sculpture_id = uuid.uuid4()
|
||||||
|
|
||||||
|
ticket = Ticket(
|
||||||
|
id=ticket_id,
|
||||||
|
reporter_id=reporter_id,
|
||||||
|
sculpture_id=sculpture_id,
|
||||||
|
latitude=3.45,
|
||||||
|
longitude=-76.53,
|
||||||
|
reported_status=SculptureStatus.MOVED,
|
||||||
|
status=TicketStatus.PENDING,
|
||||||
|
created_at="2026-10-13T10:00:00Z", # type: ignore[arg-type]
|
||||||
|
)
|
||||||
|
assert ticket.status == TicketStatus.PENDING
|
||||||
|
|
||||||
|
req = ReportVerificationRequest(
|
||||||
|
status=TicketStatus.APPROVED, notes="Verified by site inspection"
|
||||||
|
)
|
||||||
|
assert req.status == TicketStatus.APPROVED
|
||||||
Generated
+1048
File diff suppressed because it is too large.
Load diff
+410
@@ -0,0 +1,410 @@
|
|||||||
|
// Mock data matching Pydantic / OpenAPI schema requirements
|
||||||
|
const SCULPTURES_DATA = [
|
||||||
|
{
|
||||||
|
id: "234e5678-e89b-12d3-a456-426614174001",
|
||||||
|
name: "La Novia Dulce",
|
||||||
|
artist: "Lorena Espitia",
|
||||||
|
year: 2006,
|
||||||
|
latitude: 3.450143,
|
||||||
|
longitude: -76.533282,
|
||||||
|
status: "on-site",
|
||||||
|
image: "assets/la_novia_dulce.png",
|
||||||
|
description: "Decorated with sweets and candies representing Cali's culinary traditions. This bride is a homage to the traditional 'Macetas' given to godchildren every June.",
|
||||||
|
unlocked_content: "Cultural Oracle Insight: Lorena Espitia used bright fiberglass modeling to create a tactile sense of Colombian sugar candies. The sculpture is traditionally positioned near the river to evoke Cali's warm breeze carrying sweet aromas.",
|
||||||
|
captured: false,
|
||||||
|
audio_url: "https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "234e5678-e89b-12d3-a456-426614174002",
|
||||||
|
name: "La Gata Ceremonial",
|
||||||
|
artist: "José Horacio Martínez",
|
||||||
|
year: 2006,
|
||||||
|
latitude: 3.451600,
|
||||||
|
longitude: -76.532600,
|
||||||
|
status: "moved",
|
||||||
|
image: "assets/la_gata_ceremonial.png",
|
||||||
|
description: "A dark sculpture featuring intricate pre-Columbian gold patterns. It represents the ancestral heritage, jaguar spirits, and mythological elements of Southwest Colombia.",
|
||||||
|
unlocked_content: "Cultural Oracle Insight: The gold motifs are inspired by Calima culture gold artifacts. Its temporary relocation due to civic repairs on the Boulevard has triggered consensus recalculation, verifying its new spot 150m north.",
|
||||||
|
captured: false,
|
||||||
|
audio_url: "https://cdn.gatos.cali.gov.co/audio/gata_ceremonial.mp3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "234e5678-e89b-12d3-a456-426614174003",
|
||||||
|
name: "La Gata Ilustrada",
|
||||||
|
artist: "Lucy Tejada",
|
||||||
|
year: 2006,
|
||||||
|
latitude: 3.452600,
|
||||||
|
longitude: -76.532000,
|
||||||
|
status: "on-site",
|
||||||
|
image: "assets/la_gata_ilustrada.png",
|
||||||
|
description: "A whimsical tribute decorated with open books, flying musical notes, and colorful abstract silhouettes of dancing people. Created by the pioneer female artist Lucy Tejada.",
|
||||||
|
unlocked_content: "Cultural Oracle Insight: Lucy Tejada painted this cat as a reminder of Cali's literary and artistic renaissance in the mid-20th century. It features references to the Cali Group writers and traditional local salsa music.",
|
||||||
|
captured: false,
|
||||||
|
audio_url: "https://cdn.gatos.cali.gov.co/audio/gata_ilustrada.mp3"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
let map;
|
||||||
|
let markers = [];
|
||||||
|
let selectedSculpture = null;
|
||||||
|
let currentFilter = 'all';
|
||||||
|
|
||||||
|
// Initialize Map
|
||||||
|
function initMap() {
|
||||||
|
// Center on Cali Gato monument area
|
||||||
|
map = L.map('map', {
|
||||||
|
zoomControl: false,
|
||||||
|
attributionControl: false
|
||||||
|
}).setView([3.4516, -76.5325], 16);
|
||||||
|
|
||||||
|
// Add zoom control at bottom-right
|
||||||
|
L.control.zoom({
|
||||||
|
position: 'bottomright'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
// CartoDB Dark Matter tiles
|
||||||
|
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
||||||
|
maxZoom: 20
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
renderMarkers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Leaflet Markers
|
||||||
|
function renderMarkers() {
|
||||||
|
// Clear existing markers
|
||||||
|
markers.forEach(marker => map.removeLayer(marker));
|
||||||
|
markers = [];
|
||||||
|
|
||||||
|
SCULPTURES_DATA.forEach(sculpture => {
|
||||||
|
// Skip if doesn't match filter
|
||||||
|
if (currentFilter !== 'all' && sculpture.status !== currentFilter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Custom glowing icon
|
||||||
|
const customIcon = L.divIcon({
|
||||||
|
html: `<div class="custom-pin">
|
||||||
|
<div class="pin-glow status-${sculpture.status}"></div>
|
||||||
|
</div>`,
|
||||||
|
className: 'leaflet-custom-marker-wrapper',
|
||||||
|
iconSize: [24, 24],
|
||||||
|
iconAnchor: [12, 12]
|
||||||
|
});
|
||||||
|
|
||||||
|
const marker = L.marker([sculpture.latitude, sculpture.longitude], { icon: customIcon })
|
||||||
|
.addTo(map)
|
||||||
|
.on('click', () => {
|
||||||
|
selectSculpture(sculpture);
|
||||||
|
map.setView([sculpture.latitude, sculpture.longitude], 17, { animate: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
markers.push(marker);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Sculpture Cards in List
|
||||||
|
function renderCards() {
|
||||||
|
const container = document.getElementById('cards-container');
|
||||||
|
container.innerHTML = '';
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
SCULPTURES_DATA.forEach(sculpture => {
|
||||||
|
if (currentFilter !== 'all' && sculpture.status !== currentFilter) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
|
const card = document.createElement('div');
|
||||||
|
card.className = `sculpture-card ${selectedSculpture && selectedSculpture.id === sculpture.id ? 'selected' : ''}`;
|
||||||
|
card.innerHTML = `
|
||||||
|
<img src="${sculpture.image}" alt="${sculpture.name}" class="card-thumb">
|
||||||
|
<div class="card-info">
|
||||||
|
<span class="card-title">${sculpture.name}</span>
|
||||||
|
<span class="card-artist">${sculpture.artist}</span>
|
||||||
|
<div style="display: flex; gap: 8px; align-items: center; margin-top: 4px;">
|
||||||
|
<span class="status-badge status-${sculpture.status}">${capitalize(sculpture.status)}</span>
|
||||||
|
${sculpture.captured ? '<span class="status-badge status-on-site" style="background:rgba(16,185,129,0.1);"><i class="fa-solid fa-circle-check"></i> Captured</span>' : ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
card.addEventListener('click', () => {
|
||||||
|
selectSculpture(sculpture);
|
||||||
|
map.setView([sculpture.latitude, sculpture.longitude], 17, { animate: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
container.appendChild(card);
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('list-count').textContent = `${count} matching`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select a sculpture & display detail view
|
||||||
|
function selectSculpture(sculpture) {
|
||||||
|
selectedSculpture = sculpture;
|
||||||
|
|
||||||
|
// Toggle sidebar panel views
|
||||||
|
document.getElementById('sidebar-default').style.display = 'none';
|
||||||
|
document.getElementById('sidebar-detail').style.display = 'flex';
|
||||||
|
|
||||||
|
// Fill in data
|
||||||
|
document.getElementById('detail-img').src = sculpture.image;
|
||||||
|
document.getElementById('detail-title').textContent = sculpture.name;
|
||||||
|
document.getElementById('detail-artist').textContent = sculpture.artist;
|
||||||
|
document.getElementById('detail-year').textContent = sculpture.year;
|
||||||
|
document.getElementById('detail-desc').textContent = sculpture.description;
|
||||||
|
|
||||||
|
const statusBadge = document.getElementById('detail-status');
|
||||||
|
statusBadge.className = `status-badge status-${sculpture.status}`;
|
||||||
|
statusBadge.textContent = capitalize(sculpture.status);
|
||||||
|
|
||||||
|
// Render Lock/Unlock Checkin box
|
||||||
|
renderCheckInArea(sculpture);
|
||||||
|
|
||||||
|
// Update card selected status
|
||||||
|
renderCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Lock check-in box based on captured state
|
||||||
|
function renderCheckInArea(sculpture) {
|
||||||
|
const container = document.getElementById('checkin-container');
|
||||||
|
container.innerHTML = '';
|
||||||
|
|
||||||
|
if (sculpture.captured) {
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="unlocked-box">
|
||||||
|
<div class="unlocked-header">
|
||||||
|
<i class="fa-solid fa-lock-open"></i> Sighting Captured & Unlocked
|
||||||
|
</div>
|
||||||
|
<p>${sculpture.unlocked_content}</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="locked-box">
|
||||||
|
<p style="margin-bottom: 12px; color: var(--text-secondary);">
|
||||||
|
<i class="fa-solid fa-lock" style="margin-right: 6px;"></i>
|
||||||
|
Historical insights & media are locked. Capture this Gata on-site to unlock.
|
||||||
|
</p>
|
||||||
|
<button class="checkin-btn" id="start-checkin-btn" style="width: 100%;">
|
||||||
|
<i class="fa-solid fa-camera"></i> Verify Sighting (Check-in)
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.getElementById('start-checkin-btn').addEventListener('click', () => {
|
||||||
|
triggerCheckInSimulation(sculpture);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger Checkin Modal simulation
|
||||||
|
function triggerCheckInSimulation(sculpture) {
|
||||||
|
const modal = document.getElementById('checkin-modal');
|
||||||
|
const viewImg = document.getElementById('viewfinder-img');
|
||||||
|
const modalTitle = document.getElementById('modal-sculpture-title');
|
||||||
|
const logs = document.getElementById('scan-logs');
|
||||||
|
|
||||||
|
modalTitle.textContent = `Verifying ${sculpture.name}`;
|
||||||
|
viewImg.src = sculpture.image;
|
||||||
|
logs.innerHTML = '';
|
||||||
|
|
||||||
|
// Show modal
|
||||||
|
modal.classList.add('active');
|
||||||
|
|
||||||
|
// Logs sequence simulation
|
||||||
|
const steps = [
|
||||||
|
{ text: '[INIT] Contacting Hybrid Recognition Service...', delay: 0 },
|
||||||
|
{ text: '[GPS] Acquiring coordinates: latitude: ' + sculpture.latitude.toFixed(4) + ', longitude: ' + sculpture.longitude.toFixed(4) + '...', delay: 600 },
|
||||||
|
{ text: '[GPS] Lock established. Within 2.4 meters threshold.', delay: 1200, success: true },
|
||||||
|
{ text: '[VISION] Comparing photo vector embeddings with pgvector dataset...', delay: 1800 },
|
||||||
|
{ text: '[VISION] Match found. Similarity threshold: 0.941 > 0.85.', delay: 2400, success: true },
|
||||||
|
{ text: '[ORACLE] Consensus engine: Verification success.', delay: 3000 }
|
||||||
|
];
|
||||||
|
|
||||||
|
steps.forEach(step => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const entry = document.createElement('div');
|
||||||
|
entry.className = 'log-entry';
|
||||||
|
|
||||||
|
let icon = '';
|
||||||
|
if (step.success !== undefined) {
|
||||||
|
icon = step.success ? '<i class="fa-solid fa-circle-check" style="color:var(--success-color);"></i>' : '<i class="fa-solid fa-circle-xmark" style="color:var(--danger-color);"></i>';
|
||||||
|
} else {
|
||||||
|
icon = '<div class="log-spinner"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's a loading log, remove spinner from previous logs
|
||||||
|
const spinners = logs.querySelectorAll('.log-spinner');
|
||||||
|
spinners.forEach(s => s.replaceWith(document.createTextNode('✓')));
|
||||||
|
|
||||||
|
entry.innerHTML = `${icon} <span>${step.text}</span>`;
|
||||||
|
logs.appendChild(entry);
|
||||||
|
|
||||||
|
// Auto-scroll logs
|
||||||
|
logs.scrollTop = logs.scrollHeight;
|
||||||
|
}, step.delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
// End of simulation -> Show Success card
|
||||||
|
setTimeout(() => {
|
||||||
|
renderSuccessScreen(sculpture);
|
||||||
|
}, 3800);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render Success screen in modal body
|
||||||
|
function renderSuccessScreen(sculpture) {
|
||||||
|
const modalBody = document.getElementById('modal-body-content');
|
||||||
|
|
||||||
|
// Save original body to restore later
|
||||||
|
if (!window.originalModalBodyHTML) {
|
||||||
|
window.originalModalBodyHTML = modalBody.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trigger Canvas Confetti
|
||||||
|
triggerConfetti();
|
||||||
|
|
||||||
|
modalBody.innerHTML = `
|
||||||
|
<div class="success-card">
|
||||||
|
<div class="success-icon">
|
||||||
|
<i class="fa-solid fa-cat"></i>
|
||||||
|
</div>
|
||||||
|
<h2 class="success-title">Sighting Validated!</h2>
|
||||||
|
<div class="success-badge-reward">
|
||||||
|
<i class="fa-solid fa-award"></i>
|
||||||
|
<span>Unlocked Badge: ${sculpture.name} Capture</span>
|
||||||
|
</div>
|
||||||
|
<div class="similarity-metric">
|
||||||
|
Recognition Match Score: <span class="val">94.1%</span>
|
||||||
|
</div>
|
||||||
|
<p style="font-size: 0.85rem; color: var(--text-secondary); max-width: 320px; line-height: 1.4;">
|
||||||
|
GPS proximity and vector identity matching completed. Trust score validated. Cultural Oracle content unlocked!
|
||||||
|
</p>
|
||||||
|
<button class="close-success-btn" id="finish-checkin-btn">
|
||||||
|
Access Cultural Content
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.getElementById('finish-checkin-btn').addEventListener('click', () => {
|
||||||
|
// Capture state update
|
||||||
|
sculpture.captured = true;
|
||||||
|
updateCapturedStats();
|
||||||
|
|
||||||
|
// Close modal & reset layout
|
||||||
|
closeCheckInModal();
|
||||||
|
|
||||||
|
// Refresh detail view
|
||||||
|
selectSculpture(sculpture);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeCheckInModal() {
|
||||||
|
const modal = document.getElementById('checkin-modal');
|
||||||
|
modal.classList.remove('active');
|
||||||
|
|
||||||
|
// Restore original body structure after transition completes
|
||||||
|
setTimeout(() => {
|
||||||
|
const modalBody = document.getElementById('modal-body-content');
|
||||||
|
if (window.originalModalBodyHTML) {
|
||||||
|
modalBody.innerHTML = window.originalModalBodyHTML;
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateCapturedStats() {
|
||||||
|
const count = SCULPTURES_DATA.filter(s => s.captured).length;
|
||||||
|
document.getElementById('captured-count').textContent = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerConfetti() {
|
||||||
|
const duration = 2 * 1000;
|
||||||
|
const end = Date.now() + duration;
|
||||||
|
|
||||||
|
(function frame() {
|
||||||
|
confetti({
|
||||||
|
particleCount: 3,
|
||||||
|
angle: 60,
|
||||||
|
spread: 55,
|
||||||
|
origin: { x: 0 },
|
||||||
|
colors: ['#ff5e62', '#ff9966', '#10b981']
|
||||||
|
});
|
||||||
|
confetti({
|
||||||
|
particleCount: 3,
|
||||||
|
angle: 120,
|
||||||
|
spread: 55,
|
||||||
|
origin: { x: 1 },
|
||||||
|
colors: ['#ff5e62', '#ff9966', '#10b981']
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Date.now() < end) {
|
||||||
|
requestAnimationFrame(frame);
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility Helper
|
||||||
|
function capitalize(s) {
|
||||||
|
if (typeof s !== 'string') return '';
|
||||||
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event Listeners
|
||||||
|
document.getElementById('detail-back-btn').addEventListener('click', () => {
|
||||||
|
document.getElementById('sidebar-detail').style.display = 'none';
|
||||||
|
document.getElementById('sidebar-default').style.display = 'flex';
|
||||||
|
selectedSculpture = null;
|
||||||
|
renderCards();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('close-modal').addEventListener('click', closeCheckInModal);
|
||||||
|
|
||||||
|
// Filter pills interaction
|
||||||
|
document.querySelectorAll('.filter-pill').forEach(pill => {
|
||||||
|
pill.addEventListener('click', (e) => {
|
||||||
|
document.querySelectorAll('.filter-pill').forEach(p => p.classList.remove('active'));
|
||||||
|
e.target.classList.add('active');
|
||||||
|
|
||||||
|
currentFilter = e.target.dataset.status;
|
||||||
|
renderCards();
|
||||||
|
renderMarkers();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Audio Player Mock toggle play
|
||||||
|
let audioPlaying = false;
|
||||||
|
document.getElementById('audio-play').addEventListener('click', (e) => {
|
||||||
|
const icon = e.currentTarget.querySelector('i');
|
||||||
|
const progressBar = document.querySelector('.audio-progress-bar');
|
||||||
|
|
||||||
|
if (audioPlaying) {
|
||||||
|
icon.className = 'fa-solid fa-play';
|
||||||
|
audioPlaying = false;
|
||||||
|
progressBar.style.animation = 'none';
|
||||||
|
} else {
|
||||||
|
icon.className = 'fa-solid fa-pause';
|
||||||
|
audioPlaying = true;
|
||||||
|
// Simulate progression bar movement
|
||||||
|
progressBar.style.animation = 'audioPlaySim 133s linear infinite';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add dynamic CSS style for simulating audio player progress bar
|
||||||
|
const audioStyle = document.createElement('style');
|
||||||
|
audioStyle.innerHTML = `
|
||||||
|
@keyframes audioPlaySim {
|
||||||
|
0% { width: 35%; }
|
||||||
|
100% { width: 100%; }
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
document.head.appendChild(audioStyle);
|
||||||
|
|
||||||
|
// Load everything on startup
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
initMap();
|
||||||
|
renderCards();
|
||||||
|
updateCapturedStats();
|
||||||
|
});
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 947 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
+162
@@ -0,0 +1,162 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Novias del Gato - Cali Map Prototype</title>
|
||||||
|
<!-- Google Fonts -->
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<!-- FontAwesome -->
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
|
<!-- Leaflet CSS -->
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
|
||||||
|
<!-- Custom CSS -->
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<header>
|
||||||
|
<div class="logo-container">
|
||||||
|
<div class="logo-icon">
|
||||||
|
<i class="fa-solid fa-cat"></i>
|
||||||
|
</div>
|
||||||
|
<div class="logo-text">
|
||||||
|
<h1>Novias del Gato</h1>
|
||||||
|
<p>Geographic Cultural Oracle</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="header-stats">
|
||||||
|
<div class="stat-badge">
|
||||||
|
<i class="fa-solid fa-trophy"></i>
|
||||||
|
<span>Captured: <span id="captured-count" class="val">0</span>/3</span>
|
||||||
|
</div>
|
||||||
|
<div class="stat-badge">
|
||||||
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
|
<span>Trust Score: <span class="val">0.85</span></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<!-- Main Wrapper -->
|
||||||
|
<div class="main-wrapper">
|
||||||
|
<!-- Sidebar -->
|
||||||
|
<div class="sidebar" id="sidebar">
|
||||||
|
<div class="sidebar-content" id="sidebar-default">
|
||||||
|
<!-- Search & Filter -->
|
||||||
|
<div class="filter-section">
|
||||||
|
<span class="filter-title">Filter Sculptures</span>
|
||||||
|
<div class="filter-pills">
|
||||||
|
<button class="filter-pill active" data-status="all">All</button>
|
||||||
|
<button class="filter-pill" data-status="on-site">On-Site</button>
|
||||||
|
<button class="filter-pill" data-status="moved">Moved</button>
|
||||||
|
<button class="filter-pill" data-status="missing">Missing</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- List Section -->
|
||||||
|
<div class="sculptures-list">
|
||||||
|
<div class="list-header">
|
||||||
|
<h3>Sculptures in Cali</h3>
|
||||||
|
<span id="list-count" style="font-size: 0.8rem; color: var(--text-secondary)">3 total</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="cards-container">
|
||||||
|
<!-- Dynamic cards will go here -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Detail View (hidden by default) -->
|
||||||
|
<div class="sidebar-content detail-panel" id="sidebar-detail" style="display: none;">
|
||||||
|
<button class="back-btn" id="detail-back-btn">
|
||||||
|
<i class="fa-solid fa-arrow-left"></i> Back to catalog
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="detail-img-container">
|
||||||
|
<img src="" alt="Sculpture Image" class="detail-img" id="detail-img">
|
||||||
|
<div class="detail-overlay">
|
||||||
|
<div>
|
||||||
|
<h2 class="detail-title" id="detail-title">La Novia Dulce</h2>
|
||||||
|
<span class="status-badge" id="detail-status">On-Site</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="detail-meta">
|
||||||
|
<div class="meta-row">
|
||||||
|
<span class="meta-label">Artist</span>
|
||||||
|
<span class="meta-val" id="detail-artist">Lorena Espitia</span>
|
||||||
|
</div>
|
||||||
|
<div class="meta-row">
|
||||||
|
<span class="meta-label">Year Installed</span>
|
||||||
|
<span class="meta-val" id="detail-year">2006</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="detail-desc" id="detail-desc">
|
||||||
|
Decorated with sweets and candies representing Cali's culinary traditions.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Audio Player Mock -->
|
||||||
|
<div class="audio-player-mock">
|
||||||
|
<button class="audio-play-btn" id="audio-play">
|
||||||
|
<i class="fa-solid fa-play"></i>
|
||||||
|
</button>
|
||||||
|
<div class="audio-progress">
|
||||||
|
<div class="audio-progress-bar"></div>
|
||||||
|
</div>
|
||||||
|
<span class="audio-time">0:42 / 2:15</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Locked / Unlocked Content -->
|
||||||
|
<div id="checkin-container">
|
||||||
|
<!-- Will render locked box or unlocked content -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Map Area -->
|
||||||
|
<div class="map-container">
|
||||||
|
<div id="map"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Camera Viewfinder Modal -->
|
||||||
|
<div class="modal-overlay" id="checkin-modal">
|
||||||
|
<div class="modal-card">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h3 id="modal-sculpture-title">Simulating Check-in</h3>
|
||||||
|
<button class="close-modal-btn" id="close-modal">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="modal-body-content">
|
||||||
|
<!-- Viewfinder -->
|
||||||
|
<div class="viewfinder-container">
|
||||||
|
<img src="" alt="Viewfinder Capture" class="viewfinder-img" id="viewfinder-img">
|
||||||
|
<div class="viewfinder-scanlines"></div>
|
||||||
|
<div class="viewfinder-line"></div>
|
||||||
|
<div class="viewfinder-corners"></div>
|
||||||
|
<div class="viewfinder-corners-2"></div>
|
||||||
|
|
||||||
|
<div class="gps-lock-status">
|
||||||
|
<i class="fa-solid fa-location-dot"></i> GPS Proximity Lock (1.2m)
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Scanning logs -->
|
||||||
|
<div class="scan-logs" id="scan-logs">
|
||||||
|
<!-- Logs will print dynamically -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Leaflet JS -->
|
||||||
|
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||||
|
<!-- Confetti JS -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.6.0/dist/confetti.browser.min.js"></script>
|
||||||
|
<!-- Custom JS -->
|
||||||
|
<script src="app.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+918
@@ -0,0 +1,918 @@
|
|||||||
|
/* Style Sheet for Novias del Gato UI Demo */
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--bg-color: #0d0e12;
|
||||||
|
--surface-color: rgba(20, 22, 31, 0.75);
|
||||||
|
--surface-border: rgba(255, 255, 255, 0.08);
|
||||||
|
--text-primary: #f3f4f6;
|
||||||
|
--text-secondary: #9ca3af;
|
||||||
|
--primary-gradient: linear-gradient(135deg, #ff5e62 0%, #ff9966 100%);
|
||||||
|
--accent-color: #ff7e5f;
|
||||||
|
--success-color: #10b981;
|
||||||
|
--warning-color: #f59e0b;
|
||||||
|
--danger-color: #ef4444;
|
||||||
|
--font-family: 'Outfit', sans-serif;
|
||||||
|
--shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
|
||||||
|
--transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
--transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: var(--font-family);
|
||||||
|
background-color: var(--bg-color);
|
||||||
|
color: var(--text-primary);
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Header */
|
||||||
|
header {
|
||||||
|
height: 70px;
|
||||||
|
background: rgba(13, 14, 18, 0.85);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
border-bottom: 1px solid var(--surface-border);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 24px;
|
||||||
|
z-index: 1000;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-icon {
|
||||||
|
background: var(--primary-gradient);
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
box-shadow: 0 4px 15px rgba(255, 94, 98, 0.3);
|
||||||
|
animation: float 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-text h1 {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
background: var(--primary-gradient);
|
||||||
|
-webkit-background-clip: text;
|
||||||
|
-webkit-text-fill-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo-text p {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-weight: 400;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-stats {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-badge {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
padding: 8px 14px;
|
||||||
|
border-radius: 20px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-badge i {
|
||||||
|
color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-badge .val {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main Container */
|
||||||
|
.main-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
height: calc(100vh - 70px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sidebar */
|
||||||
|
.sidebar {
|
||||||
|
width: 400px;
|
||||||
|
background: var(--surface-color);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
-webkit-backdrop-filter: blur(20px);
|
||||||
|
border-right: 1px solid var(--surface-border);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
z-index: 999;
|
||||||
|
transition: transform var(--transition-normal);
|
||||||
|
position: relative;
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-content {
|
||||||
|
flex: 1;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 24px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-content::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-content::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Filters */
|
||||||
|
.filter-section {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-title {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-pills {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-pill {
|
||||||
|
background: rgba(255, 255, 255, 0.04);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
color: var(--text-primary);
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 16px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition-fast);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-pill:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-pill.active {
|
||||||
|
background: var(--accent-color);
|
||||||
|
color: white;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
box-shadow: 0 4px 12px rgba(255, 126, 95, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sculpture List inside Sidebar */
|
||||||
|
.sculptures-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-header h3 {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sculpture-card {
|
||||||
|
background: rgba(255, 255, 255, 0.02);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition-fast);
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sculpture-card:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
transform: translateY(-2px);
|
||||||
|
border-color: rgba(255, 255, 255, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sculpture-card.selected {
|
||||||
|
background: rgba(255, 126, 95, 0.08);
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-thumb {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 8px;
|
||||||
|
object-fit: cover;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-artist {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-weight: 500;
|
||||||
|
width: fit-content;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge::before {
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-on-site {
|
||||||
|
background: rgba(16, 185, 129, 0.15);
|
||||||
|
color: var(--success-color);
|
||||||
|
}
|
||||||
|
.status-on-site::before { background: var(--success-color); }
|
||||||
|
|
||||||
|
.status-moved {
|
||||||
|
background: rgba(245, 158, 11, 0.15);
|
||||||
|
color: var(--warning-color);
|
||||||
|
}
|
||||||
|
.status-moved::before { background: var(--warning-color); }
|
||||||
|
|
||||||
|
.status-missing {
|
||||||
|
background: rgba(239, 68, 68, 0.15);
|
||||||
|
color: var(--danger-color);
|
||||||
|
}
|
||||||
|
.status-missing::before { background: var(--danger-color); }
|
||||||
|
|
||||||
|
/* Detail Panel Container (replacing list view on selection) */
|
||||||
|
.detail-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
animation: fadeIn 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.85rem;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
transition: color var(--transition-fast);
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.back-btn:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-img-container {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 220px;
|
||||||
|
border-radius: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-overlay {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
background: linear-gradient(to top, rgba(13, 14, 18, 0.95) 0%, rgba(13, 14, 18, 0) 100%);
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-title {
|
||||||
|
font-size: 1.3rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: white;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-subtitle {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||||
|
padding-bottom: 8px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta-label {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta-val {
|
||||||
|
color: white;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-desc {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unlocked-box {
|
||||||
|
background: rgba(16, 185, 129, 0.06);
|
||||||
|
border: 1px dashed rgba(16, 185, 129, 0.3);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: #a7f3d0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
animation: pulseGreen 2s infinite alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unlocked-header {
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: var(--success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.locked-box {
|
||||||
|
background: rgba(255, 255, 255, 0.02);
|
||||||
|
border: 1px dashed rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkin-btn {
|
||||||
|
background: var(--primary-gradient);
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 14px;
|
||||||
|
border-radius: 12px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
box-shadow: 0 4px 15px rgba(255, 94, 98, 0.3);
|
||||||
|
transition: all var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkin-btn:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 6px 20px rgba(255, 94, 98, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkin-btn:active {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Audio Player Mock */
|
||||||
|
.audio-player-mock {
|
||||||
|
background: rgba(255, 255, 255, 0.03);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-play-btn {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border: none;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-play-btn:hover {
|
||||||
|
background: var(--accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-progress {
|
||||||
|
flex: 1;
|
||||||
|
height: 4px;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 2px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-progress-bar {
|
||||||
|
width: 35%;
|
||||||
|
height: 100%;
|
||||||
|
background: var(--accent-color);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-time {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map Area */
|
||||||
|
.map-container {
|
||||||
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#map {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: #090a0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Custom Map Marker Glow */
|
||||||
|
.custom-pin {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pin-glow {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--accent-color);
|
||||||
|
box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
|
||||||
|
border: 2px solid white;
|
||||||
|
animation: glow 1.5s infinite alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pin-glow.status-on-site {
|
||||||
|
background: var(--success-color);
|
||||||
|
box-shadow: 0 0 10px var(--success-color), 0 0 20px var(--success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pin-glow.status-moved {
|
||||||
|
background: var(--warning-color);
|
||||||
|
box-shadow: 0 0 10px var(--warning-color), 0 0 20px var(--warning-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pin-glow.status-missing {
|
||||||
|
background: var(--danger-color);
|
||||||
|
box-shadow: 0 0 10px var(--danger-color), 0 0 20px var(--danger-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Viewfinder Modal (Check-in camera validation UI) */
|
||||||
|
.modal-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(9, 10, 15, 0.85);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
|
-webkit-backdrop-filter: blur(8px);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 2000;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-overlay.active {
|
||||||
|
opacity: 1;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-card {
|
||||||
|
width: 90%;
|
||||||
|
max-width: 440px;
|
||||||
|
background: #151722;
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
border-radius: 24px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
transform: scale(0.9);
|
||||||
|
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-overlay.active .modal-card {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header {
|
||||||
|
padding: 16px 20px;
|
||||||
|
border-bottom: 1px solid var(--surface-border);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-header h3 {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-modal-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 1.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-modal-btn:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
padding: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Camera Viewfinder Mock */
|
||||||
|
.viewfinder-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 280px;
|
||||||
|
background: #0d0e12;
|
||||||
|
border-radius: 16px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 2px solid rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
filter: blur(2px) brightness(0.6);
|
||||||
|
transition: filter 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-scanlines {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(
|
||||||
|
rgba(18, 16, 16, 0) 50%,
|
||||||
|
rgba(0, 0, 0, 0.25) 50%
|
||||||
|
);
|
||||||
|
background-size: 100% 4px;
|
||||||
|
z-index: 10;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-line {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 4px;
|
||||||
|
background: rgba(255, 94, 98, 0.7);
|
||||||
|
box-shadow: 0 0 10px rgba(255, 94, 98, 0.8);
|
||||||
|
z-index: 11;
|
||||||
|
animation: scan 2.5s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners {
|
||||||
|
position: absolute;
|
||||||
|
top: 15px;
|
||||||
|
left: 15px;
|
||||||
|
right: 15px;
|
||||||
|
bottom: 15px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners::before,
|
||||||
|
.viewfinder-corners::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners::before {
|
||||||
|
top: -2px;
|
||||||
|
left: -2px;
|
||||||
|
border-width: 2px 0 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners::after {
|
||||||
|
bottom: -2px;
|
||||||
|
right: -2px;
|
||||||
|
border-width: 0 2px 2px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Secondary corners using CSS hacks */
|
||||||
|
.viewfinder-corners-2 {
|
||||||
|
position: absolute;
|
||||||
|
top: 15px;
|
||||||
|
left: 15px;
|
||||||
|
right: 15px;
|
||||||
|
bottom: 15px;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners-2::before,
|
||||||
|
.viewfinder-corners-2::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-color: var(--accent-color);
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners-2::before {
|
||||||
|
top: -2px;
|
||||||
|
right: -2px;
|
||||||
|
border-width: 2px 2px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-corners-2::after {
|
||||||
|
bottom: -2px;
|
||||||
|
left: -2px;
|
||||||
|
border-width: 0 0 2px 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.viewfinder-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 15;
|
||||||
|
background: rgba(13, 14, 18, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gps-lock-status {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 25px;
|
||||||
|
left: 25px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
background: rgba(0, 0, 0, 0.6);
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid rgba(255,255,255,0.1);
|
||||||
|
color: var(--success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.gps-lock-status i {
|
||||||
|
animation: pulse 1s infinite alternate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Simulated Logs / Processes */
|
||||||
|
.scan-logs {
|
||||||
|
width: 100%;
|
||||||
|
background: #090a0f;
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 12px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #10b981;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-entry {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.log-spinner {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border: 2px solid transparent;
|
||||||
|
border-top-color: #10b981;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Success Card Content (replaced inside modal body upon validation success) */
|
||||||
|
.success-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
gap: 16px;
|
||||||
|
animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||||
|
padding: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-icon {
|
||||||
|
width: 72px;
|
||||||
|
height: 72px;
|
||||||
|
background: rgba(16, 185, 129, 0.1);
|
||||||
|
border: 2px solid var(--success-color);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: var(--success-color);
|
||||||
|
font-size: 2.2rem;
|
||||||
|
box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-title {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.success-badge-reward {
|
||||||
|
background: var(--primary-gradient);
|
||||||
|
color: white;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 600;
|
||||||
|
padding: 6px 14px;
|
||||||
|
border-radius: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
box-shadow: 0 4px 10px rgba(255, 94, 98, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.similarity-metric {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.similarity-metric .val {
|
||||||
|
color: var(--success-color);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-success-btn {
|
||||||
|
width: 100%;
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
border: 1px solid var(--surface-border);
|
||||||
|
color: white;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-family: var(--font-family);
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all var(--transition-fast);
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-success-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Animations */
|
||||||
|
@keyframes float {
|
||||||
|
0% { transform: translateY(0px); }
|
||||||
|
50% { transform: translateY(-5px); }
|
||||||
|
100% { transform: translateY(0px); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes glow {
|
||||||
|
from { box-shadow: 0 0 4px var(--accent-color), 0 0 8px var(--accent-color); }
|
||||||
|
to { box-shadow: 0 0 12px var(--accent-color), 0 0 24px var(--accent-color); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes scan {
|
||||||
|
0% { top: 0%; }
|
||||||
|
50% { top: 100%; }
|
||||||
|
100% { top: 0%; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
from { opacity: 0.4; }
|
||||||
|
to { opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulseGreen {
|
||||||
|
from { border-color: rgba(16, 185, 129, 0.2); }
|
||||||
|
to { border-color: rgba(16, 185, 129, 0.5); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateY(8px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes scaleUp {
|
||||||
|
from { transform: scale(0.85); opacity: 0; }
|
||||||
|
to { transform: scale(1); opacity: 1; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
services:
|
||||||
|
pg_database:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/postgres/Dockerfile
|
||||||
|
container_name: postgres_db
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
start_period: 5s
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4
|
||||||
|
container_name: pgadmin
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
|
||||||
|
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
|
||||||
|
ports:
|
||||||
|
- "5050:80"
|
||||||
|
depends_on:
|
||||||
|
- pg_database
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "wget", "-O", "-", "http://localhost:80/misc/ping"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
start_period: 5s
|
||||||
|
|
||||||
|
api:
|
||||||
|
build:
|
||||||
|
context: ./
|
||||||
|
dockerfile: api/Dockerfile
|
||||||
|
container_name: fastapi_api
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- DATABASE_URL=postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@pg_database:5432/${POSTGRES_DB}
|
||||||
|
- JWT_SECRET=${JWT_SECRET}
|
||||||
|
- JWT_ALGORITHM=${JWT_ALGORITHM}
|
||||||
|
- ACCESS_TOKEN_EXPIRE_MINUTES=${ACCESS_TOKEN_EXPIRE_MINUTES}
|
||||||
|
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID}
|
||||||
|
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET}
|
||||||
|
- GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI}
|
||||||
|
depends_on:
|
||||||
|
pg_database:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
ui:
|
||||||
|
build:
|
||||||
|
context: ./
|
||||||
|
dockerfile: ui/Dockerfile
|
||||||
|
container_name: nginx_ui
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
depends_on:
|
||||||
|
- api
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM postgis/postgis:17-3.5
|
||||||
|
|
||||||
|
# Install build dependencies and pgvector
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
postgresql-17-pgvector || \
|
||||||
|
(apt-get install -y --no-install-recommends git build-essential postgresql-server-dev-17 && \
|
||||||
|
cd /tmp && \
|
||||||
|
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
|
||||||
|
cd pgvector && \
|
||||||
|
make && \
|
||||||
|
make install && \
|
||||||
|
apt-get remove -y git build-essential postgresql-server-dev-17 && \
|
||||||
|
apt-get autoremove -y && \
|
||||||
|
rm -rf /tmp/pgvector) && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY docker/postgres/init-extensions.sql /docker-entrypoint-initdb.d/01-init-extensions.sql
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- Initialize core extensions required by Novias del Gato
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vector;
|
||||||
+30
-9
@@ -18,32 +18,53 @@
|
|||||||
* **API / Contract:** OpenAPI (Swagger).
|
* **API / Contract:** OpenAPI (Swagger).
|
||||||
* **Database:** PostgreSQL + PostGIS (Spatial data).
|
* **Database:** PostgreSQL + PostGIS (Spatial data).
|
||||||
* **Vector Search Engine:** `pgvector` (PostgreSQL extension) for storing and comparing image embeddings.
|
* **Vector Search Engine:** `pgvector` (PostgreSQL extension) for storing and comparing image embeddings.
|
||||||
* **Backend:** Python (FastAPI) for high-performance concurrency and vision model integration.
|
* **Backend:** Python (FastAPI) for high-performance concurrency, business logic, and spatial/vector database routing.
|
||||||
* **Identity (Auth):** Google OAuth + JWT.
|
* **Identity (Auth):** Google OAuth + JWT.
|
||||||
* **Frontend:** Next.js (PWA) using WebXR/Camera APIs for the Visual Check-in experience.
|
* **Frontend:** Next.js (PWA) using WebXR/Camera APIs for the Visual Check-in experience.
|
||||||
* **Infrastructure:** Docker / Modular Monolith.
|
* **Infrastructure:** Docker / Modular Monolith.
|
||||||
|
|
||||||
## Logical Services
|
## Logical Services
|
||||||
|
|
||||||
### 1. Identity & Profile Service
|
### 1. Identity & Profile Service (SSO Adapter Architecture)
|
||||||
Manages user lifecycle, SSO, and the `trust_score` used by the reputation engine.
|
Manages user lifecycle and authentication via a pluggable Identity Provider adapter (`IdentityProvider` protocol).
|
||||||
|
- **Core Interface**: Decoupled from specific OAuth vendors via `verify_token(token: str) -> AuthUserIdentity`.
|
||||||
|
- **Implementations**:
|
||||||
|
- `GoogleOAuthAdapter`: Production token verification using Google API certs.
|
||||||
|
- `MockDevAdapter`: Local development and automated testing adapter issuing valid test sessions without external network dependencies.
|
||||||
|
- Future-ready for Authelia / OIDC providers without modifying core routes.
|
||||||
|
- Maintains user profile attributes including `trust_score` (ranging from 0.0 to 1.0) and unlocked collection counts.
|
||||||
|
|
||||||
### 2. Integrity & Reputation Engine
|
### 2. Integrity & Reputation Engine
|
||||||
Filters malicious traffic and spoofing. Performs **Velocity Checks** (time/distance deltas) and calculates user voting weight.
|
Guards against malicious data pollution, spoofing, and bot abuse.
|
||||||
|
- **Velocity Checks**: Analyzes spatio-temporal deltas between consecutive user submissions (check-ins and tickets):
|
||||||
|
$$v = \frac{d(p_1, p_2)}{\Delta t}$$
|
||||||
|
If calculated speed $v > 120\text{ km/h}$ (maximum plausible urban velocity) and $\Delta t < 300\text{ s}$, the submission is rejected or tagged as suspicious.
|
||||||
|
- **Trust Score Adjustment**: Users start at baseline $0.5$. Successful verified crowdsourced reports increment `trust_score` by $+0.05$ (max $1.0$). Submissions caught spoofing or repeatedly rejected penalize trust by $-0.15$ (min $0.0$).
|
||||||
|
|
||||||
### 3. Hybrid Recognition Service
|
### 3. Hybrid Recognition Service
|
||||||
Validates "Check-ins" by comparing image vectors and GPS proximity using a `similarity_threshold`.
|
Validates "Check-ins" using client-side edge embeddings (MobileNetV2 1280-dimension float vector) and server-side spatial proximity:
|
||||||
|
- Coordinate proximity within 15 meters using PostGIS `ST_DWithin`.
|
||||||
|
- Cosine similarity threshold: $\text{similarity} = 1.0 - (\text{embedding} \Leftrightarrow \mathbf{v}_{\text{query}}) \ge 0.65$.
|
||||||
|
|
||||||
### 4. Interaction & Collection Service
|
### 4. Interaction & Collection Service
|
||||||
Manages the many-to-many relationship between users and sculptures (unlocked achievements).
|
Manages the many-to-many relationship between users and sculptures (unlocked achievements, captured photo galleries, and cultural audio/insights).
|
||||||
|
|
||||||
### 5. Crowdsourcing & Ticket Service
|
### 5. Crowdsourcing & Ticket Service
|
||||||
Manages asynchronous reports (Tickets) for moved or missing sculptures.
|
Manages citizen reports for moved, missing, or altered sculptures:
|
||||||
|
- Accepts coordinates, observed status, verification photo, and optional commentary.
|
||||||
|
- Groups overlapping submissions into spatial clusters ($\le 20\text{ m}$ radius) over a 48-hour window.
|
||||||
|
|
||||||
### 6. Location Tracker Service (The Oracle)
|
### 6. Location Tracker Service (The Oracle) & Hybrid Consensus Engine
|
||||||
The final consumer of corroborated reports. Updates the "Single Source of Truth" (SSOT) for sculpture locations using a **Weighted Voting Algorithm**.
|
Computes the single source of truth (SSOT) location and status of each sculpture:
|
||||||
|
- **Cluster Confidence Metric**:
|
||||||
|
$$C_{\text{cluster}} = \sum_{i=1}^{N} \text{trust\_score}_i$$
|
||||||
|
- **Automatic State Transition**: If $C_{\text{cluster}} \ge 3.0$ with $N \ge 3$ distinct submitters and variance $\sigma_{\text{dist}} \le 20\text{ m}$, the Oracle automatically promotes the reported coordinates/status to the official sculpture record.
|
||||||
|
- **Moderator Escalation**: If $1.5 \le C_{\text{cluster}} < 3.0$ or reports have conflicting statuses, the cluster is held in `pending` state for manual moderator review via `/reports/{id}/verify`.
|
||||||
|
|
||||||
## Architecture Decision Records (ADR)
|
## Architecture Decision Records (ADR)
|
||||||
* **Separation of Check-in vs. Ticket:** Allows the system to be usable even with incorrect location data, fostering community correction without blocking the fun.
|
* **Separation of Check-in vs. Ticket:** Allows the system to be usable even with incorrect location data, fostering community correction without blocking the fun.
|
||||||
* **Single Database (pgvector + PostGIS):** Reduces network latency and synchronization complexity between spatial and vector data.
|
* **Single Database (pgvector + PostGIS):** Reduces network latency and synchronization complexity between spatial and vector data.
|
||||||
* **PWA Priority:** Chosen for immediate access (QR/URL) over the friction of app store downloads, especially for tourists.
|
* **PWA Priority:** Chosen for immediate access (QR/URL) over the friction of app store downloads, especially for tourists.
|
||||||
|
* **SSO Adapter Pattern:** Isolates authentication provider logic behind a clean contract, allowing local offline testing and easy migration to alternative auth providers (e.g. Authelia) without touching business logic.
|
||||||
|
* **Hybrid Consensus Threshold:** Combines automated confidence scoring ($\ge 3.0$) with human-in-the-loop moderator verification for ambiguous edge cases, balancing real-time responsiveness with catalog integrity.
|
||||||
|
|
||||||
@@ -0,0 +1,240 @@
|
|||||||
|
# Foundational Design Document: Image Recognition & Validation Pipeline
|
||||||
|
|
||||||
|
This document defines the architectural specifications, decision records (ADRs), schemas, and workflows for the **Novias del Gato** PWA image validation and check-in system. It serves as the primary technical specification for both client-side and server-side implementation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Executive Summary & Core Design
|
||||||
|
|
||||||
|
The visual check-in feature allows explorers to "capture" Cali's cat sculptures by photographing them. To meet the constraints of an **unfunded MVP** (minimizing cloud server costs) while ensuring a **reliable user experience** in public areas with unstable cellular networks, the project uses the **"Compressed Edge" Model**.
|
||||||
|
|
||||||
|
### Core Invariant
|
||||||
|
Vector embedding generation is offloaded entirely to the client device via WebAssembly/WebGL. The server processes no tensor mathematics on check-ins, operating purely as a lightweight router performing geographic proximity checks (PostGIS) and float similarity queries (`pgvector`).
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
A[Camera Capture] --> B[Resize to 800x800px & Compress to 75% JPEG]
|
||||||
|
A --> C[Local Inference via ONNX Web]
|
||||||
|
C --> D[Generate 1280-Float Vector]
|
||||||
|
B --> E[Multipart Upload Payload]
|
||||||
|
D --> E
|
||||||
|
E --> F[FastAPI Endpoint]
|
||||||
|
F --> G[S3 / CDN Gallery Storage]
|
||||||
|
F --> H[PostgreSQL Spatial & Cosine Similarity Query]
|
||||||
|
H --> I[Check-in Success / Unlock Content]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Architectural Decision Records (ADRs)
|
||||||
|
|
||||||
|
### ADR-001: Edge Inference with Quantized MobileNetV2
|
||||||
|
* **Context:** Running deep-learning vision models on the server requires high memory (1GB+ RAM) and CPU cores, raising hosting costs to $20-$40/month.
|
||||||
|
* **Decision:** We use a pre-trained **MobileNetV2** (ImageNet weights) with its final classification head removed, quantized to 8-bit integers (`int8`) to shrink the weight file from 13MB to **~3.5MB**. The PWA executes this model locally in the browser via [ONNX Runtime Web](https://onnxruntime.ai/docs/tutorials/web/).
|
||||||
|
* **Rationale:** Offloads heavy mathematical operations from the server to the client's local GPU/CPU. The API can run on a micro $4/month VPS with a minimal RAM footprint (~80MB idle).
|
||||||
|
|
||||||
|
### ADR-002: Client-Side Image Pre-Processing & Compression
|
||||||
|
* **Context:** Sending raw 2MB–5MB phone photographs over congested cellular networks in public parks leads to high upload latency, packet loss, and check-in timeouts.
|
||||||
|
* **Decision:** Before transmitting the data, the PWA draws the captured image to an offscreen HTML5 `<canvas>`, resizes it to a maximum bounding box of `800x800` pixels, and compresses it to a `75% quality JPEG`.
|
||||||
|
* **Rationale:** Reduces the network image payload size from **~5MB to ~80KB** (a ~98% reduction) while preserving sufficient quality for the explorer's personal photo gallery.
|
||||||
|
|
||||||
|
### ADR-003: API-Driven Versioning for Model Upgrades
|
||||||
|
* **Context:** If the feature extraction model is upgraded in the future, the dimensions of the generated vectors may change (e.g., from 1280 to 512 dimensions), rendering existing database vectors incompatible.
|
||||||
|
* **Decision:** Rather than adding a blocking, dynamic network `/config` request on app startup, the model version is hardcoded in the PWA client code. If the model is upgraded, a new client is released targeting a versioned API endpoint (e.g., `POST /v2/sculptures/{id}/check-in`).
|
||||||
|
* **Rationale:** Simplifies client logic, prevents blocking network calls on startup, and uses standard, predictable backend routing to manage different vector tables or columns.
|
||||||
|
|
||||||
|
### ADR-004: Asynchronous Moderation Queue for Device Failures
|
||||||
|
* **Context:** Some older or budget smartphones may throw exceptions when attempting WebAssembly compilation or WebGL initialization, preventing local vector generation.
|
||||||
|
* **Decision:** If the PWA catches an ONNX initialization error, it degrades gracefully by falling back to an **Asynchronous Moderation Queue**. It uploads the raw GPS coordinates and the compressed photo to the `/reports` endpoint. The check-in is set to "Pending" until an admin manually approves it.
|
||||||
|
* **Rationale:** Protects the server from loading resource-heavy inference engines (like PyTorch or full onnxruntime) on the backend, maintaining strict memory limits while still ensuring all users can complete check-ins.
|
||||||
|
|
||||||
|
### ADR-005: Progressive Dataset Rollout via Admin Seeding Tool
|
||||||
|
* **Context:** Collecting, photographing, and seeding reference vectors for all 38 cats on day one is a bottleneck that delays MVP deployment.
|
||||||
|
* **Decision:** We treat the database as a **Retrieval Engine** rather than a Classifier. We will build a hidden "Admin Check-in" view in the PWA. Using this view, the administrator walks up to a cat on site, photographs it to calculate the 1280-dimension vector locally, and inserts it directly into the database.
|
||||||
|
* **Rationale:** We can launch the MVP with only 3 cats in the database. New sculptures can be added progressively via database `INSERT` commands without updating the frontend bundle, modifying the backend codebase, or retraining neural networks.
|
||||||
|
|
||||||
|
### ADR-006: Acceptance of Offline Sync without Anti-Cheat
|
||||||
|
* **Context:** PWA clients cannot use hardware-based application attestation, meaning malicious users could spoof GPS coordinates or vector payloads in offline queues (IndexedDB).
|
||||||
|
* **Decision:** We accept offline check-in payloads at sync time without complex cryptographic or velocity-based anti-cheat algorithms. We reserve the `trust_score` and reputation checks strictly for the crowdsourced location reports (`/reports`).
|
||||||
|
* **Rationale:** The MVP is a non-monetary, educational cultural game. Prioritizing developer velocity over complex game anti-cheat structures allows faster market validation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Data Schemas & API Contracts
|
||||||
|
|
||||||
|
### Database Schema (SQL)
|
||||||
|
We store reference vectors using the `pgvector` extension and physical locations using the `postgis` extension.
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- Ensure extensions are loaded
|
||||||
|
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||||
|
CREATE EXTENSION IF NOT EXISTS vector;
|
||||||
|
|
||||||
|
-- Users table
|
||||||
|
CREATE TABLE users (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
email VARCHAR(255) UNIQUE NOT NULL,
|
||||||
|
trust_score FLOAT NOT NULL DEFAULT 0.5 CHECK (trust_score >= 0.0 AND trust_score <= 1.0),
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Sculptures table storing baseline vectors and spatial locations (SRID 4326)
|
||||||
|
CREATE TABLE sculptures (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
name VARCHAR(255) NOT NULL,
|
||||||
|
artist VARCHAR(255) NOT NULL,
|
||||||
|
year INTEGER NOT NULL CHECK (year >= 1900),
|
||||||
|
description TEXT,
|
||||||
|
audio_url VARCHAR(512),
|
||||||
|
unlocked_content TEXT,
|
||||||
|
status VARCHAR(50) NOT NULL DEFAULT 'on-site' CHECK (status IN ('on-site', 'moved', 'missing')),
|
||||||
|
location GEOGRAPHY(Point, 4326) NOT NULL,
|
||||||
|
embedding vector(1280) NOT NULL, -- L2-Normalized MobileNetV2 embedding vector
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Check-in Records table (Explorer's Gallery)
|
||||||
|
CREATE TABLE check_ins (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
sculpture_id UUID NOT NULL REFERENCES sculptures(id) ON DELETE CASCADE,
|
||||||
|
captured_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||||
|
photo_url VARCHAR(512) NOT NULL, -- URL pointing to the compressed 80KB photo
|
||||||
|
similarity_score FLOAT NOT NULL CHECK (similarity_score >= 0.0 AND similarity_score <= 1.0),
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
CONSTRAINT uq_user_sculpture UNIQUE (user_id, sculpture_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Crowdsourced Tickets / Reports table
|
||||||
|
CREATE TABLE tickets (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
reporter_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
sculpture_id UUID NOT NULL REFERENCES sculptures(id) ON DELETE CASCADE,
|
||||||
|
reported_status VARCHAR(50) NOT NULL CHECK (reported_status IN ('on-site', 'moved', 'missing')),
|
||||||
|
location GEOGRAPHY(Point, 4326) NOT NULL,
|
||||||
|
photo_url VARCHAR(512),
|
||||||
|
description VARCHAR(500),
|
||||||
|
status VARCHAR(50) NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'rejected')),
|
||||||
|
reporter_trust_score FLOAT NOT NULL CHECK (reporter_trust_score >= 0.0 AND reporter_trust_score <= 1.0),
|
||||||
|
notes VARCHAR(300),
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
resolved_at TIMESTAMP WITH TIME ZONE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Spatial and Vector Indexes
|
||||||
|
CREATE INDEX idx_sculptures_location ON sculptures USING GIST (location);
|
||||||
|
CREATE INDEX idx_sculptures_embedding ON sculptures USING hnsw (embedding vector_cosine_ops);
|
||||||
|
CREATE INDEX idx_tickets_location ON tickets USING GIST (location);
|
||||||
|
CREATE INDEX idx_tickets_sculpture_status ON tickets (sculpture_id, status);
|
||||||
|
CREATE INDEX idx_check_ins_user ON check_ins (user_id);
|
||||||
|
```
|
||||||
|
|
||||||
|
### API Endpoint (OpenAPI Fragment)
|
||||||
|
The check-in endpoint accepts a `multipart/form-data` request containing the coordinates, the photo file, and the float array.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
/sculptures/{id}/check-in:
|
||||||
|
post:
|
||||||
|
summary: Capture / Check-in to a Sculpture
|
||||||
|
description: |
|
||||||
|
Validate proximity and visual match. The PWA calculates the image vector
|
||||||
|
locally and compresses the image to ~80KB before sending.
|
||||||
|
operationId: checkInSculpture
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- photo
|
||||||
|
- latitude
|
||||||
|
- longitude
|
||||||
|
- embedding
|
||||||
|
properties:
|
||||||
|
photo:
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
description: Compressed sighting image file (JPEG/PNG, max 800x800px, 75% quality).
|
||||||
|
latitude:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
minimum: -90
|
||||||
|
maximum: 90
|
||||||
|
longitude:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
minimum: -180
|
||||||
|
maximum: 180
|
||||||
|
embedding:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
description: Client-side generated 1280-float array (L2-normalized).
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Verification outcome
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- success
|
||||||
|
- similarity_score
|
||||||
|
properties:
|
||||||
|
success:
|
||||||
|
type: boolean
|
||||||
|
description: True if the vector matched and location was within 15 meters.
|
||||||
|
similarity_score:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
description: 1.0 minus Cosine Distance (range 0.0 to 1.0).
|
||||||
|
unlocked_content:
|
||||||
|
type: string
|
||||||
|
description: Cultural reward facts unlocked for the user.
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Implementation Steps & Checklists
|
||||||
|
|
||||||
|
### 🟥 Phase A: Model Preparation & Seeding (Pre-requisites)
|
||||||
|
1. [ ] Run the PyTorch export script [export_onnx.py](file:///home/kiskaadee/.gemini/antigravity-cli/brain/a74d43db-73ab-4c99-9e4d-06c66547fc0b/scratch/export_onnx.py) to generate `mobilenetv2_features.onnx`.
|
||||||
|
2. [ ] Apply ONNX quantization to output `mobilenetv2_features_quant.onnx` (reducing size to ~3.5MB).
|
||||||
|
3. [ ] Gather reference photos for the first 3 cats. Run them through the python script to obtain their 1280-dimension baseline vectors.
|
||||||
|
4. [ ] Insert the baseline records into the database.
|
||||||
|
|
||||||
|
### 🟨 Phase B: Client-Side (PWA) Development
|
||||||
|
1. [ ] Implement camera stream retrieval via `navigator.mediaDevices.getUserMedia`.
|
||||||
|
2. [ ] Integrate `onnxruntime-web` to load the quantized model. Ensure the model file is cached via the service worker cache.
|
||||||
|
3. [ ] Add canvas downscaling logic: Draw video frame to canvas, crop to square, resize to `800x800px`, and export as a `75% quality JPEG` blob.
|
||||||
|
4. [ ] Write tensor conversion code: Normalize canvas pixel values to ImageNet means/standards and pass them to the ONNX session.
|
||||||
|
5. [ ] Design the camera overlay UI featuring the dashed cat silhouette to standardize the capture range.
|
||||||
|
6. [ ] Implement IndexedDB storage for offline check-ins (storing the coordinates, timestamp, vector, and image blob).
|
||||||
|
|
||||||
|
### 🟦 Phase C: Server-Side (FastAPI) Development
|
||||||
|
1. [ ] Configure FastAPI multi-part parsing to read `latitude`, `longitude`, `embedding` (from a JSON-serialized string or parsed form field), and the compressed `photo` file.
|
||||||
|
2. [ ] Implement image saving to CDN storage (generating a unique path: `/checkins/{user_id}/{sculpture_id}_{timestamp}.jpg`).
|
||||||
|
3. [ ] Build the database validation query using `pgvector` operators:
|
||||||
|
```sql
|
||||||
|
-- Cosine distance operator is '<=>'
|
||||||
|
-- Cosine similarity = 1.0 - (vector <=> :user_vector)
|
||||||
|
SELECT id, (1.0 - (embedding <=> :user_vector)) as similarity_score
|
||||||
|
FROM sculptures
|
||||||
|
WHERE ST_DWithin(location, ST_MakePoint(:longitude, :latitude)::geography, 15)
|
||||||
|
ORDER BY embedding <=> :user_vector
|
||||||
|
LIMIT 1;
|
||||||
|
```
|
||||||
|
4. [ ] Set the similarity check logic: if `similarity_score > 0.65` (cosine distance `< 0.35`), record check-in and return unlocked content.
|
||||||
|
5. [ ] Write fallback routing: If `embedding` is empty, insert the report into the `tickets` table as a pending manual review and return a `"pending"` status.
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
User:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- name
|
|
||||||
- email
|
|
||||||
- trust_score
|
|
||||||
- captured_count
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
example: Juan Perez
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: juan.perez@gmail.com
|
|
||||||
trust_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
description: Reputational metric scaling from 0.0 (untrusted) to 1.0 (highly reliable).
|
|
||||||
example: 0.85
|
|
||||||
captured_count:
|
|
||||||
type: integer
|
|
||||||
description: Total number of unique sculptures verified.
|
|
||||||
example: 12
|
|
||||||
|
|
||||||
Sculpture:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- name
|
|
||||||
- artist
|
|
||||||
- year
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- status
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
example: La Novia Dulce
|
|
||||||
artist:
|
|
||||||
type: string
|
|
||||||
example: Lorena Espitia
|
|
||||||
year:
|
|
||||||
type: integer
|
|
||||||
example: 2006
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 3.450143
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: -76.533282
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [on-site, moved, missing]
|
|
||||||
description: Operational status of the sculpture.
|
|
||||||
example: on-site
|
|
||||||
|
|
||||||
SculptureDetails:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/Sculpture'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
example: Decorated with sweets and candies representing Cali's culinary traditions.
|
|
||||||
audio_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
example: https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3
|
|
||||||
unlocked_content:
|
|
||||||
type: string
|
|
||||||
description: Extended history/curation (hidden until captured).
|
|
||||||
example: This sculpture was crafted in tribute to the traditional festival of Macetas.
|
|
||||||
|
|
||||||
CheckInRecord:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- sculpture_id
|
|
||||||
- unlocked_at
|
|
||||||
- similarity_score
|
|
||||||
properties:
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
unlocked_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
example: 2026-05-30T10:15:30Z
|
|
||||||
checkin_photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
example: https://cdn.gatos.cali.gov.co/uploads/checkin_9823.jpg
|
|
||||||
similarity_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 0.92
|
|
||||||
|
|
||||||
Ticket:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- reporter_id
|
|
||||||
- sculpture_id
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- reported_status
|
|
||||||
- status
|
|
||||||
- created_at
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
reporter_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 3.4515
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: -76.5320
|
|
||||||
reported_status:
|
|
||||||
type: string
|
|
||||||
enum: [moved, missing, on-site]
|
|
||||||
photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
nullable: true
|
|
||||||
example: https://cdn.gatos.cali.gov.co/uploads/report_8321.jpg
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
example: Under construction for street repairs. Pedestal is empty.
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [pending, approved, rejected]
|
|
||||||
example: pending
|
|
||||||
created_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
example: 2026-05-30T11:00:00Z
|
|
||||||
resolved_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
nullable: true
|
|
||||||
example: null
|
|
||||||
notes:
|
|
||||||
type: string
|
|
||||||
nullable: true
|
|
||||||
example: Verified via municipal service coordinates.
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Novias del Gato API - Modular
|
|
||||||
description: |
|
|
||||||
Modular, service-oriented API contract for the "Novias del Gato" digital ecosystem in Cali, Colombia.
|
|
||||||
This specification splits paths and components into separate domain files for enhanced maintainability.
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: https://api.gatos.cali.gov.co/v1
|
|
||||||
description: Production Server
|
|
||||||
- url: http://localhost:8000/v1
|
|
||||||
description: Local Development Server
|
|
||||||
|
|
||||||
paths:
|
|
||||||
/auth/login:
|
|
||||||
$ref: 'paths/auth.yaml'
|
|
||||||
|
|
||||||
/users/me:
|
|
||||||
$ref: 'paths/users.yaml#/me'
|
|
||||||
|
|
||||||
/users/me/collection:
|
|
||||||
$ref: 'paths/users.yaml#/collection'
|
|
||||||
|
|
||||||
/sculptures:
|
|
||||||
$ref: 'paths/sculptures.yaml#/list'
|
|
||||||
|
|
||||||
/sculptures/{id}:
|
|
||||||
$ref: 'paths/sculptures.yaml#/detail'
|
|
||||||
|
|
||||||
/sculptures/{id}/check-in:
|
|
||||||
$ref: 'paths/checkin.yaml'
|
|
||||||
|
|
||||||
/reports:
|
|
||||||
$ref: 'paths/reports.yaml#/collection'
|
|
||||||
|
|
||||||
/reports/{id}/verify:
|
|
||||||
$ref: 'paths/reports.yaml#/verify'
|
|
||||||
|
|
||||||
components:
|
|
||||||
securitySchemes:
|
|
||||||
BearerAuth:
|
|
||||||
type: http
|
|
||||||
scheme: bearer
|
|
||||||
bearerFormat: JWT
|
|
||||||
|
|
||||||
responses:
|
|
||||||
Unauthorized:
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
Forbidden:
|
|
||||||
description: Insufficient permissions for this action.
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
post:
|
|
||||||
summary: Google SSO Authentication
|
|
||||||
description: Exchange a Google OAuth ID token for a system-issued JWT access token.
|
|
||||||
operationId: loginUser
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id_token
|
|
||||||
properties:
|
|
||||||
id_token:
|
|
||||||
type: string
|
|
||||||
description: The ID token returned by Google OAuth.
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Successful authentication
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- access_token
|
|
||||||
- token_type
|
|
||||||
- expires_in
|
|
||||||
properties:
|
|
||||||
access_token:
|
|
||||||
type: string
|
|
||||||
description: JWT access token for subsequent requests.
|
|
||||||
token_type:
|
|
||||||
type: string
|
|
||||||
example: Bearer
|
|
||||||
expires_in:
|
|
||||||
type: integer
|
|
||||||
description: Token lifetime in seconds.
|
|
||||||
'401':
|
|
||||||
description: Invalid token provided.
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
post:
|
|
||||||
summary: Capture / Check-in to a Sculpture
|
|
||||||
description: |
|
|
||||||
Perform physical verification by sending the explorer's current GPS location and a freshly captured photo.
|
|
||||||
The Recognition Service verifies the photo matches the sculpture model embeddings within proximity.
|
|
||||||
operationId: checkInSculpture
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- photo
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
properties:
|
|
||||||
photo:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
description: Sighting image file (JPEG/PNG) to analyze.
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
minimum: -90
|
|
||||||
maximum: 90
|
|
||||||
example: 3.4501
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
minimum: -180
|
|
||||||
maximum: 180
|
|
||||||
example: -76.5332
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Verification outcome
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- success
|
|
||||||
- similarity_score
|
|
||||||
properties:
|
|
||||||
success:
|
|
||||||
type: boolean
|
|
||||||
description: True if the image embedding matched and location was within threshold.
|
|
||||||
similarity_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
description: Visual confidence score (0.0 to 1.0).
|
|
||||||
unlocked_content:
|
|
||||||
type: string
|
|
||||||
description: Cultural facts or reward text if successfully captured for the first time.
|
|
||||||
reward_badge:
|
|
||||||
type: string
|
|
||||||
description: Name of the badge unlocked, if any.
|
|
||||||
'400':
|
|
||||||
description: Invalid coordinates or image file format.
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
collection:
|
|
||||||
post:
|
|
||||||
summary: Submit a Sculpture Location Report
|
|
||||||
description: |
|
|
||||||
Allows citizens to report if a sculpture is missing, undergoing maintenance, or has been relocated.
|
|
||||||
Supplying GPS coordinates and an optional photo helps update the status map via the weighted consensus engine.
|
|
||||||
operationId: submitReport
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- sculpture_id
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- reported_status
|
|
||||||
properties:
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 3.4515
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: -76.5320
|
|
||||||
reported_status:
|
|
||||||
type: string
|
|
||||||
enum: [moved, missing, on-site]
|
|
||||||
description: The observed state of the sculpture.
|
|
||||||
photo:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
description: Optional verification photo of empty pedestal or relocated site.
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
maxLength: 500
|
|
||||||
description: Context about the change.
|
|
||||||
responses:
|
|
||||||
'201':
|
|
||||||
description: Report ticket successfully created
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '../components/schemas.yaml#/Ticket'
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
|
|
||||||
get:
|
|
||||||
summary: List Crowdsourced Reports (Moderator Only)
|
|
||||||
description: Retrieve reports/tickets submitted by users, filterable by status for verification.
|
|
||||||
operationId: listReports
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: status
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
enum: [pending, approved, rejected]
|
|
||||||
- name: sculpture_id
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Array of reports
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '../components/schemas.yaml#/Ticket'
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
'403':
|
|
||||||
description: Insufficient permissions for this action.
|
|
||||||
|
|
||||||
verify:
|
|
||||||
put:
|
|
||||||
summary: Resolve Location Ticket (Moderator Only)
|
|
||||||
description: Manually accept or reject a user report. Approving a report updates the location oracle and recalculates user trust scores.
|
|
||||||
operationId: verifyReport
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- status
|
|
||||||
properties:
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [approved, rejected]
|
|
||||||
notes:
|
|
||||||
type: string
|
|
||||||
maxLength: 300
|
|
||||||
description: Review notes explaining the resolution.
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Ticket resolved successfully
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '../components/schemas.yaml#/Ticket'
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
'403':
|
|
||||||
description: Insufficient permissions for this action.
|
|
||||||
'404':
|
|
||||||
description: Ticket not found.
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
list:
|
|
||||||
get:
|
|
||||||
summary: List All Cat Sculptures
|
|
||||||
description: Returns list of all sculptures with names, locations, and current status (Single Source of Truth).
|
|
||||||
operationId: listSculptures
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: List of sculptures
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '../components/schemas.yaml#/Sculpture'
|
|
||||||
|
|
||||||
detail:
|
|
||||||
get:
|
|
||||||
summary: Get Sculpture Details
|
|
||||||
description: Detailed information about a sculpture, historical context, artist, and unlockable audio guides.
|
|
||||||
operationId: getSculptureById
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Detailed sculpture object
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '../components/schemas.yaml#/SculptureDetails'
|
|
||||||
'404':
|
|
||||||
description: Sculpture not found.
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
me:
|
|
||||||
get:
|
|
||||||
summary: Retrieve Current User Profile
|
|
||||||
description: Get details about the authenticated user, including their community trust score.
|
|
||||||
operationId: getMyProfile
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Success
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '../components/schemas.yaml#/User'
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
|
|
||||||
collection:
|
|
||||||
get:
|
|
||||||
summary: Get User's Unlocked Sculptures
|
|
||||||
description: Returns the user's progress tracking which cat sculptures they have successfully captured.
|
|
||||||
operationId: getMyCollection
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: List of check-ins / captures
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '../components/schemas.yaml#/CheckInRecord'
|
|
||||||
'401':
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
@@ -1,313 +0,0 @@
|
|||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Novias del Gato API - Collector
|
|
||||||
description: |
|
|
||||||
Authenticated API contract for collectors and contributors. Contains operations for
|
|
||||||
social check-ins, location status reporting, and user profiles.
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: https://api.gatos.cali.gov.co/v1
|
|
||||||
description: Production Server
|
|
||||||
paths:
|
|
||||||
/auth/login:
|
|
||||||
post:
|
|
||||||
summary: Google SSO Authentication
|
|
||||||
description: Exchange a Google OAuth ID token for a system-issued JWT access token.
|
|
||||||
operationId: loginUser
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id_token
|
|
||||||
properties:
|
|
||||||
id_token:
|
|
||||||
type: string
|
|
||||||
description: The ID token returned by Google OAuth.
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Successful authentication
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- access_token
|
|
||||||
- token_type
|
|
||||||
- expires_in
|
|
||||||
properties:
|
|
||||||
access_token:
|
|
||||||
type: string
|
|
||||||
token_type:
|
|
||||||
type: string
|
|
||||||
example: Bearer
|
|
||||||
expires_in:
|
|
||||||
type: integer
|
|
||||||
'401':
|
|
||||||
description: Invalid token.
|
|
||||||
|
|
||||||
/users/me:
|
|
||||||
get:
|
|
||||||
summary: Retrieve Current User Profile
|
|
||||||
description: Get details about the authenticated user, including their community trust score.
|
|
||||||
operationId: getMyProfile
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Success
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/User'
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
|
|
||||||
/users/me/collection:
|
|
||||||
get:
|
|
||||||
summary: Get User's Unlocked Sculptures
|
|
||||||
description: Returns the user's progress tracking which cat sculptures they have successfully captured.
|
|
||||||
operationId: getMyCollection
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: List of check-ins / captures
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/CheckInRecord'
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
|
|
||||||
/sculptures/{id}/check-in:
|
|
||||||
post:
|
|
||||||
summary: Capture / Check-in to a Sculpture
|
|
||||||
description: |
|
|
||||||
Perform physical verification by sending the explorer's current GPS location and a freshly captured photo.
|
|
||||||
The Recognition Service verifies the photo matches the sculpture model embeddings within proximity.
|
|
||||||
operationId: checkInSculpture
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- photo
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
properties:
|
|
||||||
photo:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
minimum: -90
|
|
||||||
maximum: 90
|
|
||||||
example: 3.4501
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
minimum: -180
|
|
||||||
maximum: 180
|
|
||||||
example: -76.5332
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Verification outcome
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- success
|
|
||||||
- similarity_score
|
|
||||||
properties:
|
|
||||||
success:
|
|
||||||
type: boolean
|
|
||||||
similarity_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
unlocked_content:
|
|
||||||
type: string
|
|
||||||
reward_badge:
|
|
||||||
type: string
|
|
||||||
'400':
|
|
||||||
description: Invalid coordinates or photo format.
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
|
|
||||||
/reports:
|
|
||||||
post:
|
|
||||||
summary: Submit a Sculpture Location Report
|
|
||||||
description: |
|
|
||||||
Allows citizens to report if a sculpture is missing, undergoing maintenance, or has been relocated.
|
|
||||||
Supplying GPS coordinates and an optional photo helps update the status map via the weighted consensus engine.
|
|
||||||
operationId: submitReport
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- sculpture_id
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- reported_status
|
|
||||||
properties:
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
reported_status:
|
|
||||||
type: string
|
|
||||||
enum: [moved, missing, on-site]
|
|
||||||
photo:
|
|
||||||
type: string
|
|
||||||
format: binary
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
maxLength: 500
|
|
||||||
responses:
|
|
||||||
'201':
|
|
||||||
description: Report ticket successfully created
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Ticket'
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
|
|
||||||
components:
|
|
||||||
securitySchemes:
|
|
||||||
BearerAuth:
|
|
||||||
type: http
|
|
||||||
scheme: bearer
|
|
||||||
bearerFormat: JWT
|
|
||||||
|
|
||||||
responses:
|
|
||||||
Unauthorized:
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
|
|
||||||
schemas:
|
|
||||||
User:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- name
|
|
||||||
- email
|
|
||||||
- trust_score
|
|
||||||
- captured_count
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
example: Juan Perez
|
|
||||||
email:
|
|
||||||
type: string
|
|
||||||
format: email
|
|
||||||
example: juan.perez@gmail.com
|
|
||||||
trust_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 0.85
|
|
||||||
captured_count:
|
|
||||||
type: integer
|
|
||||||
example: 12
|
|
||||||
|
|
||||||
CheckInRecord:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- sculpture_id
|
|
||||||
- unlocked_at
|
|
||||||
- similarity_score
|
|
||||||
properties:
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
unlocked_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
example: 2026-05-30T10:15:30Z
|
|
||||||
checkin_photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
example: https://cdn.gatos.cali.gov.co/uploads/checkin_9823.jpg
|
|
||||||
similarity_score:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 0.92
|
|
||||||
|
|
||||||
Ticket:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- reporter_id
|
|
||||||
- sculpture_id
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- reported_status
|
|
||||||
- status
|
|
||||||
- created_at
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
reporter_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
reported_status:
|
|
||||||
type: string
|
|
||||||
enum: [moved, missing, on-site]
|
|
||||||
photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
nullable: true
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [pending, approved, rejected]
|
|
||||||
created_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
resolved_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
nullable: true
|
|
||||||
notes:
|
|
||||||
type: string
|
|
||||||
nullable: true
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Novias del Gato API - Explorer (Public)
|
|
||||||
description: |
|
|
||||||
Public, read-only API contract for tourists and citizens exploring Cali's public cat sculptures.
|
|
||||||
Does not require authentication.
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: https://api.gatos.cali.gov.co/v1
|
|
||||||
description: Production Server
|
|
||||||
paths:
|
|
||||||
/sculptures:
|
|
||||||
get:
|
|
||||||
summary: List All Cat Sculptures
|
|
||||||
description: Returns list of all sculptures with names, locations, and current status (Single Source of Truth).
|
|
||||||
operationId: listSculptures
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: List of sculptures
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Sculpture'
|
|
||||||
|
|
||||||
/sculptures/{id}:
|
|
||||||
get:
|
|
||||||
summary: Get Sculpture Details
|
|
||||||
description: Detailed information about a sculpture, historical context, artist, and unlockable audio guides.
|
|
||||||
operationId: getSculptureById
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Detailed sculpture object
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/SculptureDetails'
|
|
||||||
'404':
|
|
||||||
description: Sculpture not found.
|
|
||||||
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
Sculpture:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- name
|
|
||||||
- artist
|
|
||||||
- year
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- status
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
example: La Novia Dulce
|
|
||||||
artist:
|
|
||||||
type: string
|
|
||||||
example: Lorena Espitia
|
|
||||||
year:
|
|
||||||
type: integer
|
|
||||||
example: 2006
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: 3.450143
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
example: -76.533282
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [on-site, moved, missing]
|
|
||||||
description: Operational status of the sculpture.
|
|
||||||
example: on-site
|
|
||||||
|
|
||||||
SculptureDetails:
|
|
||||||
allOf:
|
|
||||||
- $ref: '#/components/schemas/Sculpture'
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
example: Decorated with sweets and candies representing Cali's culinary traditions.
|
|
||||||
audio_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
example: https://cdn.gatos.cali.gov.co/audio/novia_dulce.mp3
|
|
||||||
unlocked_content:
|
|
||||||
type: string
|
|
||||||
description: Extended history/curation (hidden until captured).
|
|
||||||
example: This sculpture was crafted in tribute to the traditional festival of Macetas.
|
|
||||||
@@ -1,152 +0,0 @@
|
|||||||
openapi: 3.0.3
|
|
||||||
info:
|
|
||||||
title: Novias del Gato API - Moderator (Backoffice)
|
|
||||||
description: |
|
|
||||||
Backoffice API contract for administrators and cultural moderators.
|
|
||||||
Enables tracking and resolving disputed location reports.
|
|
||||||
version: 1.0.0
|
|
||||||
servers:
|
|
||||||
- url: https://api.gatos.cali.gov.co/v1
|
|
||||||
description: Production Server
|
|
||||||
paths:
|
|
||||||
/reports:
|
|
||||||
get:
|
|
||||||
summary: List Crowdsourced Reports
|
|
||||||
description: Retrieve reports/tickets submitted by users, filterable by status for verification.
|
|
||||||
operationId: listReports
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: status
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
enum: [pending, approved, rejected]
|
|
||||||
- name: sculpture_id
|
|
||||||
in: query
|
|
||||||
required: false
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Array of reports
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/Ticket'
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
'403':
|
|
||||||
$ref: '#/components/responses/Forbidden'
|
|
||||||
|
|
||||||
/reports/{id}/verify:
|
|
||||||
put:
|
|
||||||
summary: Resolve Location Ticket
|
|
||||||
description: Manually accept or reject a user report. Approving a report updates the location oracle and recalculates user trust scores.
|
|
||||||
operationId: verifyReport
|
|
||||||
security:
|
|
||||||
- BearerAuth: []
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
in: path
|
|
||||||
required: true
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- status
|
|
||||||
properties:
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [approved, rejected]
|
|
||||||
notes:
|
|
||||||
type: string
|
|
||||||
maxLength: 300
|
|
||||||
description: Review notes explaining the resolution.
|
|
||||||
responses:
|
|
||||||
'200':
|
|
||||||
description: Ticket resolved successfully
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
$ref: '#/components/schemas/Ticket'
|
|
||||||
'401':
|
|
||||||
$ref: '#/components/responses/Unauthorized'
|
|
||||||
'403':
|
|
||||||
$ref: '#/components/responses/Forbidden'
|
|
||||||
'404':
|
|
||||||
description: Ticket not found.
|
|
||||||
|
|
||||||
components:
|
|
||||||
securitySchemes:
|
|
||||||
BearerAuth:
|
|
||||||
type: http
|
|
||||||
scheme: bearer
|
|
||||||
bearerFormat: JWT
|
|
||||||
|
|
||||||
responses:
|
|
||||||
Unauthorized:
|
|
||||||
description: Authentication token missing or expired.
|
|
||||||
Forbidden:
|
|
||||||
description: Insufficient permissions for this action.
|
|
||||||
|
|
||||||
schemas:
|
|
||||||
Ticket:
|
|
||||||
type: object
|
|
||||||
required:
|
|
||||||
- id
|
|
||||||
- reporter_id
|
|
||||||
- sculpture_id
|
|
||||||
- latitude
|
|
||||||
- longitude
|
|
||||||
- reported_status
|
|
||||||
- status
|
|
||||||
- created_at
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
reporter_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
sculpture_id:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
latitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
longitude:
|
|
||||||
type: number
|
|
||||||
format: float
|
|
||||||
reported_status:
|
|
||||||
type: string
|
|
||||||
enum: [moved, missing, on-site]
|
|
||||||
photo_url:
|
|
||||||
type: string
|
|
||||||
format: uri
|
|
||||||
nullable: true
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
type: string
|
|
||||||
enum: [pending, approved, rejected]
|
|
||||||
created_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
resolved_at:
|
|
||||||
type: string
|
|
||||||
format: date-time
|
|
||||||
nullable: true
|
|
||||||
notes:
|
|
||||||
type: string
|
|
||||||
nullable: true
|
|
||||||
@@ -53,6 +53,51 @@ paths:
|
|||||||
'401':
|
'401':
|
||||||
description: Invalid token provided.
|
description: Invalid token provided.
|
||||||
|
|
||||||
|
/auth/dev-token:
|
||||||
|
post:
|
||||||
|
summary: Development SSO Bypass Token Generation
|
||||||
|
description: |
|
||||||
|
Generates a valid signed JWT for a specified email without contacting external identity providers.
|
||||||
|
Available only when server environment is configured for development or testing (ENV != 'production').
|
||||||
|
operationId: getDevToken
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- email
|
||||||
|
properties:
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
format: email
|
||||||
|
example: explorer@example.com
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: Local Explorer
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Test token issued
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- access_token
|
||||||
|
- token_type
|
||||||
|
- expires_in
|
||||||
|
properties:
|
||||||
|
access_token:
|
||||||
|
type: string
|
||||||
|
token_type:
|
||||||
|
type: string
|
||||||
|
example: Bearer
|
||||||
|
expires_in:
|
||||||
|
type: integer
|
||||||
|
'403':
|
||||||
|
description: Endpoint disabled in production mode.
|
||||||
|
|
||||||
/users/me:
|
/users/me:
|
||||||
get:
|
get:
|
||||||
summary: Retrieve Current User Profile
|
summary: Retrieve Current User Profile
|
||||||
@@ -152,11 +197,12 @@ paths:
|
|||||||
- photo
|
- photo
|
||||||
- latitude
|
- latitude
|
||||||
- longitude
|
- longitude
|
||||||
|
- embedding
|
||||||
properties:
|
properties:
|
||||||
photo:
|
photo:
|
||||||
type: string
|
type: string
|
||||||
format: binary
|
format: binary
|
||||||
description: Sighting image file (JPEG/PNG) to analyze.
|
description: Compressed sighting image file (JPEG/PNG, recommended 800x800px, 75% quality).
|
||||||
latitude:
|
latitude:
|
||||||
type: number
|
type: number
|
||||||
format: float
|
format: float
|
||||||
@@ -169,6 +215,12 @@ paths:
|
|||||||
minimum: -180
|
minimum: -180
|
||||||
maximum: 180
|
maximum: 180
|
||||||
example: -76.5332
|
example: -76.5332
|
||||||
|
embedding:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
description: Client-side generated image embedding vector (e.g. 1280 float array from MobileNetV2).
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Verification outcome
|
description: Verification outcome
|
||||||
|
|||||||
Reference in new issue
Block a user