How gopal092003/inventory-order-management works
Purpose and Runtime Entry Points
This is a full-stack inventory and order-management system: product and customer CRUD, multi-line-item orders, stock control, and operational dashboard metrics. The React/Vite SPA starts at frontend/src/main.jsx, composes routes in frontend/src/routes/AppRoutes.jsx, and is hosted in frontend/src/App.jsx. The FastAPI application is created in backend/app/main.py; Uvicorn serves it and exposes OpenAPI/Swagger.
Frontend Application Shell and Navigation
The browser client is organized around a dashboard layout, shared navigation, and feature pages rather than a server-rendered web app. frontend/src/layouts/DashboardLayout.jsx establishes the primary page frame; frontend/src/components/layout/Sidebar.jsx and frontend/src/components/layout/Navbar.jsx provide navigation. Routed feature screens represent the main user workflows: frontend/src/features/dashboard/Dashboard.jsx, frontend/src/features/products/Products.jsx, and frontend/src/features/orders/Orders.jsx.
Frontend API Boundary
Feature-local API modules call a centralized HTTP client, isolating backend URL/configuration and request behavior from UI components. frontend/src/api/client.js is the client boundary, with domain callers in frontend/src/features/products/api.js, frontend/src/features/customers/api.js, and frontend/src/features/orders/api.js. The frontend obtains its API base URL through VITE_API_BASE_URL; it does not directly access PostgreSQL.
FastAPI API and Layering
The backend follows route → service → persistence boundaries. Versioned REST endpoints are partitioned by business resource in backend/app/api/v1/products.py, backend/app/api/v1/customers.py, and backend/app/api/v1/orders.py; dashboard aggregation is exposed through backend/app/api/v1/dashboard.py. Application wiring, CORS, and exception integration belong in backend/app/main.py, while configuration and database-session setup are centralized in backend/app/core/config.py and backend/app/core/database.py.
Domain Model and Validation
SQLAlchemy entities persist the core relational model: customers, products, orders, and order line items in backend/app/models/customer.py, backend/app/models/product.py, and backend/app/models/order_item.py. Pydantic request/response contracts separate API payloads from ORM entities in backend/app/schemas/product.py, backend/app/schemas/customer.py, and backend/app/schemas/order.py. Orders form the principal transactional boundary: submitted line items must be inventory-valid and result in stock deduction.
Inventory and Analytics Services
Business logic that crosses resource boundaries is kept out of route handlers. backend/app/services/inventory_service.py governs inventory checks and updates used during ordering. backend/app/services/dashboard_service.py computes inventory, product, customer, and order summaries, including low-stock and recent-order data. Its output is consumed by the dashboard endpoint and rendered via frontend/src/features/dashboard/Dashboard.jsx.
Persistence, Delivery, and External Infrastructure
PostgreSQL is the system of record, configured through DATABASE_URL. Alembic manages schema evolution from backend/alembic/env.py and backend/alembic/versions/initial_migration.py; backend/app/db/seed.py supports initial data population. Local container orchestration is defined by docker-compose.yml, with independently containerized backend and frontend in backend/Dockerfile and frontend/Dockerfile. Target deployment boundaries are Vercel for the SPA, Render for FastAPI, and Render PostgreSQL; CI is executed by .github/workflows/ci.yml.
Main entry points: AppRoutes.jsx Application routes · main.py FastAPI application · orders.py Product, customer, order APIs · docker-compose.yml Container orchestration
Components 21
React SPA
- SPA entry
frontend/src/main.jsx - Application routes
frontend/src/routes/AppRoutes.jsx - App host
frontend/src/App.jsx - Dashboard layout · Frames routed screens with shared navigation.
frontend/src/layouts/DashboardLayout.jsx - Sidebar and navbar
frontend/src/components/layout/Sidebar.jsx - Product and order screens
frontend/src/features/products/Products.jsx - Dashboard screen
frontend/src/features/dashboard/Dashboard.jsx - HTTP client · Uses VITE_API_BASE_URL for backend requests.
frontend/src/api/client.js - Domain API callers
frontend/src/features/orders/api.js
FastAPI backend
- FastAPI application · Wires CORS, exceptions, and versioned API routes.
backend/app/main.py - Product, customer, order APIs
backend/app/api/v1/orders.py - Dashboard API
backend/app/api/v1/dashboard.py - Request and response schemas
backend/app/schemas/order.py - Inventory service · Validates submitted line items and deducts stock.
backend/app/services/inventory_service.py - Dashboard service · Builds summaries, low-stock, and recent-order data.
backend/app/services/dashboard_service.py
Data and migrations
- Database session · Configured through DATABASE_URL.
backend/app/core/database.py - Customers, products, orders · Orders contain inventory-affecting line items.
backend/app/models/order_item.py - PostgreSQL
- Alembic migrations
backend/alembic/env.py
Delivery
- Container orchestration · Runs independently containerized frontend and backend locally.
docker-compose.yml - CI workflow
.github/workflows/ci.yml
Connections 23
- SPA entry → App host: mounts
- App host → Application routes: hosts
- Application routes → Dashboard layout: uses
- Dashboard layout → Sidebar and navbar: contains
- Application routes → Product and order screens: renders
- Application routes → Dashboard screen: renders
- Product and order screens → Domain API callers: requests
- Domain API callers → HTTP client: uses
- Dashboard screen → HTTP client: requests metrics
- HTTP client → FastAPI application: REST over HTTP
- FastAPI application → Product, customer, order APIs: registers
- FastAPI application → Dashboard API: registers
- Product, customer, order APIs → Request and response schemas: validates payloads
- Product, customer, order APIs → Inventory service: submits orders
- Inventory service → Database session: uses
- Dashboard API → Dashboard service: queries summaries
- Dashboard service → Database session: uses
- Database session → Customers, products, orders: persists
- Customers, products, orders → PostgreSQL: stored in
- Alembic migrations → PostgreSQL: evolves schema
- Container orchestration → SPA entry: serves frontend
- Container orchestration → FastAPI application: runs backend
- CI workflow → Container orchestration: validates delivery