{"id":34534111,"url":"https://github.com/bybatkhuu/rest-fastapi-template","last_synced_at":"2026-04-01T17:35:44.747Z","repository":{"id":160319262,"uuid":"626908442","full_name":"bybatkhuu/rest-fastapi-template","owner":"bybatkhuu","description":"This is a template repository for FastAPI web service projects.","archived":false,"fork":false,"pushed_at":"2026-03-18T15:40:19.000Z","size":4789,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-18T20:23:38.316Z","etag":null,"topics":["boilerplate","cicd","cookiecutter","docker","docker-compose","fastapi","fastapi-boilerplate","fastapi-template","microservice","python","rest-api","template","web-server"],"latest_commit_sha":null,"homepage":"https://ft-docs.bybatkhuu.dev","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/bybatkhuu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","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":"2023-04-12T11:59:59.000Z","updated_at":"2026-03-18T15:38:54.000Z","dependencies_parsed_at":"2024-12-08T12:26:53.038Z","dependency_job_id":"6e5d9472-0e10-41bf-8033-1c3b00d1efb1","html_url":"https://github.com/bybatkhuu/rest-fastapi-template","commit_stats":null,"previous_names":["bybatkhuu/rest-fastapi-template"],"tags_count":43,"template":true,"template_full_name":null,"purl":"pkg:github/bybatkhuu/rest-fastapi-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Frest-fastapi-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Frest-fastapi-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Frest-fastapi-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Frest-fastapi-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bybatkhuu","download_url":"https://codeload.github.com/bybatkhuu/rest-fastapi-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bybatkhuu%2Frest-fastapi-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["boilerplate","cicd","cookiecutter","docker","docker-compose","fastapi","fastapi-boilerplate","fastapi-template","microservice","python","rest-api","template","web-server"],"created_at":"2025-12-24T05:56:44.348Z","updated_at":"2026-04-01T17:35:44.738Z","avatar_url":"https://github.com/bybatkhuu.png","language":"Python","readme":"# FastAPI Template\n\n[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bybatkhuu/rest-fastapi-template/3.create-release.yml?logo=GitHub)](https://github.com/bybatkhuu/rest-fastapi-template/actions/workflows/3.create-release.yml)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/bybatkhuu/rest-fastapi-template?logo=GitHub)](https://github.com/bybatkhuu/rest-fastapi-template/releases)\n\nThis is a template repository for FastAPI web service projects.\n\n## ✨ Features\n\n- FastAPI\n- REST API\n- Web service\n- Microservice\n- Configuration\n- Tests\n- Build\n- Scripts\n- Examples\n- Documentation\n- CI/CD\n- Docker and docker compose\n\n---\n\n## 🐤 Getting Started\n\n### 1. 🚧 Prerequisites\n\n\u003c!-- *[OPTIONAL]* For **GPU (NVIDIA)**:\n\n- Install **NVIDIA GPU driver (\u003e= v453)** --\u003e\n\n[RECOMMENDED] For **docker** runtime:\n\n- Install [**docker** and **docker compose**](https://docs.docker.com/engine/install)\n    - Docker image: [**bybatkhuu/rest-fastapi-template**](https://hub.docker.com/r/bybatkhuu/rest-fastapi-template)\n\u003c!-- - *[OPTIONAL]* For **GPU (NVIDIA)**:\n    - Install **[NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) (\u003e= v1)** --\u003e\n\nFor **standalone** runtime:\n\n- Install **Python (\u003e= v3.10)** and **pip (\u003e= 23)**:\n    - **[RECOMMENDED] [Miniconda (v3)](https://www.anaconda.com/docs/getting-started/miniconda/install)**\n    - *[arm64/aarch64] [Miniforge (v3)](https://github.com/conda-forge/miniforge)*\n    - *[Python virtual environment] [venv](https://docs.python.org/3/library/venv.html)*\n\u003c!-- - *[OPTIONAL]* For **GPU (NVIDIA)**:\n    - Install **NVIDIA CUDA (\u003e= v11)** and **cuDNN (\u003e= v8)** --\u003e\n\n[OPTIONAL] For **DEVELOPMENT** environment:\n\n- Install [**git**](https://git-scm.com/downloads)\n- Setup an [**SSH key**](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)\n\n### 2. 📥 Download or clone the repository\n\n**2.1.** Prepare projects directory (if not exists):\n\n```sh\n# Create projects directory:\nmkdir -pv ~/workspaces/projects\n\n# Enter into projects directory:\ncd ~/workspaces/projects\n```\n\n**2.2.** Follow one of the below options **[A]**, **[B]** or **[C]**:\n\n**OPTION A.** Clone the repository:\n\n```sh\ngit clone https://github.com/bybatkhuu/rest-fastapi-template.git \u0026\u0026 \\\n    cd rest-fastapi-template\n```\n\n**OPTION B.** Clone the repository (for **DEVELOPMENT**: git + ssh key):\n\n```sh\ngit clone git@github.com:bybatkhuu/rest-fastapi-template.git \u0026\u0026 \\\n    cd rest-fastapi-template\n```\n\n**OPTION C.** Download source code:\n\n1. Download archived **zip** or **tar.gz** file from [**releases**](https://github.com/bybatkhuu/rest-fastapi-template/releases).\n2. Extract it into the projects directory.\n3. Enter into the project directory.\n\n### 3. 📦 Install dependencies\n\n[TIP] Skip this step, if you're going to use **docker** runtime\n\n\u003c!-- #### 3.1. Install base/common dependencies --\u003e\n\n```sh\npip install -r ./requirements.txt\n\n# For DEVELOPMENT:\npip install -r ./requirements/requirements.dev.txt\n# Install pre-commit hooks:\npre-commit install\n```\n\n\u003c!-- #### 3.2. Install hardware specific dependencies\n\nFollow the one of below instructions based on your environment (A is recommended for most cases):\n\n**OPTION A.** For Intel/AMD **x86_64** CPU:\n\n```sh\npip install -r ./requirements/requirements.amd64.txt\n```\n\n**OPTION B.** For **arm64/aarch64** CPU:\n\n```sh\npip install -r ./requirements/requirements.arm64.txt\n```\n\n**OPTION C.** For **NVIDIA GPU** and **x86_64** CPU:\n\n```sh\npip install -r ./requirements/requirements.gpu.txt\n``` --\u003e\n\n### 4. 🌎 Configure environment variables\n\n[NOTE] Please, check **[environment variables](#-environment-variables)** section for more details.\n\n```sh\n# Copy '.env.example' file to '.env' file:\ncp -v ./.env.example ./.env\n# Edit environment variables to fit in your environment:\nnano ./.env\n```\n\n### 5. 🏁 Start the server\n\n[NOTE] Follow the one of below instructions based on your environment **[A, B, C, D, E]**:\n\n#### Docker runtime\n\n**OPTION A.** **[RECOMMENDED]** Run with **docker compose**:\n\n```sh\n## 1. Configure 'compose.override.yml' file.\n# Copy 'compose.override.[ENV].yml' file to 'compose.override.yml' file:\ncp -v ./templates/compose/compose.override.[ENV].yml ./compose.override.yml\n# For example, DEVELOPMENT environment:\ncp -v ./templates/compose/compose.override.dev.yml ./compose.override.yml\n# For example, STATGING or PRODUCTION environment:\ncp -v ./templates/compose/compose.override.prod.yml ./compose.override.yml\n# Edit 'compose.override.yml' file to fit in your environment:\nnano ./compose.override.yml\n\n## 2. Check docker compose configuration is valid:\n./compose.sh validate\n# Or:\ndocker compose config\n\n## 3. Start docker compose:\n./compose.sh start -l\n# Or:\ndocker compose up -d --remove-orphans --force-recreate \u0026\u0026 \\\n    docker compose logs -f -n 100\n```\n\n#### Standalone runtime (PM2)\n\n**OPTION B.** Run with **PM2**:\n\n[**IMPORTANT**] Before running, need to install [**PM2**](https://pm2.keymetrics.io/docs/usage/quick-start):\n\n```sh\n## 1. Configure PM2 configuration file.\n# Copy example PM2 configuration file:\ncp -v ./pm2-process.json.example ./pm2-process.json\n# Edit PM2 configuration file to fit in your environment:\nnano ./pm2-process.json\n\n## 2. Start PM2 process:\npm2 start ./pm2-process.json \u0026\u0026 \\\n    pm2 logs --lines 50 ft\n```\n\n#### Standalone runtime (Python)\n\n**OPTION C.** Run server as **python module**:\n\n```sh\npython -u -m src.api\n```\n\n**OPTION D.** Run with **uvicorn** cli:\n\n```sh\nuvicorn src.api.main:app --host=[BIND_HOST] --port=[PORT] --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips=\"*\"\n# For example:\nuvicorn src.api.main:app --host=\"0.0.0.0\" --port=8000 --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips=\"*\"\n\n# For DEVELOPMENT:\nuvicorn src.api.main:app --host=\"0.0.0.0\" --port=8000 --no-access-log --no-server-header --proxy-headers --forwarded-allow-ips=\"*\" --reload --reload-dir=./src\n```\n\n**OPTION E.** Run with **fastapi** cli:\n\n```sh\nfastapi run src/api/main.py --host=[BIND_HOST] --port=[PORT] --forwarded-allow-ips=\"*\"\n# For example:\nfastapi run src/api/main.py --port=8000 --forwarded-allow-ips=\"*\"\n\n# For DEVELOPMENT:\nfastapi dev src/api/main.py --host=\"0.0.0.0\" --port=8000 --forwarded-allow-ips=\"*\"\n```\n\n### 6. ✅ Check server is running\n\nCheck with CLI (curl):\n\n```sh\n# Send a ping request with 'curl' to REST API server and parse JSON response with 'jq':\ncurl -s http://localhost:8000/api/v1/ping | jq\n```\n\nCheck with web browser:\n\n- Health check: \u003chttp://localhost:8000/api/v1/health\u003e\n- Swagger: \u003chttp://localhost:8000/docs\u003e\n- Redoc: \u003chttp://localhost:8000/redoc\u003e\n- OpenAPI JSON: \u003chttp://localhost:8000/openapi.json\u003e\n\n### 7. 🛑 Stop the server\n\nDocker runtime:\n\n```sh\n# Stop docker compose:\n./compose.sh stop\n# Or:\ndocker compose down --remove-orphans\n```\n\nStandalone runtime (Only for **PM2**):\n\n```sh\npm2 stop ./pm2-process.json \u0026\u0026 \\\n    pm2 flush ft \u0026\u0026 \\\n    pm2 delete ./pm2-process.json\n```\n\n👍\n\n---\n\n## ⚙️ Configuration\n\n### 🌎 Environment Variables\n\n[**`.env.example`**](./.env.example):\n\n```sh\n## --- Environment variable --- ##\nENV=LOCAL\nDEBUG=false\n# TZ=UTC\n# PYTHONDONTWRITEBYTECODE=1\n\n\n## -- API configs -- ##\nFT_API_PORT=8000\n# FT_API_CONFIGS_DIR=\"/etc/rest-fastapi-template\"\n# FT_API_LOGS_DIR=\"/var/log/rest-fastapi-template\"\n# FT_API_DATA_DIR=\"/var/lib/rest-fastapi-template\"\n# FT_API_TMP_DIR=\"/tmp/rest-fastapi-template\"\n# FT_API_VERSION=\"1\"\n# FT_API_PREFIX=\"/api/v{api_version}\"\n# FT_API_DOCS_ENABLED=true\n# FT_API_DOCS_OPENAPI_URL=\"{api_prefix}/openapi.json\"\n# FT_API_DOCS_DOCS_URL=\"{api_prefix}/docs\"\n# FT_API_DOCS_REDOC_URL=\"{api_prefix}/redoc\"\n```\n\n---\n\n## 🧪 Running Tests\n\nTo run tests, run the following command:\n\n```sh\n# Install python test dependencies:\npip install -r ./requirements/requirements.test.txt\n\n# Run tests:\n./scripts/test.sh -l -v -c\n# Or:\npython -m pytest -sv -o log_cli=true\n```\n\n## 🏗️ Build Docker Image\n\nBefore building the docker image, make sure you have installed **docker** and **docker compose**.\n\nTo build the docker image, run the following command:\n\n```sh\n# Build docker image:\n./scripts/build.sh\n# Or:\ndocker compose build\n```\n\n## 📝 Generate Docs\n\nTo build the documentation, run the following command:\n\n```sh\n# Install python documentation dependencies:\npip install -r ./requirements/requirements.docs.txt\n\n# Serve documentation locally (for development):\n./scripts/docs.sh\n# Or:\nmkdocs serve -a 0.0.0.0:8000 --livereload\n\n# Or build documentation:\n./scripts/docs.sh -b\n# Or:\nmkdocs build\n```\n\n## 📚 Documentation\n\n- [Docs](./docs)\n\n---\n\n## 📑 References\n\n- FastAPI - \u003chttps://fastapi.tiangolo.com\u003e\n- Docker - \u003chttps://docs.docker.com\u003e\n- Docker Compose - \u003chttps://docs.docker.com/compose\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbybatkhuu%2Frest-fastapi-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbybatkhuu%2Frest-fastapi-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbybatkhuu%2Frest-fastapi-template/lists"}