{"id":15411981,"url":"https://github.com/fcrozetta/template-fastapi-postgres","last_synced_at":"2025-06-16T16:04:42.977Z","repository":{"id":204373826,"uuid":"711559095","full_name":"fcrozetta/template-fastapi-postgres","owner":"fcrozetta","description":"Template for fastapi and postgres development, with devcontainers (ready for codespaces)","archived":false,"fork":false,"pushed_at":"2025-04-29T12:42:57.000Z","size":168,"stargazers_count":0,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T13:56:42.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"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/fcrozetta.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":"2023-10-29T16:29:24.000Z","updated_at":"2025-04-29T12:42:55.000Z","dependencies_parsed_at":"2024-12-07T04:40:50.386Z","dependency_job_id":"80e6a9c8-2ee7-4b56-8693-69a6db8b9e65","html_url":"https://github.com/fcrozetta/template-fastapi-postgres","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":"0.19047619047619047","last_synced_commit":"99d91eebccb78cf903aed04049158d85c37a1106"},"previous_names":["fcrozetta/template-fastapi-postgres"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/fcrozetta/template-fastapi-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcrozetta%2Ftemplate-fastapi-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcrozetta%2Ftemplate-fastapi-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcrozetta%2Ftemplate-fastapi-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcrozetta%2Ftemplate-fastapi-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcrozetta","download_url":"https://codeload.github.com/fcrozetta/template-fastapi-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcrozetta%2Ftemplate-fastapi-postgres/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260193911,"owners_count":22972618,"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":[],"created_at":"2024-10-01T16:50:44.792Z","updated_at":"2025-06-16T16:04:42.933Z","avatar_url":"https://github.com/fcrozetta.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# template-fastapi-postgres\n\nThis is a template created to develop fastapi applications that connect to a postgres database.\nThe intention of local development is a devcontainer, using vscode; But you it should work with any editor/environment. In order to allow other IDEs to use it without vscode, the configuration happens in a specific [docker-compose.yml](.devcontainer/docker-compose.yml) file, and the image built is in the [Dockerfile](Dockerfile) at root level.\n\n\u003e**NOTE:** Some modification may be necessary to work with different setups\n\nIn this project you will see 3 containers running: \n\n- app: the container you are working on, and where your codebase is located\n- db: a postgres database to connect locally\n- adminer: a GUI to access the database (port 8080)\n\n## packages used\n\n- fastapi (API)\n- SQLAlchemy (ORM)\n- alembic (DB migrations)\n- poetry (package management)\n- uvicorn (server application)\n\n## Quickstart\n\nCreate a new project using this as a template. Then, change the project name in [pyproject.toml](pyproject.toml) file. Rebuild the container, and everything should work fine. \n\n\u003e**NOTE:** If something goes wrong when running this initial setup, try to update poetry packages and rebuild the container.\n\n## Project Structure\n\n\u003e If you already are familiar with the structure, feel free to skip this section\n\nLet's separate the content of this project in two: *code* and *infrastructure*.\n\nEverything related to **code** is what you would expect in any python project:\n\n- *.env* \u0026 *local.env*: environment variables you will need in your code\n- *poetry.lock* \u0026 *pyproject.toml*: used by poetry to manage your packages\n- *src/*: The source folder where you application sits. **Your code should be here**\n\nThen you have **infrastructure**. Those files are needed to make everything work in codespaces, vscode, etc:\n\n- *.devcontainer/*: folder that contain the files that allow codespaces and vscode to setup your environment inside a docker container.\n- *.vscode/*: folder that contains the configuration for executing and debugging. This is a generic configuration, and you can modify it, if your project needs it. Remember this is shared amongst other developers, so do not add settings only valid for you.\n- *Dockerfile*: is the configuration for your environment. This file is exposed so you can change your environment like updating the python version.\n\n## Alembic\n\nAlembic is installed, and it runs the initial migration, already prepared. In a new project, you should delete the existing migration, and create a new one based on your configuration. \n\nIn alembic's [env.py](src/alembic/env.py) the target metadata was set based on user model. Change this, according to your needs. Alembic.ini was also modified, but you don't **need** to change it.\n\n\u003e**NOTE**: alembic configuration is based in the user model. If you remove this moodel, you have to change it in env.py as well\n\n### quick help on migration\n\nbefore migration, you need to create a new revision:\n\n```bash\nalembic revision -m \"migration description\" --autogenerated\n```\n\nThis will create a new revision, based on your changes in the models.\n\nTo apply update the database to the latest migrations, use the following command:\n\n```bash\nalembic upgrade head\n```\n\nFor more information about alembic, check the [official documentation](https://alembic.sqlalchemy.org/en/latest/tutorial.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcrozetta%2Ftemplate-fastapi-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcrozetta%2Ftemplate-fastapi-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcrozetta%2Ftemplate-fastapi-postgres/lists"}