{"id":24573874,"url":"https://github.com/zhiwei2017/fastapi-cookiecutter","last_synced_at":"2025-07-20T00:32:55.947Z","repository":{"id":57428473,"uuid":"316014969","full_name":"zhiwei2017/FastAPI-Cookiecutter","owner":"zhiwei2017","description":"A cookiecutter template for FastAPI projects","archived":false,"fork":false,"pushed_at":"2024-02-03T21:26:00.000Z","size":2827,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-05-19T10:07:04.722Z","etag":null,"topics":["cicd","cookiecutter-template","fastapi-template","oauth2","python3"],"latest_commit_sha":null,"homepage":"https://zhiwei2017.github.io/FastAPI-Cookiecutter/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhiwei2017.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","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":"2020-11-25T17:52:35.000Z","updated_at":"2025-05-12T06:25:02.000Z","dependencies_parsed_at":"2025-04-23T10:25:17.983Z","dependency_job_id":"9df009ef-f4ca-4f07-8c8d-1c7855bae2e9","html_url":"https://github.com/zhiwei2017/FastAPI-Cookiecutter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zhiwei2017/FastAPI-Cookiecutter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhiwei2017%2FFastAPI-Cookiecutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhiwei2017%2FFastAPI-Cookiecutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhiwei2017%2FFastAPI-Cookiecutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhiwei2017%2FFastAPI-Cookiecutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhiwei2017","download_url":"https://codeload.github.com/zhiwei2017/FastAPI-Cookiecutter/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhiwei2017%2FFastAPI-Cookiecutter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266048614,"owners_count":23868743,"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","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":["cicd","cookiecutter-template","fastapi-template","oauth2","python3"],"created_at":"2025-01-23T20:22:35.864Z","updated_at":"2025-07-20T00:32:55.936Z","avatar_url":"https://github.com/zhiwei2017.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"FastAPI Cookiecutter Template\n=============================\n\nIntroduction\n------------\nThis projects consist of a `cookiecutter`_ template that generates a full structure\nfor creating a RESTful API service project based on FastAPI following the MVC\n(Model-View-Controller) structure in the same way Django projects does.\n\nWhile using this project, you will be asked to provide some inputs such the authors, the name of the project, etc. As result you will obtain the\ncomplete file and folder structure to quickly start to code your project.\n\nPrerequisites\n-------------\nIt uses ``Python`` (\u003e=3.7) behind the scenes. Please install the Python package `cookiecutter`_ before using it.\n\n\n\nProject Generation Options\n--------------------------\n\nproject_name:\n  Your project's human-readable name, capitals and spaces allowed.\n\nproject_slug:\n    Your project's slug without dashes or spaces. Used to name your repo\n    and in other places where a Python-importable version of your project name\n    is needed.\n\nproject_url:\n    The url of your project hosted in gitlab or github.\n\nauthor:\n    This is you! The value goes into places like ``README.md`` and such.\n\nemail:\n    The email address you want to identify yourself in the project.\n\nshort_description:\n    Describes your project briefly and gets used in places like ``README.md`` and ``setup.py``.\n\nversion:\n    The version of the project at its inception.\n\nuse_oauth:\n    Indicates whether the project should be configured for using OAuth2 authentication. The choices are:\n\n    1. No\n    2. Yes\n\nuse_database:\n    Indicates whether the project should be configured for using database. The choices are:\n\n    1. No\n    2. Yes\n\nci_tool:\n    Select a CI tool. The choices are:\n\n    1. GitHub\n    2. GitLab\n    3. Bitbucket\n    4. None\n\nci_tool:\n    Select the python version for configuring the created project's CI/CD pipeline. The choices are:\n\n    1. 3.10\n    2. 3.11\n    3. 3.9\n    4. 3.8\n    5. 3.7\n\nTutorial\n--------\nLet's pretend you want to create a FastAPI project called \"redditclone\".\nBy using this template based on `cookiecutter`_,\nyou will be able to quickly setup a runnable FastAPI project.\n\nFirst, get Cookiecutter. Trust me, it's awesome::\n\n     $ pip install \"cookiecutter\u003e=1.7.0\"\n\nNow run it against this repo::\n\n     $ cookiecutter https://github.com/zhiwei2017/FastAPI-Cookiecutter.git\n\nYou'll be prompted for some values. Provide them, then a FastAPI project will be created for you.\n\n**Warning**: After this point, change 'My Awesome Project', 'John Doe', etc to your own information.\n\nAnswer the prompts with your own desired `Project Generation Options \u003c./docs/source/02_prompts.rst\u003e`_. For example::\n\n    Cloning into 'fastapi-cookiecutter'...\n    remote: Enumerating objects: 219, done.\n    remote: Counting objects: 100% (219/219), done.\n    remote: Compressing objects: 100% (123/123), done.\n    remote: Total 219 (delta 83), reused 181 (delta 69), pack-reused 0\n    Receiving objects: 100% (219/219), 41.09 KiB | 1.71 MiB/s, done.\n    Resolving deltas: 100% (83/83), done.\n    project_name [My Awesome Project]: Reddit Clone\n    project_slug [reddit_clone]: reddit_clone\n    project_url [https://github.com/example_project]: https://github.com/redditclone\n    author [John Doe]: John Doe\n    email [john-doe@example.com]: john.doe@example.com\n    short_description [Behold My Awesome Project!]: A reddit clone.\n    version [0.0.1]: 0.1.0\n    Select use_oauth:\n    1 - No\n    2 - Yes\n    Choose from 1, 2 [1]: 1\n    Select use_database:\n    1 - Yes\n    2 - No\n    Choose from 1, 2 [1]: 1\n    Select ci_tool:\n    1. GitHub\n    2. GitLab\n    3. Bitbucket\n    4. None\n    Choose from 1, 2 [1]: 1\n    Select python_version:\n    1. 3.10\n    2. 3.11\n    3. 3.9\n    4. 3.8\n    5. 3.7\n    Choose from 1, 2 [1]: 1\n\nEnter the project and take a look around::\n\n    $ cd reddit_clone/\n    $ ls\n\nNow take a look at your repo. Don't forget to carefully look at the generated **README**.\n\nProject Structure\n-----------------\n\nFiles related to application are in the ``src`` or ``tests`` directories.\nApplication components are::\n\n    {{cookiecutter.project_slug}}\n    ├── docs                            - sphinx documentastion\n    ├── scripts                         - scripts\n    │   └── prestart.sh\n    ├── {{cookiecutter.project_slug}}\n    │   ├── app\n    │   │   ├── api                     - api endpoints\n    │   │   │   └── base.py             - basic endpoints\n    │   │   ├── application.py          - function for FastAPI application creation and configuration\n    │   │   ├── configs                 - application configuration\n    │   │   │   └── base.py             - basic configuration class\n    │   │   ├── constants.py            - constants used inside the application\n    │   │   ├── db                      - database related stuff\n    │   │   │   ├── base.py             - base sqlalchemy DB model class\n    │   │   │   ├── models              - folder for defining sqlalchemy DB model classes\n    │   │   │   ├── queries             - folder for predefined sqlalchemy queries\n    │   │   │   └── session.py          - a local session instance used inside application\n    │   │   ├── events                  - events for startup, shutdown\n    │   │   │   └── base.py             - dummy startup event and shudown event\n    │   │   ├── globals.py              - global variables\n    │   │   ├── middlewares             - middleware stuff\n    │   │   │   └── logging.py          - middleware function related to logging\n    │   │   ├── schemas                 - pydantic models for this application\n    │   │   │   └── base.py             - pydantic models for the basic endpoints\n    │   │   ├── services                - logic that is not included in the other folders\n    │   │   ├── utils                   - utility stuff\n    │   │   │   ├── errors.py           - customized exception classes\n    │   │   │   ├── logging.py          - logging related utility functions, classes\n    │   │   │   └── security.py         - security related functions, classes\n    │   │   └── version.py              - version information\n    │   ├── data                        - data used for this application\n    │   └── main.py                     - main function to run the application\n    ├── tests                           - unit tests\n    │   ├── conftest.py                 - fixtures in tests\n    │   ├── resources                   - resources used in tests\n    │   └── ...\n    ├── Dockerfile                      - docker file for building docker image\n    ├── Makefile                        - predefined commands\n    ├── README.md                       - package information\n    ├── requirements                - package dependencies\n    │   ├── base.txt                - documentation dependecies\n    │   ├── doc.txt                 - documentation dependecies\n    │   ├── dev.txt                 - tests dependencies\n    ├── setup.cfg                       - configurations for mypy, bandit, pytest etc. Centralizing all the configurations to one place.\n    └── setup.py                        - package installation configuration\n\nAdvanced Usage\n--------------\n``Gunicorn`` Configuration\n**************************\nA default ``gunicorn-conf.py`` file is included in the docker image and will be\nexecuted before your service is up. It supports configuration through environment\nvariables. Please check the section `Environment variables \u003chttps://github.com/tiangolo/uvicorn-gunicorn-docker#environment-variables\u003e`_\nfrom `uvicorn-gunicorn-docker`_ project\nfor more detailed information. The suggested approach for defining environment variables\nis to use the ``scrtips/prestart.sh`` file.\n\nIn case you need to customize the ``Gunicorn`` configuration file, please check the\ndefault `gunicorn-conf.py \u003chttps://github.com/tiangolo/uvicorn-gunicorn-docker/blob/master/docker-images/gunicorn_conf.py\u003e`_ file\nand read the section `Custom Gunicorn configuration file \u003chttps://github.com/tiangolo/uvicorn-gunicorn-docker#custom-gunicorn-configuration-file\u003e`_\nfrom `uvicorn-gunicorn-docker`_ project firstly.\n\nCustomize ``prestart`` Hook\n***************************\nIf you need to run anything before starting the app, you can add a file ``prestart.sh`` to the directory ``scripts``.\nPlease check the section `Custom /app/prestart.sh \u003chttps://github.com/tiangolo/uvicorn-gunicorn-docker#custom-appprestartsh\u003e`_\nfrom `uvicorn-gunicorn-docker`_ project for more details.\n\nAccess Token\n************\nAn access token creation function is provided. However, it's not used by fault.\nTo use it, please check the `example \u003cthe https://github.com/tiangolo/full-stack-fastapi-postgresql/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/backend/app/app/api/api_v1/endpoints/login.py\u003e`_.\n\nContributing Guide\n------------------\n\nPlease check the `Contributing Guide \u003cdocs/source/07_contributing.rst\u003e`_ for details.\n\nCore Team\n---------\n\n* `Zhiwei Zhang \u003chttps://github.com/zhiwei2017\u003e`_ - *Author* / *Maintainer* - `zhiwei2017@gmail.com \u003cmailto:zhiwei2017@gmail.com?subject=[GitHub]FastAPI%20Cookiecutter\u003e`_\n\nLiterature\n----------\n\n+ `cookiecutter`_\n+ `FastAPI \u003chttps://fastapi.tiangolo.com\u003e`_\n+ `Pydantic \u003chttps://pydantic-docs.helpmanual.io\u003e`_\n+ `SQLAlchemy \u003chttps://www.sqlalchemy.org\u003e`_\n+ `Alembic \u003chttps://alembic.sqlalchemy.org/en/latest/\u003e`_\n+ `PyJWT \u003chttps://github.com/jpadilla/pyjwt\u003e`_\n+ `python-jose \u003chttps://github.com/mpdavis/python-jose\u003e`_\n\n.. _`cookiecutter`: https://github.com/cookiecutter/cookiecutter\n.. _uvicorn-gunicorn-docker: https://github.com/tiangolo/uvicorn-gunicorn-docker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhiwei2017%2Ffastapi-cookiecutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhiwei2017%2Ffastapi-cookiecutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhiwei2017%2Ffastapi-cookiecutter/lists"}