{"id":28003130,"url":"https://github.com/rahulsamant37/fastapi_versioning-template","last_synced_at":"2026-05-16T08:39:24.125Z","repository":{"id":291615954,"uuid":"978196508","full_name":"rahulsamant37/FASTAPI_versioning-Template","owner":"rahulsamant37","description":"A comprehensive demonstration of API versioning strategies in FastAPI, showcasing three different approaches to help developers choose the right architecture for their needs.","archived":false,"fork":false,"pushed_at":"2025-05-05T16:35:11.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-09T01:51:18.144Z","etag":null,"topics":["fastapi","fastapi-template","fastapi-versioning","help-others","microservices"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahulsamant37.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-05T16:04:33.000Z","updated_at":"2025-05-05T16:49:13.000Z","dependencies_parsed_at":"2025-05-05T17:39:24.520Z","dependency_job_id":"1e4c2cc3-657d-427b-a54a-822c643561ed","html_url":"https://github.com/rahulsamant37/FASTAPI_versioning-Template","commit_stats":null,"previous_names":["rahulsamant37/fastapi-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rahulsamant37/FASTAPI_versioning-Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FFASTAPI_versioning-Template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FFASTAPI_versioning-Template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FFASTAPI_versioning-Template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FFASTAPI_versioning-Template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahulsamant37","download_url":"https://codeload.github.com/rahulsamant37/FASTAPI_versioning-Template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahulsamant37%2FFASTAPI_versioning-Template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267470062,"owners_count":24092352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","fastapi-template","fastapi-versioning","help-others","microservices"],"created_at":"2025-05-09T01:50:31.290Z","updated_at":"2026-05-16T08:39:24.077Z","avatar_url":"https://github.com/rahulsamant37.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI API Versioning Template\n\nA comprehensive demonstration of API versioning strategies in FastAPI, showcasing three different approaches to help developers choose the right architecture for their needs.\n\n## 🎯 Purpose\n\nThis template demonstrates the evolution of API versioning from basic to advanced implementations, helping developers:\n- Understand different versioning strategies\n- Maintain backward compatibility\n- Scale APIs effectively\n- Choose the right approach based on project size\n\n##  Project Structure\n\n```\nfastapi-template/\n├── proj_1/              # Basic API versioning\n│   └── main.py         # All-in-one implementation\n├── proj_2/              # Structured versioning\n│   └── app/\n│       ├── controllers/  # Route handlers\n│       ├── services/    # Business logic\n│       └── models/      # Data schemas\n├── proj_3/              # Full modular versioning\n│   └── app/\n│       ├── controllers/\n│       │   ├── v1/     # Version 1 routes\n│       │   └── v2/     # Version 2 routes\n│       ├── services/\n│       │   ├── v1/     # Version 1 business logic\n│       │   └── v2/     # Version 2 business logic\n│       └── models/     # Shared data models\n└── main.py             # Example of problematic versioning\n```\n\n## ⚡ Quick Start\n\n1. **Clone and Setup**\n```bash\ngit clone https://github.com/rahulsamant37/FASTAPI_versioning-Template.git\ncd FASTAPI_versioning-Template\nuv venv\nsource .venv/bin/activate  # On Windows: .\\.venv\\Scripts\\activate\n```\n\n2. **Install Dependencies**\n```bash\nuv add fastapi\n```\n\n3. **Run Any Example**\n```bash\n# Basic versioning (Project 1)\nuvicorn proj_1.main:app --reload\n\n# Structured versioning (Project 2)\nuvicorn proj_2.app.main:app --reload\n\n# Full modular versioning (Project 3)\nuvicorn proj_3.app.main:app --reload\n```\n\n## 🔗 API Endpoints\n\n### V1 API (`/api/v1`)\n| Method | Endpoint | Description | Response |\n|--------|----------|-------------|----------|\n| GET | `/users` | List all users | `List[UserV1]` |\n| GET | `/users/{id}` | Get user by ID | `UserV1` |\n\n### V2 API (`/api/v2`)\n| Method | Endpoint | Description | Response |\n|--------|----------|-------------|----------|\n| GET | `/users` | List all users with email | `List[UserV2]` |\n| GET | `/users/{id}` | Get user by ID with email | `UserV2]` |\n\n## 🛠️ Implementation Approaches\n\n### 1. Basic Router-based (proj_1)\n- Single file implementation\n- Uses FastAPI's `APIRouter`\n- Suitable for: Small APIs, Prototypes\n- Pros: Simple, Quick to implement\n- Cons: Limited scalability\n\n### 2. Structured (proj_2)\n- MVC-like architecture\n- Shared service layer\n- Suitable for: Medium-sized APIs\n- Pros: Good organization, Maintainable\n- Cons: Some version coupling\n\n### 3. Full Modular (proj_3)\n- Complete version isolation\n- Independent services per version\n- Suitable for: Large APIs, Enterprise\n- Pros: Highly maintainable, Scalable\n- Cons: More complex setup\n\n## 📋 Technical Details\n\n### Dependencies\n```toml\npython = \"\u003e=3.12\"\nfastapi = \"\u003e=0.115.12\"\npydantic = \"\u003e=2.0.0\"\nuvicorn = \"\u003e=0.24.0\"\nemail-validator = \"\u003e=2.0.0\"  # For email validation\n```\n\n### Key Features\n- ✅ Type-safe with Pydantic models\n- ✅ Async/await support\n- ✅ OpenAPI documentation\n- ✅ Dependency injection\n- ✅ Clear version boundaries\n\n## 📚 Documentation\n\n- **API Documentation**: Available at `/docs` (Swagger) and `/redoc` (ReDoc)\n- **Version Management**: \n  - V1: Basic user info (id, name)\n  - V2: Extended user info (id, name, email)\n\n## 🔍 Best Practices\n\n1. **Version Prefixing**\n   - Clear URL versioning (`/api/v1`, `/api/v2`)\n   - Consistent version naming\n\n2. **Code Organization**\n   - Separation of concerns\n   - Clear module boundaries\n   - Version-specific services\n\n3. **Type Safety**\n   - Pydantic models for validation\n   - Comprehensive type hints\n   - Version-specific schemas\n\n4. **Backward Compatibility**\n   - Maintained across versions\n   - Clear upgrade paths\n   - Version-specific responses\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulsamant37%2Ffastapi_versioning-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahulsamant37%2Ffastapi_versioning-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahulsamant37%2Ffastapi_versioning-template/lists"}