{"id":22447292,"url":"https://github.com/yahrdev/fastapi_custom_auth_project","last_synced_at":"2025-03-27T11:26:24.663Z","repository":{"id":247797598,"uuid":"826870027","full_name":"yahrdev/fastapi_custom_auth_project","owner":"yahrdev","description":"This project is a backend application built with FastAPI and MySQL. Here custom user authorization using JWT, OAuth2 etc was implemented.","archived":false,"fork":false,"pushed_at":"2024-07-10T15:14:45.000Z","size":406,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T16:09:52.763Z","etag":null,"topics":["alembic","backend","fastapi","jwt","mysql","oauth2","python","sqlalchemy"],"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/yahrdev.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":"2024-07-10T14:41:52.000Z","updated_at":"2024-07-10T15:14:48.000Z","dependencies_parsed_at":"2024-07-10T18:10:26.258Z","dependency_job_id":null,"html_url":"https://github.com/yahrdev/fastapi_custom_auth_project","commit_stats":null,"previous_names":["yahrdev/fastapi_custom_auth_project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2Ffastapi_custom_auth_project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2Ffastapi_custom_auth_project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2Ffastapi_custom_auth_project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahrdev%2Ffastapi_custom_auth_project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahrdev","download_url":"https://codeload.github.com/yahrdev/fastapi_custom_auth_project/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245834724,"owners_count":20680062,"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","backend","fastapi","jwt","mysql","oauth2","python","sqlalchemy"],"created_at":"2024-12-06T04:15:40.043Z","updated_at":"2025-03-27T11:26:24.639Z","avatar_url":"https://github.com/yahrdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"This project is a backend application built with FastAPI and MySQL. It provides endpoints for user registration, login, adding posts, retrieving posts, and deleting posts. The application follows the MVC design pattern and uses SQLAlchemy for database interactions. *Also implemented custom user authorization using JWT, OAuth2 etc.*\n\n\u003cimg src=\"fastapi_custom_users_project.png\" width=\"700\"\u003e\n\n## API Endpoints\n\n### 1. Signup endpoint\n- **Description**: Allows users to sign up with their email and password.\n- **Inputs**: `email`, `password`\n- **Output**: Returns a token (JWT).\n\n### 2. Login endpoint\n- **Description**: Authenticates users using their email and password.\n- **Inputs**: `email`, `password`\n- **Output**: Returns a token (JWT) upon successful login.\n\n### 3. AddPost endpoint\n- **Description**: Adds a new post.\n- **Inputs**: `text`, `token`\n- **Output**: Returns `postID`.\n- **Details**: Validates the payload size (the payload should not exceed 1 MB in size) and saves the post in memory.\n\n### 4. GetPosts endpoint\n- **Description**: Retrieves all posts added by the authenticated user.\n- **Inputs**: `token`\n- **Output**: Returns all posts added by the user.\n- **Details**: Implements response caching for consecutive requests from the same user for up to 5 minutes.\n\n### 5. DeletePost endpoint\n- **Description**: Deletes a specified post.\n- **Inputs**: `postID`, `token` (to authenticate the request)\n- **Output**: Confirms deletion of the corresponding post from memory.\n\n---------------------------------------------------------------------------------------------------------------\n\n## Moduls/programs used\n\n- Python and FastAPI: Core of the application.\n- MySQL: Database for storing user and post data.\n- Alembic: For database migrations.\n- Pydantic: For data validation.\n- JWT: For authentication.\n\n------------------------------------------------------------------------------------------------------------------\n\n## Requirements \n\n- Python 3.9 or higher installed.\n- MySQL server installed.\n\n------------------------------------------------------------------------------------------------------------------\n\n### Installation\n\nClone the repository:\n\n```bash\ngit clone \u003crepository_url\u003e\ncd fastapi_users_project\n```\n\nCreate and activate a virtual environment:\n\n```bash\npython -m venv venv\nsource venv/bin/activate   # On Windows use `venv\\Scripts\\activate`\n```\n\nInstall the required dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\nCreate a .env file in the project root with the following content:\n\n```bash\nDB_USER = your_db_user\nDB_PASS = your_db_password\nDB_HOST = localhost\nDB_NAME = fastapiproj\nDB_PORT = 3306\n\nMODE = PROD\n\nSECRET = your_secret_key\nJWT_LIFETIME_MINUTES = 30\n```\n\nSet up the database:\n\n```bash\nmysql -u root -p\nCREATE DATABASE fastapiproj;\n```\n\nUse Alembic to create the tables:\n\n```bash\nalembic revision --autogenerate -m \"Initial migration\"\nalembic upgrade head\n```\n\nStart the FastAPI application:\n\n```bash\nuvicorn src.main:app --host 0.0.0.0 --port 8000\n```\n\nAccess the application at http://localhost:8000. You can view the automatically generated API documentation at http://localhost:8000/docs.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahrdev%2Ffastapi_custom_auth_project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahrdev%2Ffastapi_custom_auth_project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahrdev%2Ffastapi_custom_auth_project/lists"}