{"id":24534430,"url":"https://github.com/nazneenprojects/e-commerce_platform_app","last_synced_at":"2026-02-25T23:34:04.215Z","repository":{"id":272447082,"uuid":"913171446","full_name":"nazneenprojects/e-commerce_platform_app","owner":"nazneenprojects","description":"e-commerce_platform_app using Tech Stack - Python3, FastAPI, PostgresSQL Docker, Unit testing, Render","archived":false,"fork":false,"pushed_at":"2025-01-20T04:26:18.000Z","size":218,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T17:16:21.499Z","etag":null,"topics":["backend-api","coding-challenge","fastapi","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nazneenprojects.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-01-07T07:06:17.000Z","updated_at":"2025-01-20T04:26:20.000Z","dependencies_parsed_at":"2025-01-14T14:23:41.329Z","dependency_job_id":"a69c3b59-1fea-449a-9971-efa84836c448","html_url":"https://github.com/nazneenprojects/e-commerce_platform_app","commit_stats":null,"previous_names":["nazneenprojects/e-commerce_platform_app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nazneenprojects/e-commerce_platform_app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazneenprojects%2Fe-commerce_platform_app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazneenprojects%2Fe-commerce_platform_app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazneenprojects%2Fe-commerce_platform_app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazneenprojects%2Fe-commerce_platform_app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nazneenprojects","download_url":"https://codeload.github.com/nazneenprojects/e-commerce_platform_app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nazneenprojects%2Fe-commerce_platform_app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29844878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"ssl_error","status_checked_at":"2026-02-25T22:37:25.960Z","response_time":61,"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":["backend-api","coding-challenge","fastapi","python3"],"created_at":"2025-01-22T11:17:09.636Z","updated_at":"2026-02-25T23:34:04.198Z","avatar_url":"https://github.com/nazneenprojects.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# E-Commerce Platform API\n\nA production-grade RESTful API for an e-commerce platform built with FastAPI, PostgreSQL, and Docker.\nLive Render hosting URL - https://e-commerce-platform-app-latest.onrender.com/docs\n![api.png](api.png)\n\n## Features\n\n- Product management (create, list)\n- Order processing with stock validation\n- Comprehensive error handling\n- Cloud based Postgres Database hosting over Render (https://render.com/)\n- Database migrations with Alembic\n- Structured logging\n- Unit and integration tests\n- Docker support\n- Live Render Hosting (available live for limited period)\n- API Specification and Schema (localhost url) :\nSwagger http://127.0.0.1:8000/docs#/\nRedoc http://127.0.0.1:8000/redoc\n\n## Tech Stack\n\n- Python 3.13+\n- FastAPI\n- PostgreSQL\n- SQLAlchemy\n- Alembic\n- Poetry\n- Docker\n- pytest\n\n## Approach :\n### E-commerce Platform API\n\nThis FastAPI-based e-commerce platform demonstrates production-grade practices through a thoughtfully designed order \nmanagement system. The application uses a junction table (OrderItem) approach for handling order-product relationships, \nenabling efficient tracking of pricing, maintaining order integrity, and supporting complex queries. \nThe data model leverages SQLAlchemy with PostgreSQL, implementing proper foreign key constraints and relationships \nbetween Products, Orders, and OrderItems tables.\n\nThe application architecture follows best practices with clear separation of concerns: models for database schema, \nPydantic schemas for validation, services for business logic, and controllers for API endpoints. \nError handling is implemented through custom exception classes and proper HTTP status codes. \nThe codebase is production-ready with features like input validation, stock management, transactional integrity, and \ncomprehensive logging. The application is containerized using Docker for consistent deployment, with separate \nconfigurations for development and production environments.\n\nThe system includes unit tests for business logic and integration tests for API endpoints\nusing pytest. Database migrations are handled through Alembic, ensuring smooth schema updates. The application is \nconfigured for deployment on Render with PostgreSQL database integration, demonstrating real-world deployment practices. \nDocumentation is automatically generated through FastAPI's built-in Swagger UI, making API exploration \nand testing straightforward.\n\n\n### Database Design with Junction Table:\nMain tables: Products, Orders, OrderItems (junction table)\n\nBenefits of junction table (OrderItems) approach:\n- Maintains historical pricing with price_at_time\n- Enables many-to-many relationship between Orders and Products\n- Stores quantity and subtotal per item\n- Preserves order data even if products change/delete\n- Easier reporting and analytics\n\n### Modular structure:\nModels (SQLAlchemy)\nSchemas (Pydantic)\nServices (Business logic)\nRoutes (API endpoints)\n\n## Local Development Setup\n\n1. Clone the repository:\n```bash\ngit clone \ncd e-commerce_platform_app\n```\n\n2. Install dependencies with Poetry:\n```bash\npoetry install\n```\n\n3. Set up environment variables:\nCreate a `.env` file with:\n```\nDATABASE_URL=postgresql://user:password@localhost:5432/ecommerce_db\n```\n\n4. Run database migrations:\n```bash\npoetry run alembic upgrade head\n```\n\n5. Start the development server:\n```bash\npoetry run uvicorn app.main:app --reload\n```\n\n## Running Tests\n\nRun unit tests:\n```bash\npoetry run pytest tests/unit/\n```\n\nRun integration tests:\n```bash\npoetry run pytest tests/integration/\n```\n\n## Docker Deployment\n\n1. Build the Docker image:\n```bash\ndocker build -t e-commerce-platform-app .\n```\n\n2. Run the container:\n docker run -d -p 8080:8000 -e DATABASE_URL=postgresql://********************-a.frankfurt-postgres.render.com/ecomdb_0l2p \n --name e-commerce-app-container e-commerce-platform-app:latest\n\n\n## API Documentation\n\nOnce running, visit:\n- Swagger UI: `http://localhost:8000/docs`\n- ReDoc: `http://localhost:8000/redoc`\n\n## API Endpoints\n\n### Products\n- `GET /product/all_products` - List all products\n- `POST /product/create_product` - Create a new product\n\n### Orders\n- `POST /order/create_order` - Create a new order\n\n## Error Handling\n\nThe API includes comprehensive error handling for:\n- Insufficient stock\n- Product not found\n- Invalid order creation\n- Database errors\n\n## Logging\n\nStructured logging is implemented using `structlog`. Logs include:\n- Error information\n- Business operations\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit changes\n4. Push to the branch\n5. Create a Pull Request\n\n## Render Deployment\nThis backend service is available via Render platform where docker container is running from docker registry\nRender is a cloud platform designed for deploying and hosting applications and services. It simplifies the \nprocess of building, deploying, and managing apps by abstracting much of the infrastructure management, \nallowing developers to focus on their application code.\n\nthis backend service is hosted on render -   https://e-commerce-platform-app-latest.onrender.com/docs\n\n## Future Scope\n- Authentication using OAuth\n- CI/CD deployment\n- scaling using K8s\n- performance monitoring using Grafana or Datadog or Dynatrace\n- Rate limiting\n- UUID support\n- https security\n- api versioning\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazneenprojects%2Fe-commerce_platform_app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnazneenprojects%2Fe-commerce_platform_app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnazneenprojects%2Fe-commerce_platform_app/lists"}