{"id":31721009,"url":"https://github.com/preritdas/api-factory","last_synced_at":"2026-04-17T06:32:28.274Z","repository":{"id":260827571,"uuid":"882459628","full_name":"preritdas/api-factory","owner":"preritdas","description":"Personal starter pack for FastAPI Python API servers.","archived":false,"fork":false,"pushed_at":"2026-03-03T17:49:32.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-03T21:31:53.484Z","etag":null,"topics":["api","fastapi","fastapi-template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preritdas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-11-02T20:40:28.000Z","updated_at":"2026-03-03T17:49:34.000Z","dependencies_parsed_at":"2024-11-02T21:25:32.885Z","dependency_job_id":"5f30180a-e3ed-4927-94d8-4445d3d30844","html_url":"https://github.com/preritdas/api-factory","commit_stats":null,"previous_names":["preritdas/api-factory"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/preritdas/api-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preritdas%2Fapi-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preritdas%2Fapi-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preritdas%2Fapi-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preritdas%2Fapi-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preritdas","download_url":"https://codeload.github.com/preritdas/api-factory/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preritdas%2Fapi-factory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31918479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"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":["api","fastapi","fastapi-template"],"created_at":"2025-10-09T03:22:18.808Z","updated_at":"2026-04-17T06:32:28.246Z","avatar_url":"https://github.com/preritdas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![tests](https://github.com/ORGANIZATION/REPO/actions/workflows/tests.yaml/badge.svg)](https://github.com/ORGANIZATION/REPO/actions/workflows/tests.yaml)\n[![cloud run deployment](https://github.com/ORGANIZATION/REPO/actions/workflows/google-cloud.yaml/badge.svg)](https://github.com/ORGANIZATION/REPO/actions/workflows/google-cloud.yaml)\n\n\n# FastAPI Factory\n\nA factory for a FastAPI application. Comes with credential management, global configuration, routers, a test suite, CI/CD, production/QA pipelines, logging (including instrumentation to see all route traffic), and a containerized development environment. \n\n## Setup\n\n1. Set API titles, descriptions, etc. in `api/__init__.py`. `module` is the main application package––change the name, and update `tests/test_modules.py` to reflect the new name.\n2. Set the name of the GCP project and container in `.github/workflows/google-cloud.yaml` and `.github/workflows/deploy-preview.yaml`.\n   - `:%s/CONTAINER_NAME/NEW_NAME/g` and `:%s/GCP_PROJECT/NEW_NAME/g`\n   - Google Cloud setup: Create a service account with permissions Service Account User, Cloud Run Admin, Storage Admin, Artifact Registry Admin, and Artifact Registry Create-on-Push Admin. Make sure the Artifact Registry Admin API and Cloud Run Admin API are enabled.\n3. Add secrets to GitHub Actions: `KEYS_YAML` and `KEYS_YAML_TESTS`. The first is for the main branch, the second is for pull requests. These follow the same format. Also add `GCP_SA_KEY` to the secrets.\n4. Once a few cloud deployments have gone through, you may have to manually update traffic in the Cloud Run UI to the latest revision. \n\n## Keys Structure\n\nThe keys structure in this project is defined using Pydantic BaseModels. This approach provides type checking and validation for your configuration.\n\n### BaseModel Structure\n\nThe structure of the keys is defined in `keys/models.py`. Here's how it works:\n\n1. Individual provider models:\n   ```python\n   class ProviderNameModel(BaseModel):\n       api_key: str\n   ```\n\n2. Main Keys model:\n   ```python\n   class Keys(BaseModel):\n       Provider: ProviderNameModel\n   ```\n   This model combines all provider models into a single structure.\n\nTo access keys throughout your API:\n\n1. Import the `KEYS` object at the top of your file:\n   ```python\n   from keys import KEYS\n   ```\n\n2. Access the keys using dot notation:\n   ```python\n   api_key = KEYS.Provider.api_key\n   ```\n\n## Running\n\n```bash\nfastapi run api --app app\n```\n\nWhere `api` is the module and `app` is the variable name of the FastAPI application object. To run with multiple workers:\n\n```bash\nfastapi run api --app app --workers 4\n```\n\nThe number of workers should be $(2* numcores) + 1$. Don't include vCPUs in the calculation of $numcores$. So use 5 workers for a 2 CPU cores deployment. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreritdas%2Fapi-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreritdas%2Fapi-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreritdas%2Fapi-factory/lists"}