Senior Python Backend Engineer (FastAPI & AI-Native Systems)

Posted yesterday

Only freelancers located in the U.S. may apply.U.S. located freelancers only

Summary

The Opportunity We are building a next-generation, AI-native backend platform where large language models are not just an integration but the core orchestration engine of our business logic. We are looking for a senior Python engineer who treats APIs as a product, security as a foundation, and LLMs (specifically Claude) as a primary computation resource. This is not a "prompt engineering" role—this is a systems engineering role. You will architect stateful, stateless, and agentic workflows, ensuring sub-100ms overhead on API routing while managing 50k+ token context windows efficiently. You will bridge the gap between deterministic backend code and probabilistic AI reasoning. Core Responsibilities Backend Architecture & API Development - Design, build, and maintain high-performance, asynchronous REST/WebSocket APIs using FastAPI (Pydantic v2, dependency injection, middleware stacks). - Implement advanced FastAPI patterns: background tasks, lifespan context managers, custom route classes, and OpenAPI tag-based versioning. - Refactor monolithic endpoints into microservice-oriented domains, leveraging FastAPI’s APIRouter for modularity. Data Persistence & Cloud-Native DB (Prisma & Aurora PostgreSQL) Own the data layer using Prisma Client Python as the type-safe ORM layer, treating your database schema as the single source of truth for all domain models. Write and maintain Prisma Schema Definitions (.prisma files) with advanced relationships (one-to-many, many-to-many, polymorphic via @default), indexes, and @@unique constraints to enforce data integrity across AI-generated and user-supplied data. Manage Prisma Migrations as part of your CI/CD pipeline—you will generate, review, and apply migration files in ephemeral test environments before promoting to production, ensuring zero-downtime schema evolution. Leverage Aurora PostgreSQL Serverless v2 as our primary database, designing for: Connection Pooling using pgbouncer or RDS Proxy to handle thousands of concurrent asynchronous FastAPI requests without exhausting connections. Read/Write Splitting: Route analytical and LLM-embedding read queries (e.g., RAG lookups, historical aggregation) to Aurora read replicas, while directing transactional writes to the primary writer node. Failover Resilience: Implement retry logic with tenacity that gracefully handles Aurora failover events (writer promotion) without corrupting in-flight transactions. Performance Tuning: Use EXPLAIN ANALYZE with Aurora’s Performance Insights to identify slow queries, and leverage Prisma’s raw queries for complex window functions or JSONB operations that go beyond the ORM. Architect vector-capable extensions (pgvector) on Aurora to enable hybrid search—combining exact relational queries with similarity searches for RAG workflows, indexed via HNSW or IVFFlat for sub-50ms retrieval. Security & Identity (JWT) Architect a zero-trust JWT authentication layer implementing OAuth2 Password Flow with rotating refresh tokens. Implement fine-grained RBAC (Role-Based Access Control) and ABAC (Attribute-Based) using JWT claims and scopes. Design a secure token revocation strategy (blacklist via Redis) and handle cross-service token propagation. Ensure secure storage of secrets and implement JWT signing using RS256 (public/private key pairs) for distributed verification. AI Integration & Claude Orchestration Deeply integrate Anthropic Claude (Messages API, streaming, tool-use / function calling). Design robust, fault-tolerant retry mechanisms with exponential backoff to handle API rate limits and transient failures. Implement prompt caching strategies (if available) and context-window pruning to minimize token costs and latency while maintaining conversational state. Build structured extraction pipelines using Claude’s tool-calling capabilities, mapping raw LLM outputs to strict Pydantic models for downstream deterministic processing. AI Plugins, Skills & Spec-Driven Development (SDD) AI Plugins / MCP (Model Context Protocol): Architect an extensible plugin system where external AI agents can discover and execute backend capabilities via standardized OpenAPI schemas. You will build the scaffolding that allows third-party skills to be dynamically loaded and executed in a sandboxed environment. Skills Framework: Design a "Skill Registry" where discrete atomic actions (e.g., generate_report, query_vector_db, send_notification) are defined as executable JSON schemas, enabling Claude to autonomously select and chain these skills to fulfill complex user intents. Spec-Driven Development: Advocate and implement an API-Contract-First approach. You will write/refine OpenAPI 3.1 specifications before writing implementation code. You will utilize tools like prism for contract mocking and spectree or fastapi-openapi to enforce request/response validation strictly against the spec in testing and production. You will treat the OpenAPI spec as the single source of truth for both frontend clients and AI agents. Testing & Quality Assurance (Addressing Groovy/Python Testing) Establish a comprehensive testing pyramid: Unit, Integration, and End-to-End. Python Testing: Drive the adoption of pytest with pytest-asyncio, pytest-cov, and factory-boy for robust test fixtures. BDD / Behavior-Driven Development: While we acknowledge Groovy/Spock excellence in the Java ecosystem, we apply the same rigor here. You will implement pytest-bdd or behave to write human-readable Gherkin feature files, ensuring business logic is testable by non-engineers. CI/CD Testing: You will write and maintain the test orchestration layers in our CI pipeline (e.g., Jenkins declarative pipelines, utilizing Groovy for pipeline-as-code) to spin up ephemeral test environments, run parallelized test suites, and enforce an 80%+ coverage floor. Contract Testing: Implement Pact or schema-based contract testing between our FastAPI backend and consuming frontend/AI agents to prevent breaking changes. Required Technical Qualifications Python & Async: 5+ years of Python experience, with deep expertise in asyncio, event loops, and concurrent coroutine management. FastAPI & Pydantic: 3+ years building production systems with FastAPI. You must be comfortable with Pydantic model_validator, field_serializer, and advanced discriminated unions. JWT & Security: Proven track record implementing secure authentication pipelines. You understand the nuances of aud claims, iat/exp handling, and CSRF protection in stateless environments. LLM Integration: Hands-on experience with the Anthropic Messages API or equivalent (OpenAI). You understand tokenization, logit biases, and system prompt engineering for deterministic outputs. AI Workflows: Demonstrable experience building agentic workflows—reflection, self-correction, and tool-using agents. You must be able to articulate how you've used AI plugins/skills to decouple business logic from the LLM. Spec-Driven Development: Experience with OpenAPI 3.x, Swagger Hub, or similar. You have used specs to generate server stubs or client SDKs. Prisma & Aurora (Non-Negotiable): Production experience with Prisma Client Python (or the Node.js equivalent with strong evidence of Python adaptation) including schema design, complex include/select optimizations to prevent N+1 queries, and custom $transaction blocks for atomic multi-step AI workflows. Deep familiarity with AWS Aurora PostgreSQL, including configuring reader/writer endpoints, managing IAM database authentication, and tuning statement_timeout/idle_in_transaction_session_timeout for FastAPI workloads. You understand the difference between Aurora's shared-storage architecture and standard RDS, and you design your connection lifecycle and retry policies accordingly (e.g., handling ReadOnlyViolation after failover). Testing Tools: Advanced proficiency with pytest, httpx (for AsyncClient testing), and mocking external dependencies (respx or unittest.mock). Experience with BDD frameworks (pytest-bdd) is mandatory. Preferred Nice-to-Haves Vector Databases: Experience with pgvector on Aurora, including indexing strategies (IVFFlat vs. HNSW) and hybrid ranking (combining full-text tsvector with vector similarity). Observability: Implementing OpenTelemetry traces specifically to measure LLM latency, DB query latency, and token usage per request, with high-cardinality attributes routed to AWS X-Ray or Datadog. Prisma Middleware: Experience using Prisma’s $use middleware hooks for automatic soft-deletes, auditing (who modified what via JWT sub), or measuring query performance before execution. MCP Experience: Familiarity with the Model Context Protocol or building semantic-kernel-like connectors. Aurora Global Tables: Experience replicating Aurora across regions for disaster recovery or low-latency local reads for a global user base. The Interview Process (What we will ask) System Design: "Design an async FastAPI endpoint that accepts a complex user query, uses Claude tool-calling to break it down into 3 parallel sub-tasks, aggregates the results, and streams the final response back to the client. How do you handle JWT validation on the streaming socket?" Prisma & DB Deep Dive: "Given an Aurora PostgreSQL failover event, how does your Prisma Client handle it? Walk us through your connection retry and circuit-breaker pattern. Now, design a Prisma schema for a multi-tenant RAG system where each tenant has isolated vector embeddings." Spec Walkthrough: "Here is a business requirement. Write the OpenAPI spec for it first, then walk us through the FastAPI implementation. How does this spec enable our AI Skills framework to interact with your endpoint?" Testing Strategy: "How would you test an endpoint that relies on Claude's stochastic output? Walk us through a pytest-bdd feature file and the underlying mocks/stubs required to test the happy path and the failure path (e.g., API timeout)." Security Audit: "Given our JWT implementation, a user escalates their privileges. How do we handle this without forcing a logout? Explain the limitations of JWT and how you'd implement a refresh rotation strategy." Soft Skills & Workflows Articulate Communicator: You can explain complex AI caching strategies to a CTO just as easily as you can debug an async deadlock with a junior dev. Advocate for Quality: You are pedantic about type hints, docstrings, and pre-commit hooks. You will not merge code without a passing test suite and a reviewed OpenAPI diff. Spec First: You push back on ambiguous requirements and demand a clear API contract before typing a single line of endpoint logic. Infrastructure Aware: You treat database migrations as first-class citizens—you know that a poorly timed ALTER TABLE on a 100M-row Aurora table can take down production, and you advocate for zero-downtime migration strategies (using gh-ost or Prisma's --create-only with manual review).

  • More than 30 hrs/week
    Hourly
  • 6+ months
    Duration
  • Expert
    Experience Level
  • $50.00

    -

    $85.00

    Hourly
  • Remote Job
  • Complex project
    Project Type
Skills and Expertise
Mandatory skills
PostgreSQL
RESTful API
Activity on this job
  • Proposals:50+
  • Interviewing:
    0
  • Invites sent:
    0
  • Unanswered invites:
    0
About the client
Member since Jun 24, 2026
  • USA
    San Antonio1:23 PM
  • $823 total spent
    2 hires, 2 active
  • 30 hours

Explore similar jobs on Upwork

Solidity
Ethereum
Smart Contract
Blockchain
Cryptocurrency
Blockchain Architecture
ERC-20
API
Software Architecture & Design
Odoo
Odoo Development
Accounting

How it works

  • Post a job icon
    Create your free profile
    Highlight your skills and experience, show your portfolio, and set your ideal pay rate.
  • Talent comes to you icon
    Work the way you want
    Apply for jobs, create easy-to-by projects, or access exclusive opportunities that come to you.
  • Payment simplified icon
    Get paid securely
    From contract to payment, we help you work safely and get paid securely.
Want to get started? Create a profile

About Upwork

  • Rating is 4.9 out of 5.
    4.9/5
    (Average rating of clients by professionals)
  • G2 2021
    #1 freelance platform
  • 49,000+
    Signed contract every week
  • $2.3B
    Freelancers earned on Upwork in 2020

Find the best freelance jobs

Growing your career is as easy as creating a free profile and finding work like this that fits your skills.

Trusted by

  • Microsoft Logo
  • Airbnb Logo
  • Bissell Logo
  • GoDaddy Logo