{"id":29593097,"url":"https://github.com/codewithsegnet/fastapi-be-boilerplate","last_synced_at":"2025-09-09T12:42:28.643Z","repository":{"id":304670992,"uuid":"1019429703","full_name":"CodewithSegNet/fastapi-be-boilerplate","owner":"CodewithSegNet","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-14T13:48:00.000Z","size":250,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-14T17:37:10.057Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CodewithSegNet.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-14T10:05:57.000Z","updated_at":"2025-07-14T13:48:04.000Z","dependencies_parsed_at":"2025-07-14T17:37:12.619Z","dependency_job_id":"a02411f9-2ce9-46cb-b6ea-5c4b12d5a997","html_url":"https://github.com/CodewithSegNet/fastapi-be-boilerplate","commit_stats":null,"previous_names":["codewithsegnet/fastapi-be-boilerplate"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/CodewithSegNet/fastapi-be-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodewithSegNet%2Ffastapi-be-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodewithSegNet%2Ffastapi-be-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodewithSegNet%2Ffastapi-be-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodewithSegNet%2Ffastapi-be-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodewithSegNet","download_url":"https://codeload.github.com/CodewithSegNet/fastapi-be-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodewithSegNet%2Ffastapi-be-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274296691,"owners_count":25258897,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-07-20T06:07:05.433Z","updated_at":"2025-09-09T12:42:28.600Z","avatar_url":"https://github.com/CodewithSegNet.png","language":"Python","readme":"# FASTAPI\nFastAPI boilerplate\n\n## Setup\n\n1. Create a virtual environment.\n ```sh\n    python3 -m venv .venv\n ```\n2. Activate virtual environment.\n```sh\n    source /path/to/venv/bin/activate`\n```\n3. Install project dependencies `pip install -r requirements.txt`\n4. Create a .env file by copying the .env.sample file\n`cp .env.sample .env`\n\n5. Start server.\n ```sh\n python main.py\n```\n\n## **DATABASE TEST SETUP**\n\nTo set up the database, follow the following steps:\n\n**Cloning**\n- clone the repository using `git clone https://github.com/hngprojects/hng_boilerplate_python_fastapi_web`\n- `cd` into the directory hng_boilerplate_python_fastapi_web\n- switch branch using `git checkout backend`\n\n**Environment Setup**\n- run `pip install -r requrements.txt` to install dependencies\n- create a `.env` file in the root directory and copy the content of `.env.sample` and update it accordingly\n\n**Create your local database**\n```bash\nsudo -u root psql\n```\n```sql\nCREATE USER user WITH PASSWORD 'your desired password'; \nCREATE DATABASE hng_fast_api;\nGRANT ALL PRIVILEGES ON DATABASE hng_fast_api TO user;\n```\n\n**Starting the database**\nafter cloning the database, dont run \n`alembic revision --autogenerate -m 'initial migration'`\nbut run\n`alembic upgrade head`\n\nif you make changes to any table locally, then run the below command.\n```bash\nalembic revision --autogenerate -m 'initial migration'\nalembic upgrade head\n```\n\n**create dummy data**\n```bash\npython3 seed.py\n```\n\n\n**Adding tables and columns to models**\n\nAfter creating new tables, or adding new models. Make sure to run alembic revision --autogenerate -m \"Migration messge\"\n\nAfter creating new tables, or adding new models. Make sure you import the new model properly in th 'api/v1/models/__init__.py file\n\nAfter importing it in the init file, you need not import it in the /alembic/env.py file anymore\n\n\n**Adding new routes**\n\nTo add a new route, confirm if a file relating to that route is not already created. If it is add the route in that file using the already declared router\n\nIf the there is no file relating to the route in the 'api/v1/routes/' directory create a new one following the naming convention\n\nAfter creating the new route file, declare the router and add the prefix as well as the tag\n\nThe prefix should not include the base prefix ('/api/v1') as it is already includedin the base `api_version_one` router\n\nAfter creating the router, import it in the 'api/v1/routes/__init__.py' file and include the router in the `api_version_one` router using\n```python\napi_version_one.include_router(\u003crouter_name\u003e)\n```\n\n## TEST THE ENDPOINT\n- run the following code\n```\npython -m unittest tests/v1/test_login.py\npython -m unittest tests/v1/test_signup.py\n```\n\n## Issues\nif you encounter the following Error, when you run the code below\n\n**alembic revision --autogenerate -m 'your migration message'**\n\n```\nINFO  [alembic.runtime.migration] Context impl PostgresqlImpl.\nINFO  [alembic.runtime.migration] Will assume transactional DDL.\nERROR [alembic.util.messaging] Target database is not up to date.\n  FAILED: Target database is not up to date.\n```\n\n## Solutions\nRun the following code below first to update the datebase\n**alembic upgrade head**\nthen, run this again.\n**alembic revision --autogenerate -m 'your migration message'**\n\n## update \nplease make sure to test your endpoint or model before pushing.\npush your alembic migrations.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithsegnet%2Ffastapi-be-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewithsegnet%2Ffastapi-be-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithsegnet%2Ffastapi-be-boilerplate/lists"}