{"id":25639276,"url":"https://github.com/definetlynotai/scrapyard_shop","last_synced_at":"2025-02-23T03:29:21.171Z","repository":{"id":278754139,"uuid":"936664295","full_name":"DefinetlyNotAI/Scrapyard_Shop","owner":"DefinetlyNotAI","description":"Simple shop structure for hackathon's using postgresql","archived":false,"fork":false,"pushed_at":"2025-02-21T14:18:07.000Z","size":91,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T14:33:23.472Z","etag":null,"topics":["app","css","flask","html","js","python","scrapyard","shop","website"],"latest_commit_sha":null,"homepage":"https://scrapyard-shop.vercel.app","language":"CSS","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/DefinetlyNotAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-21T13:26:26.000Z","updated_at":"2025-02-21T14:18:11.000Z","dependencies_parsed_at":"2025-02-21T14:44:25.614Z","dependency_job_id":null,"html_url":"https://github.com/DefinetlyNotAI/Scrapyard_Shop","commit_stats":null,"previous_names":["definetlynotai/scrapyard_shop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FScrapyard_Shop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FScrapyard_Shop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FScrapyard_Shop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DefinetlyNotAI%2FScrapyard_Shop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DefinetlyNotAI","download_url":"https://codeload.github.com/DefinetlyNotAI/Scrapyard_Shop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240265402,"owners_count":19774070,"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":["app","css","flask","html","js","python","scrapyard","shop","website"],"created_at":"2025-02-23T03:29:20.360Z","updated_at":"2025-02-23T03:29:21.152Z","avatar_url":"https://github.com/DefinetlyNotAI.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shop Platform (For hackathons)\r\n\r\nThis project is a Shopping platform built using Python and Flask for hackathons (Specifically Scrapyard).\r\nIt's derived from Scrapyard Bounty (Sharjah), \r\n\r\n## Features\r\n\r\n- User authentication and session management\r\n- Full Shop Features\r\n  - Setting up items and stock\r\n  - Admin Panel\r\n  - Buying and receipt management and more\r\n- Simple RESTful API\r\n- Vercel Support\r\n\r\n## Installation\r\n\r\n1. Clone the repository:\r\n    ```sh\r\n    git clone https://github.com/DefinetlyNotAI/Scrapyard_Bounty.git\r\n    cd ctf-platform\r\n    ```\r\n\r\n2. Install the required packages:\r\n    ```sh\r\n    pip install -r requirements.txt\r\n    ```\r\n   \r\n3. Setup DB tables:\r\n    ```sh\r\n    python manual_setup.py\r\n    ```\r\n\r\n## Usage\r\n\r\n### Locally\r\n1. Run the Flask application:\r\n    ```sh\r\n    python Shop.py\r\n    ```\r\n\r\n2. Open your web browser and navigate to `http://127.0.0.1:5000`.\r\n\r\n### Vercel\r\n1. Fork this project,\r\n2. Modify the `vercel.json` as needed\r\n3. In Vercel, select the fork for building the project (DON'T BUILD YET)\r\n4. When it asks for the env variables in the settings (before building), put the following:\r\n    ```md\r\n    DB_URL_AIVEN = Your DB Secret URL - Doesn't have to be from AIVEN\r\n    DB_NAME = From the URL, get the DB name you will use, example: `postgres://USERNAME:PASSWORD@ORG_NAME.PROJECT_NAME.l.aivencloud.com:PORT/HERE_IS_THE_DBNAME?sslmode=require`\r\n    SECRET_KEY = Just anything, it's the password to secure the Flask connection\r\n   ```\r\n5. Now you can click build, and everything should be working fine, modify as your heart desires!!\r\n\r\n\r\n### Modification\r\n\r\n\u003e [!NOTE]\r\n\u003e The CSS is very messy!!\r\n\r\nYou must setup the following:\r\n- (tested on `AIVEN`) ---\u003e Postgresql Database\r\n- (tested on `VERCEL`) -\u003e Have these env variables setup: DB_NAME (The db name), DB_URL_AIVEN (The secret api url), SECRET_KEY (Any key to secure flask, just type anything)\r\n\r\nThe code will make sure it init the database, it will be populated with these tables:\r\n- teams: For storing user/team credentials and related info.\r\n- item: For storing items in the shop.\r\n- receipt: For storing purchase receipts.\r\n- missions: For storing missions related to the items.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e Even though the original code had an main admin panel (this still has the subpanels like , this doesn't (due to integration reasons) - So you should implement your own!\r\n\u003e (Or use my code in the [scrapyard bounty](https://github.com/DefinetlyNotAI/Scrapyard_Bounty), but you should integrate it properly...)\r\n\r\n---\r\n\r\nCreating the username ADMIN gives you admin rights, so do make it and remember the password!\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please fork the repository and submit a pull request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n\r\n\r\n---\r\n\r\n# API Documentation\r\n\r\nThis document provides a detailed overview of the available API endpoints for the project.\r\nEach endpoint includes information on the HTTP method, URL, required parameters,\r\nand whether admin access is required as well as rate limits.\r\n\r\n\u003e [!IMPORTANT]\r\n\u003e Keep the `accept_mimetypes` as \"*/*\" in the request headers to receive JSON error responses.\r\n\u003e The API is designed to return HTML responses by default if errors occur.\r\n\r\n---\r\n\r\n### `executeQuery`\r\n\r\n- **URL:** `/api/executeQuery`\r\n- **Method:** POST\r\n- **Description:** Executes a SQL query on the database.\r\n- **Admin?:** 🔐\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ❌ (Requires an HTTP request with a JSON payload)\r\n- **Request Body Preview:**\r\n  ```json\r\n  {\r\n    \"query\": \"SELECT * FROM users\"\r\n  }\r\n  ```\r\n- **Response preview**\r\n    - `#200`:\r\n       ```json\r\n       {\r\n         \"id\": 1,\r\n         \"username\": \"example_user\",\r\n         \"email\": \"user@example.com\"\r\n       }\r\n       ```\r\n    - `#400`:\r\n       ```json\r\n       {\r\n         \"error\": \"No query provided\"\r\n       }\r\n       ```\r\n    - `#500`:\r\n       ```json\r\n       {\r\n         \"error\": \"Query Execution Failed - API execute_query\"\r\n       }\r\n       ```\r\n\r\n---\r\n\r\n### `api_status`\r\n\r\n- **URL:** `/api/status`\r\n- **Method:** GET\r\n- **Description:** Checks if the API is running and verifies database connectivity.\r\n- **Admin?:** 🔓\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ✅\r\n- **Response preview**\r\n    - `#200`:\r\n       ```json\r\n       {\r\n         \"status\": \"API is running\",\r\n         \"uptime_seconds\": 12345.67,\r\n         \"database_connected\": true\r\n       }\r\n       ```\r\n\r\n---\r\n\r\n### `buy`\r\n\r\n- **URL:** `/api/shop/buy`\r\n- **Method:** POST\r\n- **Description:** Allows a user to buy an item from the shop, generating a receipt image if the item is in stock.\r\n- **Admin?:** 🔓\r\n- **Rate Limit:** 🔥 30 requests/hour\r\n- **Plug and Play?:** ❌ (Proper JSON body must be sent)\r\n- **Request Body Preview:**\r\n  ```json\r\n  {\r\n    \"item_id\": \"123\",\r\n    \"email\": \"user@example.com\"\r\n  }\r\n  ```\r\n- **Response preview**\r\n    - `#200`:\r\n      ```json\r\n      {\r\n        \"message\": \"Receipt generated successfully\",\r\n        \"receipt_url\": \"path/to/receipt_image.png\"\r\n      }\r\n      ```\r\n    - `#400`:\r\n      ```json\r\n      {\r\n        \"message\": \"Invalid input! Make sure all fields are filled.\"\r\n      }\r\n      ```\r\n    - `#404`:\r\n      ```json\r\n      {\r\n        \"message\": \"Item out of stock\"\r\n      }\r\n      ```\r\n\r\n---\r\n\r\n### `update_stock`\r\n\r\n- **URL:** `/api/shop/update_stock`\r\n- **Method:** POST\r\n- **Description:** Allows an admin to update the stock levels for items in the shop.\r\n- **Admin?:** 🔐\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ❌ (Admin required and Proper JSON body must be sent)\r\n- **Request Body Preview:**\r\n  ```json\r\n  {\r\n    \"stock_123\": \"10\",\r\n    \"stock_124\": \"5\"\r\n  }\r\n  ```\r\n- **Response preview**\r\n    - `#200`:\r\n      ```json\r\n      {\r\n        \"message\": \"Stock updated successfully!\"\r\n      }\r\n      ```\r\n    - `#400`:\r\n      ```json\r\n      {\r\n        \"message\": \"Invalid stock values\"\r\n      }\r\n      ```\r\n\r\n---\r\n\r\n### `cancel_receipt`\r\n\r\n- **URL:** `/api/shop/cancel_receipt`\r\n- **Method:** POST\r\n- **Description:** Allows an admin to cancel a receipt by deleting it from the database.\r\n- **Admin?:** 🔐\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ❌ (Admin required and Proper JSON body must be sent)\r\n- **Request Body Preview:**\r\n  ```json\r\n  {\r\n    \"receipt_id\": \"abc123\"\r\n  }\r\n  ```\r\n- **Response preview**\r\n    - `#200`:\r\n      ```json\r\n      {\r\n        \"message\": \"Receipt cancelled!\"\r\n      }\r\n      ```\r\n    - `#400`:\r\n      ```json\r\n      {\r\n        \"message\": \"Receipt not found\"\r\n      }\r\n      ```\r\n\r\n---\r\n\r\n### `remove_mission`\r\n\r\n- **URL:** `/api/shop/remove_mission/\u003cint:mission_id\u003e`\r\n- **Method:** GET\r\n- **Description:** Allows an admin to remove a mission from the system.\r\n- **Admin?:** 🔐\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ✔️ (Admin required)\r\n- **Response preview**\r\n    - `#200`:\r\n      ```json\r\n      {\r\n        \"message\": \"Mission removed successfully!\"\r\n      }\r\n      ```\r\n    - `#404`:\r\n      ```json\r\n      {\r\n        \"message\": \"Mission not found\"\r\n      }\r\n      ```\r\n\r\n---\r\n\r\n### `add_mission`\r\n\r\n- **URL:** `/api/shop/add_mission`\r\n- **Method:** GET, POST\r\n- **Description:** Allows an admin to add a new mission to the system.\r\n- **Admin?:** 🔐\r\n- **Rate Limit:** 🚀\r\n- **Plug and Play?:** ❌ (Admin required and Proper JSON body must be sent)\r\n- **Request Body Preview:**\r\n  ```json\r\n  {\r\n    \"name\": \"New Mission\",\r\n    \"description\": \"A description of the new mission\",\r\n    \"scraps\": \"100\"\r\n  }\r\n  ```\r\n- **Response preview**\r\n    - `#200`:\r\n      ```json\r\n      {\r\n        \"message\": \"Mission added successfully!\"\r\n      }\r\n      ```\r\n    - `#400`:\r\n      ```json\r\n      {\r\n        \"message\": \"All fields are required!\"\r\n      }\r\n      ```\r\n\r\n---\r\n\r\n### Mini Table for Emoji Explanation\r\n\r\n| Emoji | Sector        | Meaning                                                                             |\r\n|-------|---------------|-------------------------------------------------------------------------------------|\r\n| ❌     | Plug and Play | Impossible to use directly in the browser (requires proper HTTP requests)           |\r\n| ✔️    | Plug and Play | Requires some setup (like being logged in or an admin) but still browser-accessible |\r\n| ✅     | Plug and Play | Fully accessible via browser without any additional setup                           |\r\n| 🔓    | Admin?        | No admin required to use the api                                                    |\r\n| 🔐    | Admin?        | Admin is required to use the api                                                    |\r\n| 🚀    | Rate Limit    | No rate limit                                                                       |\r\n\r\n---\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinetlynotai%2Fscrapyard_shop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefinetlynotai%2Fscrapyard_shop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefinetlynotai%2Fscrapyard_shop/lists"}