{"id":27484559,"url":"https://github.com/praisetompane/app_flask_archetype","last_synced_at":"2025-04-16T16:44:21.645Z","repository":{"id":278031360,"uuid":"934263649","full_name":"praisetompane/app_flask_archetype","owner":"praisetompane","description":"A Flask archetype project with common patterns to enable focusing on the unique aspects of your application instead of setup ceremony.","archived":false,"fork":false,"pushed_at":"2025-03-31T05:40:31.000Z","size":675,"stargazers_count":0,"open_issues_count":14,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-31T06:27:56.250Z","etag":null,"topics":["alembic","docker","docker-compose","flask","gunicorn","python","sql","sqlalchemy"],"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/praisetompane.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}},"created_at":"2025-02-17T14:43:30.000Z","updated_at":"2025-03-31T05:40:34.000Z","dependencies_parsed_at":"2025-03-08T10:20:30.226Z","dependency_job_id":"fe98f0a0-fdf3-4a6b-8ffc-be905d9ae48b","html_url":"https://github.com/praisetompane/app_flask_archetype","commit_stats":null,"previous_names":["praisetompane-utilities/app_flask_quickstart","praisetompane-utilities/app_flask_archetype","praisetompane/app_flask_archetype"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praisetompane%2Fapp_flask_archetype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praisetompane%2Fapp_flask_archetype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praisetompane%2Fapp_flask_archetype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/praisetompane%2Fapp_flask_archetype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/praisetompane","download_url":"https://codeload.github.com/praisetompane/app_flask_archetype/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249259170,"owners_count":21239422,"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":["alembic","docker","docker-compose","flask","gunicorn","python","sql","sqlalchemy"],"created_at":"2025-04-16T16:44:21.042Z","updated_at":"2025-04-16T16:44:21.633Z","avatar_url":"https://github.com/praisetompane.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# app_flask_archetype\n![build status](https://github.com/praisetompane-utilities/app_flask_archetype/actions/workflows/app.yaml/badge.svg)\n\n##  Objectives\n- A Flask archetype with common patterns to enable focusing on the unique aspects of your application instead of setup ceremony.\n- Features:\n    - [Project Conversion](#usage)\n    - HTTP REST API\n        - [Application Logic Resource](src/app_flask_archetype/api/api.py)\n        - [Health Check Resource](src/app_flask_archetype/api/health_check.py)\n        - [Input Validator](src/app_flask_archetype/api/validator.py)\n    - [External API Gateway](src/app_flask_archetype/gateway/external_api.py)\n    - [Repository Pattern implemented with SQLAlchemy and Postgres](src/app_flask_archetype/repository/computation_result_repository.py)\n    - [Alembic Migrations](src/app_flask_archetype/migrations/versions)\n    - [Tests](tests/app_flask_archetype)\n    - [GitHub Actions CI/CD](.github/workflows/app.yaml)\n\n## Project Structure\n- docs: Project documentation lives in here.\n- src: Production code lives in this folder and is divided in the modules below:\n    - app_flask_archetype: Project package.\n        - api:\n            - The HTTP API to the application lives in this module.\n            - The current implementation is a HTTP REST API, but a gRPC, CLI API, etc would be implemented in here.\n        - config:\n            - Configuration lives in here.\n        - core:\n            - the domain logic of the application lives in this module.\n        - gateway:\n            - Integration with external objects(e.g. files, external APIs etc) lives in here.\n        - model:\n            - The domain model lives in here.\n        - repository:\n            - Integration with internal data store (persistence and access) lives in here.\n        - app.py:\n            - The application factory to bootstrap the system lives in here.\n- tests: Test code lives in here.\n    - The tests are intentionally separated from production code.\n        - Benefits of this structure:\n            - Tests can run against an installed version of the app after using `pip install .`.\n            - Tests can run against the local copy with an editable install after executing `pip install --edit`.\n        - [more in depth discussion here](https://docs.pytest.org/en/latest/explanation/goodpractices.html#choosing-a-test-layout-import-rules)\n\n- utilities: Ad-hoc utilities such as scripts, curl \u0026 postman requests, JSON payloads, software installations, etc live in here.\n\n## Dependencies\n- [Docker](https://docs.docker.com/get-started/)\n\n## Package Management\n- [Pipenv](https://pipenv.pypa.io/en/latest/)\n    - [Quick Reference](https://pipenv.pypa.io/en/latest/cli.html#install)\n\n## Setup Instructions\n- The repository is configured to use [devcontainers](https://containers.dev) for development.\n    - [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers)\n\n## Usage\n- Project Conversion: Converts the project name to your desired name. This renames all import, configuration, etc.\n    ```shell\n    #target_app_name is desired project name\n    ./convert_project.sh target_app_name\n    ```\n- Steps Executed:\n    - Renames all occurrences of `app_flask_archetype` to `target_app_name`\n    - Optional Step: Rename the project folder to user desired project name.\n    This is a manual step, it is the folder you cloned this repository into.\n   \n## Run Program\n- The system automatically starts up as part of loading the project into an editor/IDE that supports devcontainers.\n    - If you would like to run the prod image, change `dockerfile: Dockerfile.dev` to `dockerfile: Dockerfile` in [docker-compose](docker-compose.debug.yaml).\n\n- Manual\n    - Execute the required update detailed here: [app_flask_archetype_postgres_service](https://github.com/praisetompane/app_flask_archetype/blob/aa89f106fa6485ab00719d4df5c094621604fb94/docker-compose.yaml#L11)\n    - Manually start\n        ```shell\n        ./start_system_development.sh\n        ```\n\n    - Manually stop\n        ```shell\n        ./stop_system_development.sh\n        ```\n\n- Invoke an endpoint\n    ```shell\n    # specifically imports malaria_annual_confirmed_cases from WHO API\n    ./utilities/curl/computation/computation.sh\n    ```\n\n- Debugging\n    - Debug with VSCode:\n        - Open the \"Run and Debug\" view.\n        - Execute the \"Python Debugger: Remote Attach\" task.\n            ![start system output](./docs/vscode_debugging.png)\u003cbr\u003e\n        - Allow debugging without frozen modules by clicking \"Debug Anyway\".\n            ![bypass frozen modules](./docs/vscode_debugging_frozen.png)\n        - The server will inform you the host and port in the terminal output at the bottom.\u003cbr\u003e\n        - Debug as you normally do(i.e. add break points, step into code definitions, evaluate code snippets, etc) \u003cbr\u003e\n\n    - If you would like to debug the prod image, change `dockerfile: Dockerfile.dev` to `dockerfile: Dockerfile` in [docker-compose.debug](docker-compose.debug.yaml).\n\n## Testing\n- ### Execute Unit Tests\n    ```shell\n    pytest\n    ```\n- ### Execute Integration Tests\n    ```shell\n    pytest tests/app_flask_archetype/integration\n    ```\n- ### Execute System Tests\n    ```shell\n    Not Implemented\n    ```\n- ### Execute Spellcheck\n    ```shell\n    pyspelling -c spellcheck.yaml\n    ```\n\n## Database State Management\n- The database state (i.e. tables, stored procedures, indexes, etc) are managed using [Alembic](https://alembic.sqlalchemy.org/en/latest/).\n    - Migrations location: src/app_flask_archetype/migrations\n    - Migrations naming scheme: YYYY_MM_DD_HHMM_rev_name\n        - uses alembic's full revision scheme defined in alembic.ini\n        - example: `2025_02_10_1349-9e2772c6755f_create_schema_computation.py`\n    - Current database state can be queried with `SELECT * FROM public.alembic_version;`\n- To upgrade the database to latest migrations:\n    ```shell\n    alembic upgrade head\n    ```\n- To downgrade the database to the base state:\n    ```shell\n    alembic downgrade base\n    ```\n\n## Spell Check\n```shell\npyspelling -c spellcheck.yaml\n```\n\n## Git Conventions\n- **NB:** The main is locked and all changes must come through a Pull Request.\n- Commit Messages:\n    - Provide concise commit messages that describe what you have done.\n        ```shell\n        # example:\n        git commit -m \"feat(core): algorithm\" -m\"implement my new shiny faster algorithm\"\n        ```\n    - screen shot of GitHub view\n    - references:\n        - https://www.conventionalcommits.org/en/v1.0.0/\n        - https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/\n\n**Disclaimer**: This is still work in progress.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraisetompane%2Fapp_flask_archetype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpraisetompane%2Fapp_flask_archetype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraisetompane%2Fapp_flask_archetype/lists"}