portal-backend-api

Create FastAPI routers, endpoints, and SSE handlers for a financial data portal.

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-backend-api-arthurzizumbo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: portal-backend-api
Source: https://github.com/ArthurZizumbo/karisma-data/tree/main/.claude/skills/portal-backend-api
Command: npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-backend-api-arthurzizumbo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastapi, pydantic, structlog.

What problem does it solve? Building secure, consistent backend endpoints for the Portal Centralizado de Datos Financieros requires enforcing authentication scopes, typed error responses, and streaming chat behavior across every router, which is error-prone when done by hand. ## Core Features & Use Cases - Scoped Endpoint Creation: Generates FastAPI routers with Security(get_current_user, scopes=[...]) enforcement, returning 401 without a token and 403 without permission. - Typed Error Handling: Produces standardized errors such as 422 with fuzzy catalog suggestions for unknown metrics, 409 for duplicate users, and 503 for unavailable silos. - SSE Chat Streaming: Implements /api/chat as a StreamingResponse with tool_call, token, error, and done events, cancelling the LLM call when the client disconnects. - Use Case: Add a new /api/creditos endpoint that delegates to SemanticService, enforces the operativo scope, and returns a Pydantic SemanticResult model. ## Quick Start Create a new FastAPI router for the creditos endpoint with scope enforcement and Pydantic response models following the portal conventions.

Frequently Asked Questions about portal-backend-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new FastAPI endpoint with scope-based authorization?

Define a router with APIRouter and protect each endpoint using Security(get_current_user, scopes=[...]) as a dependency. Requests without a token receive 401 with a WWW-Authenticate Bearer header, and authenticated users lacking the scope receive 403.

How to implement SSE streaming in FastAPI with client disconnect handling?

Return a StreamingResponse with media_type text/event-stream and yield formatted event lines from an async generator. Check request.is_disconnected() inside the loop and cancel the underlying LLM call when the client disconnects.

What HTTP status code should an API return for an unknown metric or dimension?

Return 422 with a structured detail body containing the error type, the offending metric, and fuzzy-match suggestions from the catalog. Duplicate username or email conflicts return 409, and an unavailable data silo returns a typed partial 503.

Should FastAPI routers contain business logic?

No, routers should only receive requests and delegate to services, following the pattern router receives, service processes, model persists. Responses must always use Pydantic response_model classes rather than raw SQLModel objects or hand-serialized DataFrames.

Why should passwords and raw prompts never appear in API logs?

Logging credentials or raw prompts leaks sensitive data into log storage where it can be exposed. Use structlog.get_logger() for structured logging and record only safe fields such as user IDs, metric names, and prompt hashes.