python-samples-fastapi-restful

作者 nanotaboada已验证

🧪 Proof of Concept for a RESTful API built with Python 3 and FastAPI

129
Stars
23
Forks
Python
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/nanotaboada/python-samples-fastapi-restful

快速入门

使用 python-samples-fastapi-restful 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

🧪 RESTful API with Python 3 and FastAPI

Python CI Python CD CodeQL Advanced Quality Gate Status codecov CodeFactor License: MIT Code style: black Dependabot Copilot Claude CodeRabbit

Proof of Concept for a RESTful Web Service built with FastAPI and Python 3.13. This project demonstrates best practices for building a layered, testable, and maintainable API implementing CRUD operations for a Players resource (Argentina 2022 FIFA World Cup squad).

Features

  • 🏗️ Async Architecture - Async/await throughout with SQLAlchemy 2.0 and dependency injection via FastAPI's Depends()
  • 📚 Interactive Documentation - Auto-generated Swagger UI with VS Code and JetBrains REST Client support
  • Performance Caching - In-memory caching with aiocache and async SQLite operations
  • Input Validation - Pydantic models enforce request/response schemas with automatic error responses
  • 🐳 Containerized Deployment - Production-ready Docker setup with migration-based database initialization
  • 🔄 Automated Pipeline - Continuous integration with Black, Flake8, and automated testing

Tech Stack

CategoryTechnology
LanguagePython 3.13
Web FrameworkFastAPI + Uvicorn
ORMSQLAlchemy 2.0 (async) + aiosqlite
DatabaseSQLite
ValidationPydantic
Cachingaiocache (in-memory, 10-minute TTL)
Testingpytest + pytest-cov + httpx
Linting / FormattingFlake8 + Black
ContainerizationDocker & Docker Compose

Architecture

Layered architecture with dependency injection via FastAPI's Depends() mechanism and Pydantic for request/response validation.

%%{init: {
  "theme": "default",
  "themeVariables": {
    "fontFamily": "Fira Code, Consolas, monospace",
    "textColor": "#555",
    "lineColor": "#555"
  }
}}%%

graph RL

    tests[tests]

    main[main]
    routes[routes]
    fastapi[FastAPI]
    aiocache[aiocache]

    services[services]

    models[models]
    pydantic[Pydantic]

    schemas[schemas]

    databases[databases]
    sqlalchemy[SQLAlchemy]

    %% Strong dependencies

    routes --> main
    fastapi --> main

    fastapi --> routes
    aiocache --> routes
    services --> routes
    models --> routes
    databases --> routes

    schemas --> services
    models --> services
    sqlalchemy --> services
    pydantic --> models

    databases --> schemas
    sqlalchemy --> schemas
    sqlalchemy --> databases

    %% Soft dependencies

    sqlalchemy -.-> routes
    main -.-> tests

    %% Node styling with stroke-width
    classDef core fill:#b3d9ff,stroke:#6db1ff,stroke-width:2px,color:#555,font-family:monospace;
    classDef deps fill:#ffcccc,stroke:#ff8f8f,stroke-width:2px,color:#555,font-family:monospace;
    classDef test fill:#ccffcc,stroke:#53c45e,stroke-width:2px,color:#555,font-family:monospace;

    class main,routes,services,schemas,databases,models core
    class fastapi,sqlalchemy,pydantic,aiocache deps
    class tests test

Arrows follow the injection direction (A → B means A is injected into B). Solid = runtime dependency, dotted = structural. Blue = core domain, red = third-party, green = tests.

Significant architectural decisions are documented in docs/adr/.

API Reference

Interactive API documentation is available via Swagger UI at http://localhost:9000/docs when the server is running.

MethodEndpointDescriptionStatus
GET/players/List all players200 OK
GET/players/{player_id}Get player by ID200 OK
GET/players/squadnumber/{squad_number}Get player by squad number200 OK
POST/players/Create new player201 Created
PUT/players/squadnumber/{squad_number}Update player by squad number204 No Content
DELETE/players/squadnumber/{squad_number}Remove player by squad number204 No Content
GET/healthHealth check200 OK

Error codes: 400 Bad Request (squad number mismatch on PUT) · 404 Not Found (player not found) · 409 Conflict (duplicate squad number on POST) · 422 Unprocessable Entity (schema validation failed)

For complete endpoint documentation with request/response schemas, explore the interactive Swagger UI.

Alternatively, use rest/players.rest with the REST Client extension for VS Code, or the built-in HTTP Client in JetBrains IDEs (IntelliJ IDEA, PyCharm, WebStorm).

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.13+ — uses .python-version for automatic activation with pyenv, asdf, or mise
  • uv (recommended) — fast Python package and project manager
  • Docker & Docker Compose (optional, for containerized deployment)

Quick Start

Clone

git clone https://github.com/nanotaboada/python-samples-fastapi-restful.git
cd python-samples-fastapi-restful

Install

Dependencies are defined in pyproject.toml using PEP 735 dependency groups.

# Install uv (if you haven't already)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create a virtual environment and install all dependencies
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install --group dev
CommandDescription
uv pip installProduction dependencies only
uv pip install --group testTest dependencies
uv pip install --group lintLinting dependencies
uv pip install --group devAll (test + lint + production)

Run

# Apply database migrations (required once before the first run, and after
# docker compose down -v)
uv run alembic upgrade head

uv run uvicorn main:app --reload --port 9000

Access

Once the application is running, you can access:

  • API Server: http://localhost:9000
  • Swagger UI: http://localhost:9000/docs
  • Health Check: http://localhost:9000/health

Containers

Build and Start

docker compose up

💡 Note: On first run, the entrypoint applies Alembic migrations (alembic upgrade head), which creates the database and seeds all 26 players. On subsequent runs, migrations are a no-op and the volume data is preserved.

Stop

docker compose down

Reset Database

To remove the volume and re-apply migrations from scratch on next start:

docker compose down -v

Pull Docker Images

Each release publishes multiple tags for flexibility:

# By semantic version (recommended for production)
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:1.0.0

# By coach name (memorable alternative)
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:ancelotti

# Latest release
docker pull ghcr.io/nanotaboada/python-samples-fastapi-restful:latest

Environment Variables

# Full async database URL (SQLite default, PostgreSQL compatible)
# SQLite (local/test):
DATABASE_URL=sqlite+aiosqlite:///./players-sqlite3.db
# PostgreSQL (Docker/production):
DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/playersdb

# Legacy: SQLite file path — used only when DATABASE_URL is not set
STORAGE_PATH=./players-sqlite3.db

# Python output buffering: set to 1 for real-time logs in Docker
PYTHONUNBUFFERED=1

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details on:

  • Code of Conduct
  • Development workflow and best practices
  • Commit message conventions (Conventional Commits)
  • Pull request process and requirements

Key guidelines:

  • Follow Conventional Commits for commit messages
  • Ensure all tests pass (uv run pytest)
  • Run uv run black . before committing
  • Keep changes small and focused
  • Review .github/copilot-instructions.md for architectural patterns

Testing:

Run the test suite with pytest:

# Run all tests
uv run pytest

# Run tests with coverage report
uv run pytest --cov=./ --cov-report=term

Command Summary

CommandDescription
uv run uvicorn main:app --reload --port 9000Start development server
uv pip install --group devInstall all dependencies
uv run pytestRun all tests
uv run pytest --cov=./ --cov-report=termRun tests with coverage
uv run flake8 .Lint code
uv run black --check .Check formatting
uv run black .Auto-format code
docker compose buildBuild Docker image
docker compose upStart Docker container
docker compose downStop Docker container
docker compose down -vStop and remove Docker volume
AI Commands
/pre-commitRuns linting, tests, and quality checks before committing
/pre-releaseRuns pre-release validation workflow

Legal

This project is provided for educational and demonstration purposes and may be used in production at your own discretion. All trademarks, service marks, product names, company names, and logos referenced herein are the property of their respective owners and are used solely for identification or illustrative purposes.

常见问题

What is python-samples-fastapi-restful?

python-samples-fastapi-restful is an open-source testing skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by nanotaboada. 🧪 Proof of Concept for a RESTful API built with Python 3 and FastAPI. It has 129 GitHub stars.

Is python-samples-fastapi-restful safe to use?

Yes. python-samples-fastapi-restful passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install python-samples-fastapi-restful?

Clone the repository with "git clone https://github.com/nanotaboada/python-samples-fastapi-restful" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is python-samples-fastapi-restful written in?

python-samples-fastapi-restful is primarily written in Python. It is open-source under nanotaboada on GitHub, so you can review or fork the full source.

Are there alternatives to python-samples-fastapi-restful?

Yes. SkillsLLM lists many other Testing skills you can browse and compare side by side. Open the Testing category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh python-samples-fastapi-restful against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

Claude-BugHunter

by elementalsouls

A Claude Code skill bundle for bug hunting and external red-team work - 82 skills, 15 slash commands, 681 disclosed-report patterns curated across 24 core vulnerability classes, plus enterprise identity + infrastructure attack matrices.

3,740578Python
Testing
查看详情

Rapid-MLX

by raullenchai

The fastest local AI engine for Apple Silicon. 4.2x faster than Ollama, 0.08s cached TTFT, 100% tool calling. 17 tool parsers, prompt cache, reasoning separation, cloud routing. Drop-in OpenAI replacement. Works with Claude Code, Cursor, Aider.

3,530401Python
Testing
查看详情

playwright-skill

by lackeyjb

Claude Code Skill for browser automation with Playwright. Model-invoked - Claude autonomously writes and executes custom automation for testing and validation.

3,014229JavaScript
Testing
查看详情

src-hunter-skill

by MyuriKanao

实战 SRC / 众测 / Bug bounty 漏洞挖掘 Claude Code skill — 19 个攻击类 playbook、305 个结构化 payload、263 个 WAF/EDR 绕过、2887 份 HackerOne 真实案例、88,636 WooYun 案例统计

60187
Testing
查看详情

100 field-tested Claude Code recipes for knowledge workers — prompts, steps, and 6 installable graded skills.

38048
Testing
查看详情

Claude Code Skill that turns any idea into a cinematic, model-ready video prompt — Sora · Kling · Veo · Seedance. 21 genre templates, 5-stage structure, eval-tested. Distilled from the AI short Hollywood director PJ Ace called "one of the best short films I've seen in years."

36869Python
Testing
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情