{"id":26982872,"url":"https://github.com/spyker77/fastapi-tdd-docker","last_synced_at":"2025-06-23T09:34:36.852Z","repository":{"id":42048201,"uuid":"327653821","full_name":"spyker77/fastapi-tdd-docker","owner":"spyker77","description":"Transformers with test-driven development","archived":false,"fork":false,"pushed_at":"2023-11-03T15:22:17.000Z","size":612,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-20T22:00:19.435Z","etag":null,"topics":["asyncio","celery","docker","fastapi","heroku","mysql","oauth2","pytest","python","rabbitmq","redis","sqlalchemy","transformers"],"latest_commit_sha":null,"homepage":"","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/spyker77.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-07T15:38:57.000Z","updated_at":"2024-06-11T10:00:38.000Z","dependencies_parsed_at":"2023-10-29T18:31:20.370Z","dependency_job_id":"6aee5aa5-07d5-407e-9ba3-d81eacb31494","html_url":"https://github.com/spyker77/fastapi-tdd-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spyker77/fastapi-tdd-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyker77%2Ffastapi-tdd-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyker77%2Ffastapi-tdd-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyker77%2Ffastapi-tdd-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyker77%2Ffastapi-tdd-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spyker77","download_url":"https://codeload.github.com/spyker77/fastapi-tdd-docker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyker77%2Ffastapi-tdd-docker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261453231,"owners_count":23160471,"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":["asyncio","celery","docker","fastapi","heroku","mysql","oauth2","pytest","python","rabbitmq","redis","sqlalchemy","transformers"],"created_at":"2025-04-03T16:35:31.596Z","updated_at":"2025-06-23T09:34:31.828Z","avatar_url":"https://github.com/spyker77.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test-Driven Development with FastAPI and Docker\n\n![Continuous Integration and Delivery](https://github.com/spyker77/fastapi-tdd-docker/workflows/Continuous%20Integration%20and%20Delivery/badge.svg?branch=main)\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Testing](#testing)\n- [Deployment](#deployment)\n- [License](#license)\n\n## Introduction\n\nThis project is an implementation of [the course](https://testdriven.io/courses/tdd-fastapi/) on Test-Driven Development to build the API for summarizing articles, with additional features and optimizations. Key enhancements include:\n\n- Dependencies updated to the latest version at the moment\n- CORSMiddleware used to manually control allowed origins\n- Venv replaced with PDM\n- Added versions of the API\n- Refactored the code\n- Gunicorn added to manage the uvicorn\n- BackgroundTasks replaced with Celery, Redis and RabbitMQ\n- Optimized CI/CD pipeline in GitHub Actions\n- Migrated to the Container registry from the Docker registry\n- Implemented authentication and authorization using OAuth2\n- Tortoise-ORM has been replaced by SQLAlchemy\n- Transformers models are used instead of the NLP from Newspaper3k\n\n## Prerequisites\n\n- Docker and Docker Compose installed on your machine.\n- Basic knowledge of Python, FastAPI, and Docker.\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/spyker77/fastapi-tdd-docker.git\ncd fastapi-tdd-docker\n```\n\n2. Build and start the containers:\n\n```bash\ndocker compose up -d --build\n```\n\n3. Generate the database schema:\n\n```bash\ndocker compose exec web alembic upgrade head\n```\n\n## Usage\n\n1. Access the API documentation at: \u003chttp://localhost:8000/docs\u003e\n2. Create a test user at: \u003chttp://localhost:8000/docs#/users/create_user_api_v2_users__post\u003e\n\n    Example of the payload:\n\n```json\n{\n  \"full_name\": \"Cute Koala\",\n  \"username\": \"cute\",\n  \"email\": \"cute@example.com\",\n  \"password\": \"supersecret\"\n}\n```\n\n3. Use the **Authorize** button (simplest way) at the top and enter the username and password you've just created, then click **Authorize**.\n\n4. At this point you're authorized. Now use the endpoint \u003chttp://localhost:8000/docs#/summaries/create_summary_api_v2_summaries__post\u003e to send the article you want to summarize, for example like so:\n\n```json\n{\n  \"url\": \"https://dev.to/spyker77/how-to-connect-godaddy-domain-with-heroku-and-cloudflare-mdh\"\n}\n```\n\n5. This triggers the ML models to download, which may take a few minutes for the first run (in the current implementation). After that, reach the endpoint \u003chttp://localhost:8000/docs#/summaries/read_all_summaries_api_v2_summaries__get\u003e and in the response you should see something like:\n\n```json\n[\n  {\n    \"id\": 1,\n    \"url\": \"https://dev.to/spyker77/how-to-connect-godaddy-domain-with-heroku-and-cloudflare-mdh\",\n    \"summary\": \"If you struggle to connect newly registered domain from GoDaddy with your app at Heroku, and in addition would like to use advantages of Cloudflare – this article is for you. Hope it will help you and without many words, let's jump in!Sections: Heroku settings, Cloudflare settings and GoDaddy settings.\",\n    \"user_id\": 1\n  }\n]\n```\n\n## Testing\n\nRun the tests using the following command:\n\n```bash\ndocker compose exec web pytest -n auto --cov\n```\n\n## Deployment\n\nFor production deployment, don't forget to change the ENVIRONMENT variables. The default CI/CD pipeline is set up to build images with GitHub Actions, store them in GitHub Packages, and deploy the application to Heroku. But the deployment part is currently disabled/commented out.\n\n### Note\n\nThe current implementation of text summarization using the transformer models is not ideal for production due to the following reasons:\n\n- The requirement to install a heavy transformers library along with its dependencies.\n- The necessity to download several gigabytes of the model.\n- The need for powerful hardware to run the model.\n\nTypically, in a production environment, the models would be provided via an API using services like AWS SageMaker or Paperspace Gradient.\n\n## License\n\nThis project is licensed under the MIT License. See the [MIT License](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspyker77%2Ffastapi-tdd-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspyker77%2Ffastapi-tdd-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspyker77%2Ffastapi-tdd-docker/lists"}