{"id":20433337,"url":"https://github.com/jpcadena/fastapi-boilerplate","last_synced_at":"2026-01-20T06:33:06.249Z","repository":{"id":207673270,"uuid":"719814559","full_name":"jpcadena/fastapi-boilerplate","owner":"jpcadena","description":"FastAPI boilerplate project for backend with SQAlchemy and Redis","archived":false,"fork":false,"pushed_at":"2024-04-19T15:41:07.000Z","size":2441,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-21T17:05:22.436Z","etag":null,"topics":["api","backend","black-formatter","boilerplate","database","fastapi","isort","mypy","poetry","postgresql","pydantic","python","redis","rest-api","restful-api","ruff","sqlalchemy","starlette","template","uvicorn"],"latest_commit_sha":null,"homepage":"https://github.com/jpcadena/fastapi-boilerplate","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/jpcadena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-17T00:32:32.000Z","updated_at":"2024-04-22T20:05:54.095Z","dependencies_parsed_at":"2024-04-25T05:46:24.253Z","dependency_job_id":null,"html_url":"https://github.com/jpcadena/fastapi-boilerplate","commit_stats":null,"previous_names":["jpcadena/fastapi-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jpcadena/fastapi-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpcadena%2Ffastapi-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpcadena%2Ffastapi-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpcadena%2Ffastapi-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpcadena%2Ffastapi-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpcadena","download_url":"https://codeload.github.com/jpcadena/fastapi-boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpcadena%2Ffastapi-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28597639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"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":["api","backend","black-formatter","boilerplate","database","fastapi","isort","mypy","poetry","postgresql","pydantic","python","redis","rest-api","restful-api","ruff","sqlalchemy","starlette","template","uvicorn"],"created_at":"2024-11-15T08:18:40.517Z","updated_at":"2026-01-20T06:33:06.230Z","avatar_url":"https://github.com/jpcadena.png","language":"Python","readme":"# fastapi-boilerplate\n\n\u003c!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 --\u003e\n\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!--\n*** Markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n--\u003e\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/othneildrew/Best-README-Template\"\u003e\n    \u003cimg src=\"assets/images/logo.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n\u003ch3 align=\"center\"\u003eFastapi boilerplate\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Fastapi boilerplate\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/jpcadena/fastapi-boilerplate\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n       \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#api-documentation\"\u003eAPI Documentation\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#openapi-typescript-codegen\"\u003eOpenAPI TypeScript Codegen\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#react-native-installation\"\u003eReact Native Installation\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#codegen-usage\"\u003eCodegen Usage\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#security\"\u003eSecurity\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#code-of-conduct\"\u003eCode of Conduct\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e  \u003c/ol\u003e\n\u003c/details\u003e\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n\n## About The Project\n\n![Project][project-screenshot]\n\nThis backend project is a FastAPI-based template designed to serve as a robust,\nreliable, and RESTful API backend. It is crucial for facilitating user\nauthentication, real-time monitoring, data processing, and an advanced alerting\nsystem. By leveraging the principles of RESTful architecture, this API ensures\nstandardized communication and a scalable, maintainable infrastructure for the\nassociated mobile application. This project is not only vital for the\nfunctionality it provides but also for ensuring the scalability and\nmaintainability of the overall solution.\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Built with\n\nThis project is built using a suite of modern, powerful technologies and\nframeworks to ensure high performance, ease of development, and robustness:\n\n[![Python][python-shield]][python-url] [![FastAPI][fastapi-shield]][fastapi-url] [![Pydantic][pydantic-shield]][pydantic-url] [![Starlette][starlette-shield]][starlette-url] [![Uvicorn][uvicorn-shield]][uvicorn-url] [![postgresql][postgresql-shield]][postgresql-url] [![Redis][redis-shield]][redis-url] [![JWT][jwt-shield]][jwt-url] [![HTML5][html5-shield]][html5-url] [![CSS3][css3-shield]][css3-url] [![isort][isort-shield]][isort-url] [![Black][black-shield]][black-url] [![Ruff][ruff-shield]][ruff-url] [![MyPy][mypy-shield]][mypy-url] [![pre-commit][pre-commit-shield]][pre-commit-url] [![GitHub Actions][github-actions-shield]][github-actions-url] [![Poetry][poetry-shield]][poetry-url] [![Pycharm][pycharm-shield]][pycharm-url] [![Visual Studio Code][visual-studio-code-shield]][visual-studio-code-url] [![Markdown][markdown-shield]][markdown-url] [![Swagger UI][swagger-ui-shield]][swagger-ui-url] [![License: MIT][license-shield]][license-url]\n\n### Components\n\nThe system is composed of the following main components, each playing a\ncrucial role in providing a scalable, maintainable, and robust application:\n\n- **FastAPI Backend**: Serves as the core of the RESTful API, handling incoming\n  HTTP requests, processing data, and sending responses. It's designed for high\n  performance and encourages standard API development practices.\n- **PostgreSQL \u0026 Redis**: PostgreSQL is used for structured relational data\n  storage, while Redis serves as a fast, in-memory data store for caching and\n  temporary data to enhance performance.\n- **JWT Authentication**: Implements secure authentication mechanisms using JSON\n  Web Tokens (JWT), ensuring secure access to the API.\n\nThis project adheres to RESTful design principles, ensuring an intuitive and\nstandard approach to API development. This design facilitates easy integration,\nscalability, and interaction with various clients, including web and mobile\napplications. The API provides clear, resource-oriented URLs, uses HTTP response\ncodes to indicate API errors, and employs JWT for secure, stateless\nauthentication.\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting started\n\n### Prerequisites\n\n- [Python 3.11][python-docs]\n\n### Installation\n\n1. Clone the **repository**\n\n   ```bash\n   git clone https://github.com/jpcadena/fastapi-boilerplate.git\n   ```\n\n2. Change the directory to **root project**\n\n   ```bash\n   cd fastapi-boilerplate\n   ```\n\n3. Install **Poetry** package manager\n\n   ```bash\n   pip install poetry\n   ```\n\n4. Install the project's **dependencies**\n\n   ```bash\n   poetry install\n   ```\n\n5. Activate the **environment**\n\n   ```bash\n   poetry shell\n   ```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n## Usage\n\n1. **Setting up environment variables:**\n\n   If you find a `.env.sample` in the project directory, make a copy of it and rename to `.env`.\n\n   ```bash\n   cp .env.sample .env\n   ```\n\n   This `.env` file will be used to manage your application's environment variables.\n\n2. **Configuring your credentials:**\n\n   Open the `.env` file in a text editor and replace the placeholder values with your actual credentials.\n\n   ```bash\n   # .env file\n   POSTGRES_USER=your_database_user\n   SECRET_KEY=your_api_key\n   ```\n\n   Be sure to save the file after making these changes.\n\n3. **Generating RSA keys**\n\n    To ensure secure communication in this project, RSA keys are used. Before running the application, you need to generate a public and private RSA key pair.\n    We've provided a Python script to automatically generate these keys. You can find the script at `app\\services\\infrastructure\\encryption.py`. To generate your keys, simply run:\n\n    ```bash\n    python app\\services\\infrastructure\\encryption.py.py\n    ```\n\n    This will create `public_key.pem` and `private_key.pem` files in your specified directory.\n\n    Once the keys are generated, the application will use them for cryptographic operations. Ensure that these files are kept secure and are not exposed publicly. The default configuration expects these keys in the root directory of the project.\n\n4. **Starting the server:**\n\n   To start the local server on your machine, run the following command in your terminal:\n\n   ```bash\n   uvicorn main:app --reload\n   ```\n\n   The `--reload` flag enables hot reloading, which means the server will automatically update whenever you make changes to the code.\n\n5. **Interacting with the app:**\n\n   Once your server is running, you can interact with it using any API client like Postman or your web browser. You can send GET, POST, PUT, DELETE requests to the API endpoints as defined in your `main.py` file. For example, to get all users, you can send a GET request to `http://localhost:8000/api/v1/users`.\n\n6. **Using Swagger UI:**\n\n   FastAPI provides automatic interactive API documentation using Swagger UI. Once your server is up and running, you can go to `http://localhost:8000/docs` in your web browser to access it. From there, you can explore and interact with your API directly.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- OPENAPI TYPESCRIPT CODEGEN --\u003e\n\n## OpenAPI TypeScript Codegen\n\nTo facilitate the interaction between the frontend and the API, we use the [OpenAPI TypeScript Codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) to generate TypeScript models and APIs based on our OpenAPI specification file.\n\n### React Native Installation\n\nFirst, you need to install the OpenAPI TypeScript Codegen as a devDependency. In your project directory, run:\n\n```bash\nnpm install openapi-typescript-codegen --save-dev\n```\n\n### Codegen Usage\n\nAdd the following to your package.json file:\n\n```bash\n\"generate-client\": \"openapi --input C:/Users/user/fastapi-boilerplate/openapi.json --output . /src/client --client axios\"\n```\n\nTo generate the TypeScript code, you need to use the openapi.json specification file. Run the following command in your terminal:\n\n```bash\nnpm run generate-client\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\n[![GitHub][github-shield]][github-url]\n\nPlease read our [contributing guide](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- SECURITY --\u003e\n\n## Security\n\nFor security considerations and best practices, please refer to our [Security Guide](SECURITY.md) for a detailed guide.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CODE_OF_CONDUCT --\u003e\n\n## Code of Conduct\n\nWe enforce a code of conduct for all maintainers and contributors. Please read our [Code of Conduct](CODE_OF_CONDUCT.md) to understand the expectations before making any contributions.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- LICENSE --\u003e\n\n## License\n\nDistributed under the MIT License. See [LICENSE](LICENSE) for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTACT --\u003e\n\n## Contact\n\n- [![LinkedIn][linkedin-shield]][linkedin-url]\n\n- [![Outlook][outlook-shield]](mailto:jpcadena@espol.edu.ec?subject=[GitHub]fastapi-boilerplate)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n\n[project-screenshot]: assets/images/project.png\n[python-docs]: https://docs.python.org/3.11/\n\n[linkedin-shield]: https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\n[outlook-shield]: https://img.shields.io/badge/Microsoft_Outlook-0078D4?style=for-the-badge\u0026logo=microsoft-outlook\u0026logoColor=white\n[python-shield]: https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54\n[fastapi-shield]: https://img.shields.io/badge/FastAPI-FFFFFF?style=for-the-badge\u0026logo=fastapi\n[pydantic-shield]: https://img.shields.io/badge/Pydantic-FF43A1?style=for-the-badge\u0026logo=pydantic\u0026logoColor=white\n[starlette-shield]: https://img.shields.io/badge/Starlette-392939?style=for-the-badge\u0026logo=starlette\u0026logoColor=white\n[uvicorn-shield]: https://img.shields.io/badge/Uvicorn-2A308B?style=for-the-badge\u0026logo=uvicorn\u0026logoColor=white\n[redis-shield]: https://img.shields.io/badge/Redis-DC382D?style=for-the-badge\u0026logo=redis\u0026logoColor=white\n[html5-shield]: https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge\u0026logo=html5\u0026logoColor=white\n[jwt-shield]: https://img.shields.io/badge/JWT-black?style=for-the-badge\u0026logo=JSON%20web%20tokens\n[pycharm-shield]: https://img.shields.io/badge/PyCharm-21D789?style=for-the-badge\u0026logo=pycharm\u0026logoColor=white\n[markdown-shield]: https://img.shields.io/badge/Markdown-000000?style=for-the-badge\u0026logo=markdown\u0026logoColor=white\n[swagger-ui-shield]: https://img.shields.io/badge/-Swagger-%23Clojure?style=for-the-badge\u0026logo=swagger\u0026logoColor=white\n[github-shield]: https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white\n[ruff-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json\n[black-shield]: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge\u0026logo=appveyor\n[mypy-shield]: https://img.shields.io/badge/mypy-checked-2A6DB2.svg?style=for-the-badge\u0026logo=appveyor\n[visual-studio-code-shield]: https://img.shields.io/badge/Visual_Studio_Code-007ACC?style=for-the-badge\u0026logo=visual-studio-code\u0026logoColor=white\n[poetry-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/python-poetry/website/main/static/badge/v0.json\n[postgresql-shield]: https://img.shields.io/badge/PostgreSQL-336791?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white\n[isort-shield]: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336\n[github-actions-shield]: https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge\u0026logo=githubactions\u0026logoColor=white\n[pre-commit-shield]: https://img.shields.io/badge/pre--commit-F7B93E?style=for-the-badge\u0026logo=pre-commit\u0026logoColor=white\n[css3-shield]: https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge\u0026logo=css3\u0026logoColor=white\n[license-shield]: https://img.shields.io/badge/License-MIT-yellow.svg\n\n[linkedin-url]: https://linkedin.com/in/juanpablocadenaaguilar\n[python-url]: https://docs.python.org/3.11/\n[fastapi-url]: https://fastapi.tiangolo.com\n[pydantic-url]: https://docs.pydantic.dev\n[starlette-url]: https://www.starlette.io/\n[uvicorn-url]: https://www.uvicorn.org/\n[redis-url]: https://redis.io/\n[html5-url]: https://developer.mozilla.org/en-US/docs/Glossary/HTML5\n[jwt-url]: https://jwt.io/\n[pycharm-url]: https://www.jetbrains.com/pycharm/\n[markdown-url]: https://daringfireball.net/projects/markdown/\n[swagger-ui-url]: https://swagger.io/\n[github-url]: https://github.com/jpcadena/fastapi-boilerplate\n[ruff-url]: https://beta.ruff.rs/docs/\n[black-url]: https://github.com/psf/black\n[mypy-url]: http://mypy-lang.org/\n[visual-studio-code-url]: https://code.visualstudio.com/\n[poetry-url]: https://python-poetry.org/\n[postgresql-url]: https://www.postgresql.org/\n[isort-url]: https://pycqa.github.io/isort/\n[github-actions-url]: https://github.com/features/actions\n[pre-commit-url]: https://pre-commit.com/\n[css3-url]: https://developer.mozilla.org/en-US/docs/Web/CSS\n[license-url]: https://opensource.org/licenses/MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpcadena%2Ffastapi-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpcadena%2Ffastapi-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpcadena%2Ffastapi-boilerplate/lists"}