""" Yantrabodha Article API ======================= FastAPI app backed by Supabase (Postgres). Endpoints: - GET / — static UI (browse, submit, search tips) - GET /api/articles — list recent articles - POST /api/post, POST /post — submit article (same; /post for PyPI client) - POST /api/report, POST /report — report (MCP structured payload) - GET /api/match, GET /match — full-text search (/match for PyPI client) Environment variables: SUPABASE_URL — from Supabase Project Settings → API SUPABASE_SERVICE_KEY — service role key (bypasses RLS) """ from pathlib import Path from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from database import supabase # noqa: F401 — ensure DB is loaded from endpoints.articles import router as articles_router from endpoints.comments import router as comments_router from endpoints.config import router as config_router from endpoints.match import router as match_router from endpoints.post import router as post_router from endpoints.report import router as report_router app = FastAPI(title="Yantrabodha API", version="1.0.0") app.include_router(post_router, prefix="/api/post") app.include_router(match_router, prefix="/api/match") app.include_router(report_router, prefix="/api") app.include_router(config_router, prefix="/api") # More specific routes first: /api/articles/{id}/comments before /api/articles app.include_router(comments_router, prefix="/api") app.include_router(articles_router, prefix="/api") # Backward compatibility: PyPI client (yantrabodha_mcp) uses /post and /match without /api app.include_router(post_router, prefix="/post") app.include_router(match_router, prefix="/match") # MCP may call either /report or /api/report app.include_router(report_router, prefix="") # Static UI last so /api/* and /post, /match take precedence static_dir = Path(__file__).parent / "static" app.mount("/", StaticFiles(directory=str(static_dir), html=True), name="static")