{"id":26172468,"url":"https://github.com/pauljwright/weird_salads","last_synced_at":"2026-04-24T13:32:47.908Z","repository":{"id":251840725,"uuid":"837732609","full_name":"PaulJWright/weird_salads","owner":"PaulJWright","description":"A weekend attempt at a full-stack web app using a unit-of-work and repository patterns. Streamlit, FastAPI, Docker, SQLAlchemy, SQLite, Alembic","archived":false,"fork":false,"pushed_at":"2024-08-07T22:40:04.000Z","size":2376,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T02:29:50.180Z","etag":null,"topics":["alembic","docker","docker-compose","fastapi","python","repository-pattern","sqlalchemy","sqlite","unit-of-work-pattern"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaulJWright.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"licenses/LICENSE.rst","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-03T21:22:48.000Z","updated_at":"2024-09-02T20:24:06.000Z","dependencies_parsed_at":"2024-08-06T04:09:53.939Z","dependency_job_id":null,"html_url":"https://github.com/PaulJWright/weird_salads","commit_stats":null,"previous_names":["pauljwright/weird_salads"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PaulJWright/weird_salads","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJWright%2Fweird_salads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJWright%2Fweird_salads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJWright%2Fweird_salads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJWright%2Fweird_salads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulJWright","download_url":"https://codeload.github.com/PaulJWright/weird_salads/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJWright%2Fweird_salads/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32225758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"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":["alembic","docker","docker-compose","fastapi","python","repository-pattern","sqlalchemy","sqlite","unit-of-work-pattern"],"created_at":"2025-03-11T19:56:36.944Z","updated_at":"2026-04-24T13:32:47.890Z","avatar_url":"https://github.com/PaulJWright.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Overview\n--------\n\nThis project provides a web app and backend, with the backend built on Python and SQLite. The architecture is \"hexagonal\", utilising a repository pattern (plus Unit of Work pattern; see `weird_salads/utils/unit_of_work.py`, or `https://github.com/PaulJWright/weird_salads/pull/7` for an overview of the initial Orders implementation) for data access.\n\nInitial design documentation on the API, database, repository, and technologies can be found in the `weird_salads/README.rst` (`https://github.com/PaulJWright/weird_salads/blob/main/weird_salads/README.rst`). The repository is split into two services: Orders and Inventory. Integration of these services occurs through HTTP requests, although other methods were considered.\n\nStart the Services\n==================\n\nTo get started, run the following commands (for a more complete breakdown, see `/docker/README.rst`):\n\n.. code-block:: bash\n\n    cd docker\n    docker compose up --build\n\nHere, the `docker-compose.yml` file defines the `location_id` and `quantity` that are used for seeding the database from empty (`weird_salads/utils/database/seed_db.py`). This seeding is performed from `data/*.csv` files, which are downloaded sheets from the provided Google Sheet document. The following example during initialization shows that the seeding process is complete for location 1 with a quantity of 1000 for each ingredient.\n\n.. code-block:: bash\n\n    fastapi-1    | INFO - Starting data seeding process\n    fastapi-1    | INFO - Seeding completed successfully for location 1 and quantity 1000.0.\n\nOnce these services are running, the FastAPI endpoints can be accessed at `http://localhost:8000`, and the Streamlit frontend at `http://localhost:8501`. The FastAPI Docker container interacts with a SQLite database located at `/data/orders.db`, which can easily be viewed through a GUI, such as `https://sqlitebrowser.org/dl/`.\n\nFastAPI\n=======\n\nAn overview of the FastAPI endpoints (designed here: `https://github.com/PaulJWright/weird_salads/blob/main/weird_salads/README.rst`) is shown below:\n\n.. image:: docs/misc/api_page.png\n  :alt: API design\n\nThis is semi-complete, allowing various tasks, such as:\n\n* Selling items (POST `/order`)\n* Accepting deliveries (POST `/inventory`)\n\nThese are the primary tasks involved in the business.\n\nOther tasks, such as taking stock, can be completed through various endpoints (e.g. viewing inventory, updating), and reports are better suited to the frontend.\n\nThe working ordering system can be demonstrated by executing an order on `http://localhost:8000/docs#/Order/create_order_order_post`, for example `menu_id = 18`, which will return a response like:\n\n.. code-block:: json\n\n    {\n        \"menu_id\": 18,\n        \"id\": \"e893be34-b95e-4a94-8c46-9da9d2bca288\",\n        \"created\": \"2024-08-05T23:52:43.498404\"\n    }\n\nThis can be verified at `http://localhost:8000/docs#/Order/get_orders_order_get`, for example:\n\n.. code-block:: json\n\n    [\n        {\n            \"menu_id\": 18,\n            \"id\": \"e893be34-b95e-4a94-8c46-9da9d2bca288\",\n            \"created\": \"2024-08-05T23:52:43.498404\"\n        }\n    ]\n\nYou can get more information on a certain menu at `/menu/`, and specific details on an item, including ingredients, at `/menu/{item_id}`. For availability information, there is also the `/menu/{item_id}/availability` endpoint, which can be checked before and after a POST to the `/order` endpoint.\n\nStreamlit\n=========\n\nThe Streamlit frontend is unfortunately lacking in features, particularly in error handling, as this was my first time using Streamlit (chosen as a simple frontend solution).\nSimple fixes would be to propagate the errors properly from the API endpoints, and add filtering functionality to create the reports\n\n\u003e The working ordering system can be demonstrated by clicking an order, and checking the order reports page, which should display the UUID for the order.\n\n.. image:: docs/misc/streamlit_menu.png\n  :alt: Streamlit Menu\n\n.. image:: docs/misc/streamlit_orders_report.png\n  :alt: Orders\n\nNotes\n=====\n\n**Positives:**\n\n* I spent time on the first day designing the API and database, knowing that I wanted to build on the repository pattern. I chose to prioritise this to reduce the scope of the project and to get a better time estimate for completion.\n* I prioritised seeding the database with a certain location to reduce the handling of `staff` and `locations` tables.\n\n**Negatives:**\n\n* I wish I had spent more time properly writing unit and integration tests. This is the next thing I would do if I had more time.\n* Type hinting and docstrings are incomplete, another thing I will do with more tmie.\n* I would like to further understand how to implement a proper frontend with error handling using a technology such as React.\n* The handling of units in the deduction of ingredients is not complete and was an oversight.\n\n**Summary:**\n\nOverall, I limited the scope through:\n\n* Fixing a location in the database seeding,\n* Primarily concentrating on selling orders and accepting deliveries,\n* Concentrating on merge requests that addressed end-to-end changes from the database through to the frontend app, to provide a complete app from the beginning.\n\n**Further basic scratch notes:**\n\n* Docker: `https://github.com/PaulJWright/weird_salads/blob/main/docker/README.rst`\n* Database: `https://github.com/PaulJWright/weird_salads/blob/main/database/README.rst`\n* API/Database/Repo: `https://github.com/PaulJWright/weird_salads/blob/main/weird_salads/README.rst`\n* Initial OrdersService/OrdersRepository implementation: https://github.com/PaulJWright/weird_salads/pull/7\n\nDeveloping\n==========\n\nTo get started locally, you can install the package and use it as follows:\n\n.. code:: bash\n\n    pip install -e .\n\nThen you can import the utility functions in your Python script:\n\n.. code:: python\n\n    import weird_salads\n\nThis codebase uses pre-commit etc.\n\n.. code:: bash\n\n    pre-commit install\n\n.. code:: bash\n\n    (weird_salads) ➜  mad_salads git:(feature/initial_setup) ✗ pre-commit run --all\n    ruff.....................................................................Passed\n    black....................................................................Passed\n    isort....................................................................Passed\n    check python ast.........................................................Passed\n    check for case conflicts.................................................Passed\n    trim trailing whitespace.................................................Passed\n    check yaml...............................................................Passed\n    debug statements (python)................................................Passed\n    check for added large files..............................................Passed\n    fix end of files.........................................................Passed\n    mixed line ending........................................................Passed\n    codespell................................................................Passed\n\n\nLicense\n-------\n\nThis project is Copyright (c) Paul Wright and licensed under\nthe terms of the GNU GPL v3+ license. This package is based upon\nthe `Openastronomy packaging guide \u003chttps://github.com/OpenAstronomy/packaging-guide\u003e`_\nwhich is licensed under the BSD 3-clause licence. See the licenses folder for\nmore information.\n\nContributing\n------------\n\nWe love contributions! weird_salads is open source,\nbuilt on open source, and we'd love to have you hang out in our community.\n\n**Imposter syndrome disclaimer**: We want your help. No, really.\n\nThere may be a little voice inside your head that is telling you that you're not\nready to be an open source contributor; that your skills aren't nearly good\nenough to contribute. What could you possibly offer a project like this one?\n\nWe assure you - the little voice in your head is wrong. If you can write code at\nall, you can contribute code to open source. Contributing to open source\nprojects is a fantastic way to advance one's coding skills. Writing perfect code\nisn't the measure of a good developer (that would disqualify all of us!); it's\ntrying to create something, making mistakes, and learning from those\nmistakes. That's how we all improve, and we are happy to help others learn.\n\nBeing an open source contributor doesn't just mean writing code, either. You can\nhelp out by writing documentation, tests, or even giving feedback about the\nproject (and yes - that includes giving feedback about the contribution\nprocess). Some of these contributions may be the most valuable to the project as\na whole, because you're coming to the project with fresh eyes, so you can see\nthe errors and assumptions that seasoned contributors have glossed over.\n\nNote: This disclaimer was originally written by\n`Adrienne Lowe \u003chttps://github.com/adriennefriend\u003e`_ for a\n`PyCon talk \u003chttps://www.youtube.com/watch?v=6Uj746j9Heo\u003e`_, and was adapted by\nweird_salads based on its use in the README file for the\n`MetPy project \u003chttps://github.com/Unidata/MetPy\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljwright%2Fweird_salads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauljwright%2Fweird_salads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljwright%2Fweird_salads/lists"}