{"id":23137183,"url":"https://github.com/saif807380/fastapi-starter-template","last_synced_at":"2026-02-14T03:07:46.098Z","repository":{"id":129160568,"uuid":"332238077","full_name":"Saif807380/fastapi-starter-template","owner":"Saif807380","description":"Opinionated FastAPI template bootstrapped with authentication, database configuration and testing","archived":false,"fork":false,"pushed_at":"2022-06-01T02:41:19.000Z","size":127,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T05:24:17.004Z","etag":null,"topics":["fastapi","fastapi-boilerplate","fastapi-jwt","fastapi-sqlalchemy","fastapi-template","starter-template"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Saif807380.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"github":["Saif807380"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-01-23T15:08:20.000Z","updated_at":"2024-11-09T07:00:52.000Z","dependencies_parsed_at":"2023-03-30T21:45:49.895Z","dependency_job_id":null,"html_url":"https://github.com/Saif807380/fastapi-starter-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Saif807380/fastapi-starter-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saif807380%2Ffastapi-starter-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saif807380%2Ffastapi-starter-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saif807380%2Ffastapi-starter-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saif807380%2Ffastapi-starter-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Saif807380","download_url":"https://codeload.github.com/Saif807380/fastapi-starter-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Saif807380%2Ffastapi-starter-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270837402,"owners_count":24654374,"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-08-17T02:00:09.016Z","response_time":129,"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-boilerplate","fastapi-jwt","fastapi-sqlalchemy","fastapi-template","starter-template"],"created_at":"2024-12-17T12:27:07.803Z","updated_at":"2026-02-14T03:07:41.052Z","avatar_url":"https://github.com/Saif807380.png","language":"Python","funding_links":["https://github.com/sponsors/Saif807380"],"categories":[],"sub_categories":[],"readme":"![Auto Generated Docs](https://github.com/Saif807380/fastapi-starter-template/blob/main/images/Screenshot%202021-01-23%20at%2022.25.36.png)\n\n# FastAPI Starter Template\n\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-sucess.svg)](https://gitHub.com/preprocessy/preprocessy/graphs/commit-activity)\n[![Issues Open](https://img.shields.io/github/issues/Saif807380/fastapi-starter-template)](https://github.com/Saif807380/fastapi-starter-template/issues)\n[![Forks](https://img.shields.io/github/forks/Saif807380/fastapi-starter-template)](https://github.com/Saif807380/fastapi-starter-template/network/members)\n[![Stars](https://img.shields.io/github/stars/Saif807380/fastapi-starter-template)](https://github.com/Saif807380/fastapi-starter-template/stargazers)\n[![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](https://github.com/Saif807380/fastapi-starter-template/issues)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nAn opinionated template that will help you get quickly setup with a FastAPI backend with minimal configuration.\n\n## Features\n\n- A dedicated folder structure for supporting big projects\n\n- Boilerplate code for user authentication\n\n- Minimal Database configuration using `SQLAlchemy` which supports many databases\n\n- `JWT` and `CORS` middleware configured out of the box\n\n- Testing environment using `pytest`\n\n## Requirements\n\n```\nbcrypt\nfastapi\npasslib\npydantic\npython-dotenv\npython-jose\npython-multipart\nSQLAlchemy\nstarlette\nuvicorn\n```\n\nFor development requirements see [Contributing Guidelines](https://github.com/Saif807380/fastapi-starter-template/blob/main/CONTRIBUTING.md)\n\n## Quick Setup\n\n1. Clone the Template\n\n```bash\n$ git clone https://github.com/Saif807380/fastapi-starter-template\n```\n\n2. Create a `virtual environment` and install the requirements\n\n```bash\n$ pip install -r requirements.txt\n```\n\n3. Setup your [environment](#environment)\n\n4. Run the project\n\n  - Using `main.py`\n\n  ```bash\n  // using main.py\n\n  $ cd src/app\n\n  $ python main.py\n\n  ```\n\n  - Using `uvicorn` command\n\n  ```bash\n  $ uvicorn --app-dir=\"./src/app\" --reload main:app\n  ```\n\n## Project Structure\n\n```\n.\n├── LICENSE\n├── README.md\n├── requirements.txt\n├── requirements_dev.txt\n├── src\n│   └── app\n│       ├── __init__.py\n│       ├── database\n│       │   ├── __init__.py\n│       │   ├── db.py\n│       │   ├── models.py\n│       │   ├── queries.py\n│       │   └── schemas.py\n│       ├── exceptions\n│       │   ├── __init__.py\n│       │   └── user.py\n│       ├── helpers\n│       │   └── auth.py\n│       ├── main.py\n│       ├── middleware\n│       │   ├── __init__.py\n│       │   └── auth.py\n│       └── routers\n│           ├── __init__.py\n│           └── auth.py\n└── tests\n    ├── __init__.py\n    ├── conftest.py\n    └── test_auth.py\n```\n\n### Routes\n\nYou can add new routes for resources inside the `routers` directory using FastAPI's `APIRouter`. Out of the box, the routes for user creation and authentication have been provided with `JWT` support.\n\n### Database\n\nThe `database` directory holds all database, models and schema related files. You can set your `DATABASE_URL` in the environment and the `SQLAlchemy` engine in `database/db.py` will create the required sessions and connections.\n\nAll your database models go inside the `database/models.py` file. These are standard `SQLAlchemy` models.\n\n`Pydantic` schemas for data validation reside in the `database/schemas.py` file. There can be 2 schemas defined for each resource, `ResourceBase` which validates the request body and `ResourceSchema` which resembles the database resource item.\n\n### Middleware\n\nAll the app-wide applicable middleware can be added to `main.py` directly. Middleware applicable to specific routes can be placed inside the `middleware` directory.\n\nThe `is_autheticated` middleware checks for valid `JWT` tokens and can be added to routes as a dependency.\n\nThe `CORS` middleware is added app-wide and list of origins can be changed inside `main.py`.\n\n### Exceptions\n\nYou can put your custom exceptions inside `exceptions` directory.\n\n### Testing\n\nTesting is done using `pytest` and `fastapi.test_client`. You can add your tests inside the `tests` directory. You add your custom `pytest fixtures` inside `conftest.py` file. Currently, tests are run against the production database but they will shifted to a test database soon.\n\nYou can run the tests from inside the project folder\n\n```bash\n$ pytest\n```\n\n### Environment\n\nYou need to set the following environment variables\n\n```\nSECRET_KEY                    // JWT secret\nALGORITHM                     // Algorithm for encoding JWT\nACCESS_TOKEN_EXPIRE_MINUTES   // JWT token expiration in minutes\nDATABASE_URL                  // Database URL\n```\n\nYou can generate a secure `SECRET_KEY` using -\n\n```bash\n$ openssl rand -hex 32\n```\n\nSee this for a list of [supported encoding algorithms](https://python-jose.readthedocs.io/en/latest/jws/index.html#supported-algorithms).\n\n### Helpers\n\nYou can add your helper functions to `helpers` directory.\n\n## Contributing\n\nPlease read the [Contributing Guide](https://github.com/Saif807380/fastapi-starter-template/blob/main/CONTRIBUTING.md) before submitting a Pull Request to the project.\n\n## Support\n\nFeel free to [contact me](https://www.saif-kazi.tech). I'm happy to help!\n\n## License\n\nSee the [LICENSE](https://github.com/Saif807380/fastapi-starter-template/blob/main/LICENSE) file for licensing information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaif807380%2Ffastapi-starter-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaif807380%2Ffastapi-starter-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaif807380%2Ffastapi-starter-template/lists"}