A professional, secure, and clean FastAPI-based Ecommerce API designed for a Single Vendor store.
- Personalized Admin Dashboard: Separate section for the Shop Owner.
- Secure Admin Registration: Register using a secret code to prevent unauthorized access.
- Product Management: Full CRUD (Create, Read, Update, Delete) functionality for products.
- Customer Shopping: Customers can browse products, search by name, and place orders.
- Order Tracking: Automated total price calculation and real-time stock management.
- Password Security: Modern Bcrypt hashing for all users.
- Framework: FastAPI
- Database: SQLite (SQLAlchemy ORM)
- Security: Bcrypt Hashing
- Validation: Pydantic v2
app/
├── main.py # Main Entry Point
├── models.py # Database Models
├── schemas.py # Pydantic Schemas
├── crud.py # Database Operations
├── database.py # DB Connection
├── utils.py # Security Helpers (Hasing)
├── config.py # Settings & Secret Keys
└── routers/
├── admin.py # Admin/Vendor Endpoints
├── products.py # Public Product Catalog
├── user.py # Customer Accounts
└── orders.py # Shopping & Orders
To register as an admin, use the following details in the /admin/register endpoint:
- Secret Code:
ALTAF_ADMIN_786(Configurable inapp/config.py)
POST /users/- Register as a new customer.POST /users/login- Login to your account.
GET /products/- View all products.GET /products/?search=name- Search products by name.
POST /admin/register- Create an admin account (requires Secret Code).POST /admin/login- Admin login.POST /admin/products- Add new stock.PUT /admin/products/{id}- Update product details.DELETE /admin/products/{id}- Remove a product.GET /admin/orders- View all customer orders.
POST /orders/- Place a new order (Autocalculates total & updates stock).GET /orders/{id}- View specific order details.
-
Install Dependencies:
pip install fastapi uvicorn sqlalchemy bcrypt
-
Run Server:
uvicorn app.main:app --reload
-
Explore Documentation: Open
http://127.0.0.1:8000/docsin your browser.
Built by Altaf with ❤️ using FastAPI.