{"id":19874728,"url":"https://github.com/dxphilo/octo","last_synced_at":"2025-05-02T10:31:36.223Z","repository":{"id":186946127,"uuid":"652515079","full_name":"dxphilo/octo","owner":"dxphilo","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-08T09:46:56.000Z","size":25,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T18:35:50.766Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dxphilo.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}},"created_at":"2023-06-12T08:23:02.000Z","updated_at":"2024-04-21T16:26:47.000Z","dependencies_parsed_at":"2023-08-08T11:27:58.556Z","dependency_job_id":null,"html_url":"https://github.com/dxphilo/octo","commit_stats":null,"previous_names":["dxphilo/octo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Focto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Focto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Focto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dxphilo%2Focto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dxphilo","download_url":"https://codeload.github.com/dxphilo/octo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224307277,"owners_count":17289777,"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-11-12T16:25:11.783Z","updated_at":"2024-11-12T16:25:12.321Z","avatar_url":"https://github.com/dxphilo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI Application\nFastAPI. Article Guide [here](https://python.plainenglish.io/building-a-restful-api-with-fastapi-secure-signup-and-login-functionality-included-45cdbcb36106)\n## Features\n\n- User Registration: Users can create an account.\n- User Login: Users can log in to their accounts.\n- Role-based Authentication: Three roles with different permission levels - regular user, user manager, admin.\n- CRUD Operations: Users can create, read, update, and delete their owned records.\n- User Manager: User managers can CRUD users.\n- Admin: Admins can CRUD all records and users.\n- Entry Information: Each entry has a date, time, text, and number of calories.\n- Calories API Integration: If calories are not provided, the API connects to a Calories API provider to fetch the number of calories for the entered meal.\n- User Setting: Users can set their expected number of calories per day.\n- Calorie Comparison: Each entry has a boolean field indicating if the total calories for the day are less than the expected number of calories.\n- JSON API: Data is returned in JSON format.\n- Filtering and Pagination: Endpoints provide filter capabilities and support pagination.\n- Unit and E2E Tests: Includes unit tests and end-to-end tests.\n- Python Web Framework: Uses any Python web framework.\n- SQLite Database: Uses SQLite as the database.\n\n## Installation and Setup\n\n#### Clone the repository.\n\n```shell\n    git clone https://github.com/dxphilo/octo.git\n```\n\n#### ENV Setup\n\nCreate a file named .env in the root directory of your project.\n\n```shell\n    cp .env.example .env\n```\n\n\n#### Install the required dependencies.\n\n```shell\n    pip install -r requirements.txt\n```\n#### Set up the database with sqlite.\n\n```shell\n    python create_db.py\n```\n\n#### Run the application.\n\nApplication will be exposed to port 8000 on http://localhost:8000/\n\n```shell\n    python main.py\n```\n\n#### Testing\n\nRunning tests.\n\nwill run all test suites\n```shell\n    pytest\n```\n\nYou can run specific test file, i,e\n\nTo run entry specific tests\n\n```shell\n  pytest -k test_entry_api.py     \n```\n\nTo run user specific tests\n\n```shell\n  pytest -k test_user_api.py   \n```  \n\nTo run utility specific tests\n\n```shell\n  pytest -k test_helpers.py   \n```  \n\n### Usage\n\nOpen the API documentation in your browser by visiting http://localhost:8000/docs.\n\n\n## API Endpoints\n\nThe following endpoints are available in the API:\n\nSend token in the form: \n\n```ssh\n  Authorization: Bearer \u003cyour-token-here\u003e\n```\n\n### 1. Create a User\n\n- **Endpoint**: `/signup/`\n- **Method**: `POST`\n- **Request Body**:\n  - `fullname` (string): Full name of the user (required)\n  - `email` (string): Email of the user (required)\n  - `password` (string): Password of the user (required)\n  - `role` (string): Role of the user (required)\n- **Response**:\n  - `id` (integer): ID of the created user\n  - `fullname` (string): Full name of the created user\n  - `email` (string): Email of the created user\n  - `role` (string): Role of the created user\n  - `date` (string): Current date\n  - `time` (string): Current time\n\n### 2. User Login\n\n- **Endpoint**: `/login/`\n- **Method**: `POST`\n- **Request Body**:\n  - `email` (string): Email of the user (required)\n  - `password` (string): Password of the user (required)\n- **Response**:\n  - `access_token` (string): JWT access token for authentication\n\n### 3. Get Users\n\n- **Endpoint**: `/users/`\n- **Method**: `GET`\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - List of user objects:\n    - `id` (integer): ID of the user\n    - `fullname` (string): Full name of the user\n    - `email` (string): Email of the user\n    - `role` (string): Role of the user\n    - `date` (string): Current date\n    - `time` (string): Current time\n\n### 4. Update User Details\n\n- **Endpoint**: `/users/{user_id}/`\n- **Method**: `PUT`\n- **Path Parameters**:\n  - `user_id` (integer): ID of the user to update (required)\n- **Request Body**:\n  - `fullname` (string): New full name of the user (required)\n  - `email` (string): New email of the user (required)\n  - `password` (string): New password of the user (required)\n  - `role` (string): New role of the user (required)\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `id` (integer): ID of the updated user\n  - `fullname` (string): New full name of the user\n  - `email` (string): New email of the user\n  - `role` (string): New role of the user\n  - `date` (string): Current date\n  - `time` (string): Current time\n\n### 5. Delete User\n\n- **Endpoint**: `/users/{user_id}/`\n- **Method**: `DELETE`\n- **Path Parameters**:\n  - `user_id` (integer): ID of the user to delete (required)\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `message` (string): Deletion success message\n\n### 6. Save User Entries\n\n- **Endpoint**: `/user/entries/`\n- **Method**: `POST`\n- **Request Body**:\n  - `text` (string): Entry text (required)\n  - `tags` (list): List of entry tags\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `id` (integer): ID of the created entry\n  - `text` (string): Entry text\n  - `tags` (list): List of entry tags\n  - `date` (string): Current date\n  - `time` (string): Current time\n\n### 7. Get User Entries\n\n- **Endpoint**: `/user/entries/`\n- **Method**: `GET`\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - List of entry objects:\n    - `id` (integer): ID of the entry\n    - `text` (string): Entry text\n    - `tags` (list): List of entry tags\n    - `date` (string): Current date\n    - `time` (string): Current time\n\n### 8. Get Entry Details\n\n- **Endpoint**: `/user/entries/{entry_id}/`\n- **Method**: `GET`\n- **Path Parameters**:\n  - `entry_id` (integer): ID of the entry to retrieve (required)\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `id` (integer): ID of the entry\n  - `text` (string): Entry text\n  - `tags` (list): List of entry tags\n  - `date` (string): Current date\n  - `time` (string): Current time\n\n### 9. Update Entry\n\n- **Endpoint**: `/user/entries/{entry_id}/`\n- **Method**: `PUT`\n- **Path Parameters**:\n  - `entry_id` (integer): ID of the entry to update (required)\n- **Request Body**:\n  - `text` (string): New entry text (required)\n  - `tags` (list): New list of entry tags\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `id` (integer): ID of the updated entry\n  - `text` (string): New entry text\n  - `tags` (list): New list of entry tags\n  - `date` (string): Current date\n  - `time` (string): Current time\n\n### 10. Delete Entry\n\n- **Endpoint**: `/user/entries/{entry_id}/`\n- **Method**: `DELETE`\n- **Path Parameters**:\n  - `entry_id` (integer): ID of the entry to delete (required)\n- **Headers**:\n  - `Authorization` (string): JWT access token (required)\n- **Response**:\n  - `message` (string): Deletion success message\n\n\n\n## Contributing\n\nContributions are welcome! If you encounter any issues or have suggestions for improvement, please create an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxphilo%2Focto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdxphilo%2Focto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdxphilo%2Focto/lists"}