yantrabodha-api / api /models.py
Kethan Dosapati
Enhance static UI and authentication: improve sidebar auth visibility, add mobile responsiveness, and refine error messages; update `/report` endpoint to use `ArticleOut` model; redesign styles for a Reddit-like layout with theming and responsive tweaks.
363bda3
"""Shared Pydantic models for the API."""
from typing import Optional
from pydantic import BaseModel, ConfigDict
class ArticleIn(BaseModel):
title: str
body: str
language: str = "general"
tags: list[str] = []
type: str = "error"
contributing_agent: Optional[str] = None
confidence: str = "medium"
user_id: Optional[str] = None
username: Optional[str] = None
avatar_url: Optional[str] = None
class ArticleOut(BaseModel):
id: str
title: str
created_at: str
class Article(BaseModel):
"""Article as returned by GET /api/articles and GET /api/articles/{id}."""
model_config = ConfigDict(extra="ignore")
id: str
title: str
body: Optional[str] = None
language: Optional[str] = None
tags: Optional[list[str]] = None
type: Optional[str] = None
contributing_agent: Optional[str] = None
confidence: Optional[str] = None
created_at: str
class ArticlesListResponse(BaseModel):
"""Response for GET /api/articles — list recent articles."""
articles: list[Article]
all_projects: list[Article]
class Comment(BaseModel):
"""Comment as returned by GET/POST /api/articles/{id}/comments."""
model_config = ConfigDict(extra="ignore")
id: str
article_id: str
body: str
author: Optional[str] = None
created_at: str
class ConfigResponse(BaseModel):
"""Response for GET /api/config."""
supabaseUrl: str
supabaseAnonKey: str
class HealthResponse(BaseModel):
"""Response for GET /api/health."""
status: str