How mdik0n/fastapi-ecommerce works
This is a FastAPI e-commerce API. Its visible customer workflow is to browse and search the catalog, inspect product reviews, authenticate, and manage a cart; sellers manage products, while admins manage categories. The sampled routers directly query and mutate the async database through SQLAlchemy models. The users router and several model files are present in the tree but were not sampled, so their internal behavior is not inferred here.
Main entry points: database.py SQL database · db_depends.py DB sessions · main.py FastAPI app · auth.py Authentication
Components 15
API entry
- FastAPI app
app/main.py - User routes
app/routers/users.py - Authentication
app/auth.py
Catalog management
- Category routes
app/routers/categories.py - Product routes
app/routers/products.py
Customer commerce
- Cart routes
app/routers/cart.py - Review routes
app/routers/reviews.py
Persistence
- Category model
app/models/categories.py - Product model
app/models/products.py - Cart item model
app/models/cart_items.py - Review model
app/models/reviews.py - User model
app/models/users.py - DB sessions
app/db_depends.py - SQL database
app/database.py
Other components
- API client
Connections 27
- API client → FastAPI app: sends requests
- FastAPI app → User routes: dispatches
- FastAPI app → Category routes: dispatches
- FastAPI app → Product routes: dispatches
- FastAPI app → Cart routes: dispatches
- FastAPI app → Review routes: dispatches
- Category routes → Authentication: requires user
- Product routes → Authentication: requires seller
- Cart routes → Authentication: requires user
- Review routes → Authentication: requires user
- Authentication → DB sessions: gets session
- Category routes → DB sessions: gets session
- Product routes → DB sessions: gets session
- Cart routes → DB sessions: gets session
- Review routes → DB sessions: gets session
- DB sessions → SQL database: opens session
- Authentication → SQL database: looks up user
- Category routes → SQL database: reads and writes
- Product routes → SQL database: reads and writes
- Cart routes → SQL database: reads and writes
- Review routes → SQL database: reads and writes
- User routes → DB sessions: gets session
- Category model → SQL database: maps category data
- Product model → SQL database: maps product data
- Cart item model → SQL database: maps cart data
- Review model → SQL database: maps review data
- User model → SQL database: maps user data