{"id":28816686,"url":"https://github.com/akshat3128/fastapi-ecommerce","last_synced_at":"2026-05-02T18:32:14.548Z","repository":{"id":299821477,"uuid":"1004317070","full_name":"Akshat3128/fastapi-ecommerce","owner":"Akshat3128","description":"A scalable e-commerce backend built with FastAPI, featuring JWT-based authentication, role-based access control, product management, cart, checkout, and order history APIs.","archived":false,"fork":false,"pushed_at":"2025-06-18T12:55:52.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-18T13:49:00.718Z","etag":null,"topics":["alembic","crud-application","fastapi","fastapi-security","github-config","jwt","postgresql","postman","pydantic-v2","python3","smtpmailer","sql-alchemy","swagger-ui"],"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/Akshat3128.png","metadata":{"files":{"readme":"README","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,"zenodo":null}},"created_at":"2025-06-18T12:47:02.000Z","updated_at":"2025-06-18T12:55:57.000Z","dependencies_parsed_at":"2025-06-18T13:59:07.024Z","dependency_job_id":null,"html_url":"https://github.com/Akshat3128/fastapi-ecommerce","commit_stats":null,"previous_names":["akshat3128/fastapi-ecommerce"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Akshat3128/fastapi-ecommerce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshat3128%2Ffastapi-ecommerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshat3128%2Ffastapi-ecommerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshat3128%2Ffastapi-ecommerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshat3128%2Ffastapi-ecommerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Akshat3128","download_url":"https://codeload.github.com/Akshat3128/fastapi-ecommerce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Akshat3128%2Ffastapi-ecommerce/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260595746,"owners_count":23033789,"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","crud-application","fastapi","fastapi-security","github-config","jwt","postgresql","postman","pydantic-v2","python3","smtpmailer","sql-alchemy","swagger-ui"],"created_at":"2025-06-18T17:06:28.711Z","updated_at":"2025-10-05T15:41:07.045Z","avatar_url":"https://github.com/Akshat3128.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏍️ FastAPI E-Commerce Backend\n\nA secure and scalable e-commerce backend built with **FastAPI** and **PostgreSQL**, featuring role-based authentication, product management, cart system, orders, and secure password reset.\n\n---\n\n## 🚀 Features\n\n### ✅ Authentication\n\n* Signup / Signin (JWT)\n* Role-based access: `admin` and `user`\n* Profile endpoint\n* Password hashing with bcrypt\n* Forgot/Reset Password via email (Gmail SMTP)\n\n### 🏍️ Product Management\n\n* Admin-only CRUD operations\n* Public product listing with pagination, filters, and search\n* Product detail view\n\n### 🛍️ Cart Management (User Only)\n\n* Add/update/remove items from cart\n* View current cart with nested product info\n\n### 💳 Checkout \u0026 Orders (User Only)\n\n* Checkout from cart (dummy payment)\n* Create order with total + items\n* View order history \u0026 details\n\n### 🔐 Security \u0026 Validation\n\n* JWT for protected routes\n* Role-restricted access (user/admin)\n* Strong validators for email, password, product data\n* SQLAlchemy models with Alembic migrations\n\n---\n\n## 🧱 Tech Stack\n\n* Python 3.11\n* FastAPI\n* PostgreSQL\n* SQLAlchemy ORM\n* Alembic (migrations)\n* Pydantic (data validation)\n* Gmail SMTP (emailing reset tokens)\n\n---\n\n## 📁 Project Structure\n\n```\napp/\n├── auth/               # Signup, signin, JWT, password reset\n│   ├── models.py\n│   ├── schemas.py\n│   ├── routes.py\n│   └── utils.py\n│\n├── products/           # Product CRUD \u0026 listing\n│   ├── models.py\n│   ├── schemas.py\n│   ├── routes.py\n│   └── public_routes.py\n│\n├── cart/               # Cart management\n│   ├── models.py\n│   ├── schemas.py\n│   └── routes.py\n│\n├── orders/             # Checkout \u0026 order viewing\n│   ├── models.py\n│   ├── schemas.py\n│   ├── checkout_routes.py\n│   └── order_routes.py\n│\n├── core/               # DB setup \u0026 config\n│   ├── config.py\n│   └── database.py\n│\n├── seed/               # Product seed script (manual)\n│   └── seed_products.py\n│\n├── postman/            # Postman collection\n│   └── fastapi-ecommerce.postman_collection.json\n│\n├── main.py             # App entry point\n```\n\n---\n\n## ⚙️ Setup Instructions\n\n### 1. Clone and Install\n\n```bash\ngit clone https://github.com/Akshat3128/fastapi-ecommerce\ncd fastapi-ecommerce\npython -m venv venv\nsource venv/bin/activate  # or venv\\Scripts\\activate on Windows\npip install -r requirements.txt\n```\n\n### 2. Setup `.env`\n\n```env\nDATABASE_URL=postgresql://postgres:yourpass@localhost:5432/ecommerce_db\nSECRET_KEY=your_jwt_secret\nALGORITHM=HS256\n\nEMAIL_HOST=smtp.gmail.com\nEMAIL_PORT=587\nEMAIL_USER=yourgmail@gmail.com\nEMAIL_PASSWORD=your_app_password\n```\n\n### 3. Run Alembic Migrations\n\n```bash\nalembic upgrade head\n```\n\n### 4. Run the Server\n\n```bash\nuvicorn app.main:app --reload\n```\n\nVisit: [http://localhost:8000/docs](http://localhost:8000/docs) — Swagger UI auto-generates full API documentation (OpenAPI compliant).\n\n---\n\n## 📧 Reset Password Flow\n\n1. `POST /auth/forgot-password` with email → sends reset token\n2. `POST /auth/reset-password` with token + new password\n\n---\n\n## 📅 Postman Collection\n\n\nImport this file into Postman to test:\n\n* Signup / Login\n* Cart operations\n* Checkout \u0026 Orders\n* Password reset flow\n\n---\n\n## 🔐 Admin vs User Permissions\n\n| Action               | User | Admin |\n| -------------------- | ---- | ----- |\n| Sign Up / Login      | ✅    | ✅     |\n| Access JWT Routes    | ✅    | ✅     |\n| View Products        | ✅    | ✅     |\n| Create/Edit Products | ❌    | ✅     |\n| Use Cart             | ✅    | ❌     |\n| Checkout + Orders    | ✅    | ❌     |\n\n---\n\n## 📍 Seeding Products\n\nUse the manual script:\n\n```bash\npython seed/seed_products.py\n```\n\nThis script inserts test products into the database for local testing/dev. Modify it to fit your product data.\n\n---\n\n## 📌 Notes\n\n* Uses Gmail App Passwords — safe for dev.\n* Email send uses `smtplib`, can switch to SendGrid/SMTP provider.\n* Swagger/OpenAPI auto-generated at `/docs`\n* Postman collection included\n* Deployment-ready structure\n\n---\n\n## 💖 Author\n\nBuilt by Akshat Saxena 😘\n\n---\n\n## 📜 License\n\nMIT License\n\n```\nCopyright (c) 2025 AKSHAT SAXENA\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshat3128%2Ffastapi-ecommerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakshat3128%2Ffastapi-ecommerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshat3128%2Ffastapi-ecommerce/lists"}