{"id":20154909,"url":"https://github.com/ai-helpers/api-cookiecutter-template","last_synced_at":"2026-02-10T10:39:01.219Z","repository":{"id":218088094,"uuid":"744542555","full_name":"ai-helpers/api-cookiecutter-template","owner":"ai-helpers","description":"Cookiecutter template for FastAPI projects using Machine Learning.","archived":false,"fork":false,"pushed_at":"2024-05-31T12:45:04.000Z","size":2976,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T05:44:28.613Z","etag":null,"topics":["cookiecutter","cookiecutter-template","fastapi","machine-learing","mlops","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/ai-helpers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2024-01-17T14:12:08.000Z","updated_at":"2024-08-07T14:16:47.000Z","dependencies_parsed_at":"2024-01-19T17:30:02.578Z","dependency_job_id":"801a3e43-99b5-465a-8150-27b899f6aef5","html_url":"https://github.com/ai-helpers/api-cookiecutter-template","commit_stats":null,"previous_names":["ai-helpers/api-cookiecutter-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ai-helpers/api-cookiecutter-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai-helpers%2Fapi-cookiecutter-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai-helpers%2Fapi-cookiecutter-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai-helpers%2Fapi-cookiecutter-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai-helpers%2Fapi-cookiecutter-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ai-helpers","download_url":"https://codeload.github.com/ai-helpers/api-cookiecutter-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ai-helpers%2Fapi-cookiecutter-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260851172,"owners_count":23072551,"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":["cookiecutter","cookiecutter-template","fastapi","machine-learing","mlops","template"],"created_at":"2024-11-13T23:28:59.935Z","updated_at":"2026-02-10T10:38:55.879Z","avatar_url":"https://github.com/ai-helpers.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cookiecutter API Template based on FastAPI\n\nThis template streamlines your FastAPI development, providing a robust foundation built on best practices.\n\nContributions are welcome!\n\n![Demo App](_static/gif-cruft-template.gif)\n\n# Table of Content (ToC)\n\n- [Cookiecutter API Template based on FastAPI](#cookiecutter-api-template-based-on-fastapi)\n- [Table of Content (ToC)](#table-of-content-toc)\n  - [Main Features](#main-features)\n  - [Prerequisites](#prerequisites)\n  - [Quickstart](#quickstart)\n    - [Without `cruft`](#without-cruft)\n    - [With `cruft`](#with-cruft)\n    - [Updating Template](#updating-template)\n  - [Endpoints](#endpoints)\n    - [Health](#health)\n    - [Info](#info)\n    - [Predict](#predict)\n    - [Test](#test)\n    - [Documentation](#documentation)\n  - [Tests](#tests)\n  - [Project Structure](#project-structure)\n  - [Contributions](#contributions)\n\n\n## Main Features\n\n* **Modern Structure:** Organized project layout for easy navigation and scaling.\n* **Essential Dependencies:** Includes FastAPI, Uvicorn, Pytest (for testing), and Pydantic (for data validation).\n* **Environment Management:** Preconfigured with Poetry for virtual environments and dependency management.\n* **API Routing:** Sample `/health` endpoint included.\n* **Testing Framework:** Pytest for writing and running automated tests.\n* **Linting:** Pre-commit hooks with Black for consistent code formatting.\n* **Logging:** Structured logging with Loguru for better debugging and monitoring.\n\nSee [here](https://github.com/ai-helpers/example-api-template) an example for project instantiation.\n\n## Prerequisites\n\nEnsure you have the following tools installed:\n\n* **Python:** Recommended to use Pyenv for managing multiple Python versions.\n* **Pyenv:** For managing multiple Python versions.\n* **Cookiecutter:** `pip install cookiecutter`\n* **Poetry:** `pip install poetry`\n* **(Optional) Cruft:** For managing Cookiecutter templates more efficiently (not strictly required).\n\n## Quickstart\n\n### Without `cruft`\n\n```bash\n$ cookiecutter git@github.com:dktunited/dps-ml-databricks-template\n  [1/5] project_long_name (My Project): API Example\n  [2/5] project_name_dashes (my-project): api-example\n  [3/5] project_name_underscores (my_project): api_example\n  [4/5] version (0.1.0):\n  [5/5] description (My project description):\n$ cd api-example\n$ poetry install\n[...]\nPackage operations: 44 installs, 0 updates, 0 removals\n[...]\n$ poetry run api-example\n[\\2024-05-28 15:58:59,332] {\\root} \\INFO - \\[API] Starting service with version 0.1.0...\n[\\2024-05-28 15:58:59,332] {\\root} \\INFO - \\[API] Log level set to DEBUG\n[\\2024-05-28 15:58:59,332] {\\api_example.cli} \\INFO - \\[API] Log level set to DEBUG\n[\\2024-05-28 15:58:59,332] {\\api_example.cli} \\INFO - \\[API] API service starting on 0.0.0.0:80\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Started server process [98569]\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Waiting for application startup.\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Application startup complete.\n[\\2024-05-28 15:59:15,534] {\\uvicorn.error} \\INFO - \\Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)\n```\n\n### With `cruft`\n```bash\n$ cruft create https://github.com/ai-helpers/api-cookiecutter-template\n  [1/5] project_long_name (My Project): API Example\n  [2/5] project_name_dashes (my-project): api-example\n  [3/5] project_name_underscores (my_project): api_example\n  [4/5] version (0.1.0):\n  [5/5] description (My project description):\n$ cd api-example\n$ poetry install\n[...]\nPackage operations: 44 installs, 0 updates, 0 removals\n[...]\n$ poetry run api-example\n[\\2024-05-28 15:58:59,332] {\\root} \\INFO - \\[API] Starting service with version 0.1.0...\n[\\2024-05-28 15:58:59,332] {\\root} \\INFO - \\[API] Log level set to DEBUG\n[\\2024-05-28 15:58:59,332] {\\api_example.cli} \\INFO - \\[API] Log level set to DEBUG\n[\\2024-05-28 15:58:59,332] {\\api_example.cli} \\INFO - \\[API] API service starting on 0.0.0.0:80\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Started server process [98569]\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Waiting for application startup.\n[\\2024-05-28 15:59:15,529] {\\uvicorn.error} \\INFO - \\Application startup complete.\n[\\2024-05-28 15:59:15,534] {\\uvicorn.error} \\INFO - \\Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)\n```\n\n### Updating Template\n\n```bash\n$ cruft update\nRespond with \"s\" to intentionally skip the update while marking your project as up-to-date or respond with \"v\" to view the changes that will be applied.\nApply diff and update? (y, n, s, v) [y]: y\nGood work! Project's cruft has been updated and is as clean as possible!\n```\n\n## Endpoints\n\n### Health\nA simple endpoint to check the health of the application.\n```http\nGET /health\n```\nReturns a status message indicating the service is up and running.\n\n### Info\nProvides information about the application.\n```http\nGET /info\n```\nReturns metadata such as version, author, and other relevant details (cf. `data/info.txt`)\n\n### Predict\nEndpoint for making predictions based on input data.\n```http\nPOST /predict\n```\nAccepts a JSON payload with the necessary input data and returns the prediction results.\n\n### Test\nEndpoint for testing purposes.\n```http\nGET /test\n```\nReturns a test response, useful for debugging and ensuring the endpoint is reachable.\n\n### Documentation\nFastAPI provides interactive API documentation.\n```http\nGET /docs\n```\nAccess the Swagger UI for a user-friendly interface to interact with your API.\n\n```http\nGET /redoc\n```\nAccess the ReDoc interface for an alternative documentation style.\n\n## Tests\nTo run the tests, you need to install the testing dependencies and then execute the test suite. Here are the commands to get started:\n\n```bash\npython -m pip install -U pip\npython -m pip install -U pytest pytest-cookies\npytest pytest --keep-baked-projects test_cookiecutter.py\n```\n\nThese commands will ensure that your pip is up to date, install pytest and pytest-cookies for testing, and then run the tests defined in `test_cookiecutter.py`. The --keep-baked-projects flag keeps the generated projects for inspection even after tests are run.\n\nImplementation of these tests in GitHub Actions is straightforward. You can see an example configuration in the `.github/workflows/main.yml` file. This setup ensures that tests are run automatically on each push or pull request, providing continuous integration and ensuring code quality.\n\n## Project Structure\n\n    ├── .github\n    ├── {{cookiecutter.project_name_dashes}}\n    │   ├── .github                                         \u003c- Github Actions CICD\n    │   ├── data\n    │   ├── docs                                            \u003c- Sphinx documentation\n    │   ├── src   \n    │       └── {{cookiecutter.project_name_underscores}}   \u003c- Core of project\n    │   │       ├── endpoints                               \u003c- API endpoints definition\n    │   │       ├── settings                                \u003c- settings\n    │   │       ├── __init__.py      \n    │   │       ├── app.py           \n    │   │       ├── cli.py           \n    │   │       ├── errors           \n    │   │       ├── load_model.py    \n    │   │       └── setup_logging.py \n    │   ├── tasks                                           \u003c- Makefile tasks\n    │   ├── tests                                           \u003c- tests (units tests, data tests)\n    │   ├── .gitignore          \n    │   ├── .mypy.ini   \n    │   ├── Makefile   \n    │   ├── poetry.toml                       \n    │   ├── pyproject.toml   \n    │   ├── README.md    \n    ├── .gitignore  \n    ├── .python-version            \n    ├── CONTRIBUTING.md            \n    ├── cookiecutter.json            \n    ├── README.md            \n    ├── test_cookiecutter.py            \n    └── VERSION\n\n## Contributions\n\nYour contributions are valued! Please feel free to open issues or submit pull requests.\n\nLet me know if you'd like any other sections added!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai-helpers%2Fapi-cookiecutter-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fai-helpers%2Fapi-cookiecutter-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fai-helpers%2Fapi-cookiecutter-template/lists"}