How s-madii/ecommerce-api works
Commerce API is a FastAPI storefront backend. The main workflow runs from account authentication and catalog browsing through a persistent cart, locked-stock checkout, Stripe payment confirmation, and asynchronous confirmation email. The graph preserves documented caching, role controls, category management, and payment integration. Some router-to-service links are supported only by the README or module references; these are marked unverified where the exact call is not shown.
Main entry points: session.py Async DB sessions · payments.py Payment webhook · auth.py Authentication routes · security.py JWT and access control
Components 25
API and identity
- API routes
app/routers - Authentication routes
app/routers/auth.py - JWT and access control
app/core/security.py - User accounts
app/models/user.py - Request and response schemas
app/schemas
Storefront domain
- Catalog routes
app/routers/products.py - Catalog service
app/services/product.py - Category management
app/routers/categories.py - Cart routes
app/routers/cart.py - Cart service
app/services/cart.py - Product inventory
app/models/product.py - Cart state
app/models/cart.py - Checkout routes
app/routers/orders.py - Checkout and orders
app/services/order.py
Persistence and cache
- PostgreSQL
- Redis cache and broker
- Async DB sessions
app/db/session.py
Payments and tasks
- Orders and payments
app/models/order.py - Payment webhook
app/routers/payments.py - Stripe payment service
app/services/payment.py - Email task worker
app/worker.py
Shared foundations
- Application settings
app/core/config.py - Domain errors
app/core/exceptions.py
Other components
- Storefront user
- Stripe
Connections 34
- Storefront user → Authentication routes: signs up
README.md - Authentication routes → User accounts: queries and creates
app/routers/auth.py - Authentication routes → JWT and access control: creates token
app/routers/auth.py - Storefront user → Catalog routes: browses
README.md - Catalog routes → Catalog service: delegates
app/routers/products.py - Catalog service → Redis cache and broker: reads and caches
app/services/product.py - Catalog service → Product inventory: queries products
app/services/product.py - Storefront user → Category management: views categories
README.md - Storefront user → Cart routes: manages cart
README.md - Cart routes → Cart service: delegates
app/routers/cart.py - Cart service → Cart state: reads and updates
app/services/cart.py - Cart service → Product inventory: checks stock
app/services/cart.py - Storefront user → Checkout routes: checks out
README.md - Checkout routes → Checkout and orders: delegates
- Checkout and orders → Product inventory: locks stock
README.md - Checkout and orders → Orders and payments: creates order
README.md - Checkout and orders → Stripe payment service: creates intent
README.md - Stripe payment service → Stripe: creates intent
README.md - Stripe → Payment webhook: sends webhook
README.md - Payment webhook → Stripe payment service: verifies signature
app/routers/payments.py - Payment webhook → Orders and payments: confirms payment
app/routers/payments.py - Payment webhook → Email task worker: dispatches email
app/routers/payments.py - Email task worker → Redis cache and broker: uses broker
app/worker.py - API routes → Request and response schemas: validates and serializes
app/routers/auth.py - Authentication routes → Async DB sessions: uses DB session
app/routers/auth.py - Catalog routes → Async DB sessions: uses DB session
app/routers/products.py - Cart routes → Async DB sessions: uses DB session
app/routers/cart.py - Payment webhook → Async DB sessions: uses DB session
app/routers/payments.py - Async DB sessions → PostgreSQL: opens sessions
app/db/session.py - JWT and access control → Async DB sessions: loads user
app/core/security.py - JWT and access control → User accounts: queries account
app/core/security.py - JWT and access control → Application settings: reads secrets
app/core/security.py - Catalog service → Domain errors: raises domain errors
app/services/product.py - Cart service → Domain errors: raises domain errors
app/services/cart.py