How shishirbaidya/cse311 works
1. Overall shape
- This is a two-tier application: a Python backend API and a React/Vite frontend.
- The frontend is organized around shopping workflows, user accounts, and an admin console.
- The backend is organized by resource domain using router modules and a shared database/config/security layer.
2. Backend entrypoint and core layers
- backend/app/app.py is the main application entrypoint.
- config.py centralizes runtime configuration, and database.py is the shared database connection/access layer.
- services/ contains business logic that sits between routes and persistence, with auth_service.py being the clearest example.
- utils/ contains cross-cutting helpers such as security and upload handling.
3. Backend API boundaries
- The backend is split into domain routers: auth_router, user_router, orders_router, drinks_router, grocery_router, restaurant_router, admin_router, root_service_router, and upload.py.
- This suggests the API is segmented by business capability rather than by generic CRUD only.
- The presence of separate store-type routers implies the product catalog is partitioned into multiple shop categories.
4. Backend data and persistence
- backend/app/SQL/sql1.sql indicates a relational schema is part of the repo, likely used to initialize or document the database.
- The application likely reads/writes users, products, carts/orders, and admin-managed entities through this schema.
- database.py is the boundary between the API layer and the database, so it is a key node in the architecture diagram.
5. Authentication and security flow
- Authentication is handled in the backend by auth_router plus services/auth_service.py.
- utils/security.py is likely responsible for password hashing, token creation/validation, or other auth-related primitives.
- On the frontend, contexts/AuthContext.jsx holds the current auth state, and components/ProtectedRoute.jsx guards private routes.
- The auth boundary separates public browsing from logged-in profile, checkout, and admin features.
6. File upload and static asset handling
- backend/app/utils/upload.py, routers/upload.py, and backend/app/static/uploads/ form a dedicated upload pipeline.
- This is important for item images or avatar/profile media.
- The backend appears to store uploaded files locally and expose them through static serving rather than via an external object store.
7. Frontend app structure
- The frontend is a React single-page app built with Vite (vite.config.js, main.jsx, App.css).
- Navigation and page composition are split across pages/, components/, profile/, admin/, and category-specific folders like grocery/, juices/, and restaurants/.
- Layout.jsx, ShopLayout.jsx, Home.jsx, Shops.jsx, About.jsx, Checkout.jsx, and ErrorPage.jsx define the top-level user experience flow.
8. Frontend state and client-side orchestration
- contexts/CartContext.jsx manages shopping cart state across the app.
- contexts/AuthContext.jsx manages login/session state and likely drives conditional rendering of protected areas.
- This means the frontend is not just a view layer; it also owns important session and cart state before sending data to the backend.
9. Shop/category features
- The storefront is split into multiple domain views: DrinkHome.jsx, GroceryHome.jsx, and RestaurantHome.jsx.
- Reusable card components under components/, grocery/components/, juices/components/, and restaurants/components/ are used to render product listings.
- This suggests a catalog browsing flow where the frontend requests category-specific data from the corresponding backend routers.
10. Profile and order lifecycle
- profile/CurrentOrder.jsx, PreviousOrders.jsx, OrderCard.jsx, and related components indicate a user account area focused on order tracking/history.
- This aligns with the backend orders_router and user_router, which likely serve current order state, past orders, and profile details.
- The architecture separates end-user order visibility from administrative order management.
11. Admin subsystem
- admin/AdminHome.jsx and components like AddItemForm.jsx, OrdersManager.jsx, and UsersTable.jsx form a distinct admin dashboard.
- The admin UI maps directly to backend management routes, especially admin_router, plus likely orders_router and user_router.
- AddItemForm implies admins can create catalog entries, probably including uploads for item images.
12. Client-server data flow
- Frontend API access is centralized in src/services/api.js and src/services/auth.jsx.
- Typical flow is: user action in a page/component → local context state updates → API call via the services layer → backend router/service/database → updated UI state.
- This keeps network concerns out of the page components and makes the frontend easier to diagram as presentation, state, and API layers.
13. Notable repository boundary
- The frontend/app/public/juice_gsap* assets look like bundled static content from a design or animation source and are not part of the core application logic.
- They matter only as static frontend assets; they do not change the backend/frontend architectural split.
Main entry points: app.py App entry · main.jsx SPA shell · database.py Database · api.js API client
Components 23
Backend
Python API, routers, services, persistence, and upload/static handling.
- App entry · Main backend application bootstrap and router wiring.
backend/app/app.py - Config · Central runtime settings and environment-driven configuration.
backend/app/config.py - Database · Shared database access boundary used by routers and services.
backend/app/database.py - Auth API · Login, registration, and authentication endpoints.
backend/app/routers/auth_router.py - User API · User profile and account endpoints.
backend/app/routers/user_router.py - Orders API · Current and historical order endpoints.
backend/app/routers/orders_router.py - Catalog APIs · Category-specific product and browsing endpoints for drinks, grocery, and restaurants.
- Admin API · Administrative management endpoints for users, orders, and catalog data.
backend/app/routers/admin_router.py - Root API · Shared or top-level service endpoints.
backend/app/routers/root_service_router.py - Upload API · File upload endpoints for images and other media.
backend/app/routers/upload.py - Auth service · Authentication and account logic between auth routes and persistence.
backend/app/services/auth_service.py - Security utils · Cross-cutting password, token, or security primitives.
backend/app/utils/security.py - Upload utils · Helpers for storing and handling uploaded files locally.
backend/app/utils/upload.py - SQL schema · Database schema and initialization script.
backend/app/SQL/sql1.sql - Static uploads · Local storage for uploaded media served by the backend.
backend/app/static/uploads
Frontend
React/Vite SPA with shared state, routes, and domain screens.
- SPA shell · Frontend application entry and overall shell.
frontend/app/src/main.jsx - Layouts · Top-level page composition and shop layout structure.
frontend/app/src/Layout.jsx - App state · Global auth and cart state shared across the frontend.
frontend/app/src/contexts/AuthContext.jsx - API client · Centralized client-side HTTP access and auth helpers.
frontend/app/src/services/api.js - Public pages · Home, shop discovery, about, checkout, and error screens.
frontend/app/src/pages/Home.jsx - Storefronts · Category storefronts for groceries, drinks, and restaurants.
frontend/app/src/grocery/GroceryHome.jsx - Profile area · User profile, current order, and past order screens.
frontend/app/src/profile/Profile.jsx - Admin console · Admin dashboard and catalog/order/user management screens.
frontend/app/src/admin/AdminHome.jsx
Connections 35
- App entry → Config: reads · Loads runtime settings during startup.
- App entry → Database: connects · Initializes shared database access.
- App entry → Auth API: registers · Mounts auth endpoints into the app.
- App entry → User API: registers · Mounts user endpoints into the app.
- App entry → Orders API: registers · Mounts order endpoints into the app.
- App entry → Catalog APIs: registers · Mounts category-specific catalog routers.
- App entry → Admin API: registers · Mounts admin endpoints into the app.
- App entry → Root API: registers · Mounts shared or root service endpoints.
- App entry → Upload API: registers · Mounts upload endpoints into the app.
- Auth API → Auth service: uses · Delegates authentication logic to service layer.
- Auth service → Security utils: uses · Relies on auth/security primitives.
- Auth service → Database: persists · Reads and writes identity data through the database layer.
- User API → Database: queries · Accesses user records through shared persistence.
- Orders API → Database: queries · Accesses order state through shared persistence.
- Catalog APIs → Database: queries · Serves category catalog data from persistence.
- Admin API → Database: mutates · Performs administrative writes against persisted data.
- Upload API → Upload utils: uses · Delegates file handling to upload helpers.
- Upload utils → Static uploads: stores · Writes uploaded files to local static storage.
- SQL schema → Database: defines · Provides the relational structure used by the app.
- SPA shell → Layouts: composes · Builds the app around route/layout structure.
- SPA shell → App state: wraps · Provides global context for auth and cart state.
- SPA shell → Public pages: routes to · Serves public landing and checkout-related pages.
- SPA shell → Storefronts: routes to · Serves category storefront experiences.
- SPA shell → Profile area: routes to · Serves authenticated account and order pages.
- SPA shell → Admin console: routes to · Serves admin dashboard views.
- App state → API client: calls · Uses the API layer for server communication.
- Public pages → API client: fetches · Loads data and submits actions through the client API.
- Storefronts → API client: fetches · Requests category data through the client API.
- Profile area → API client: fetches · Loads profile and order data through the client API.
- Admin console → API client: mutates · Sends admin actions through the client API.
- App state → Auth API: authenticates · Login/session state is validated against backend auth endpoints.
- Public pages → Catalog APIs: browses · Public storefront views consume category APIs.
- Profile area → Orders API: tracks · Profile and order views depend on order endpoints.
- Admin console → Admin API: manages · Admin UI maps to backend management endpoints.
- Admin console → Upload API: uploads · Admin item creation can attach media through upload endpoints.