diff --git a/AGENTS.md b/AGENTS.md index 31e53de..adeac72 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,10 +4,10 @@ You are **Anti-Gravity**, an autonomous AI development agent designed to execute ## Environment & Managed Workspace - **Agent Location**: `d:/Tradhox_workspace/Agents` -- **Supplier Central Frontend**: `d:/Tradhox_workspace/supplier_central_frontend` (React 19, TypeScript, Vite, TailwindCSS v4, Bulma CSS) -> AWS S3 / CloudFront -- **Customer Living Heritage Marketplace**: `d:/Tradhox_workspace/customerwebsite` (React 19, Vite, TailwindCSS v4) -> AWS S3 / CloudFront -- **CSA Site Frontend**: `d:/Tradhox_workspace/crmfrontend` (React 19, TypeScript, Vite) -> AWS S3 (`csawebsite` / `betacsa`) / CloudFront (`csa.tradhox.com` / `betacsa.tradhox.com`) -- **Backend Core**: `d:/Tradhox_workspace/seller_central_backend` (Python 3.14, Django 6.1, DRF, Gunicorn, PostgreSQL/SQLite) -> AWS EC2 (`seller-central-backend.service`) +- **Supplier Central Frontend (FOR SELLERS)**: `d:/Tradhox_workspace/supplier_central_frontend` (React 19, TypeScript, Vite, TailwindCSS v4, Bulma CSS) -> AWS S3 / CloudFront (Seller portal for onboarding, inventory, payouts & order fulfillment) +- **Customer Living Heritage Marketplace (FOR CONSUMERS)**: `d:/Tradhox_workspace/customerwebsite` (React 19, Vite, TailwindCSS v4) -> AWS S3 / CloudFront (Consumer shopping portal for browsing catalog, cart, checkout & orders) +- **Customer Website Backend Service (FOR CONSUMERS)**: `d:/Tradhox_workspace/customerwebsitebackend` (Python 3.14, Django 6.1 DRF, SimpleJWT, Gunicorn, PostgreSQL) -> Daemon (`customer-website-backend.service`, Port 8082, CORS-enabled Consumer API) +- **Backend Core (FOR SELLERS)**: `d:/Tradhox_workspace/seller_central_backend` (Python 3.14, Django 6.1, DRF, Gunicorn, PostgreSQL/SQLite) -> AWS EC2 (`seller-central-backend.service`, Seller API Base `https://betapartner-api.tradhox.com/api`) - **CSA Backend Service**: `d:/Tradhox_workspace/crmbackend` (Python 3.14, Django 6.1 DRF) -> AWS EC2 (`apicsa.tradhox.com` / `betaapicsa.tradhox.com`) - **Logistics & Shipping Service**: `d:/Tradhox_workspace/shippingservice` (Django microservice for EKart & SFX integrations, Webhooks, AWB Label rendering) -> Daemon (`shippingservice-beta.service`) - **Search Engine Microservice**: `d:/Tradhox_workspace/searchengine` (Django 6.1, DRF, Typesense 27.1 integration for low-latency search-as-you-type and catalog indexing) -> Daemon (`searchengine.service`, Port 8087) @@ -21,7 +21,8 @@ You are **Anti-Gravity**, an autonomous AI development agent designed to execute - **No Hardcoded Dummy Data**: Never hardcode dummy/sample products or mock users in frontend production states. Catalog, cart, orders, wishlist, addresses, and wallets must start in a clean initial/guest state. ### 3. Critical API & Infrastructure Standards -- **API Base URL**: Always use `https://betapartner-api.tradhox.com/api` for **both Beta and Local Testing** environments. +- **Supplier API Base URL**: Always use `https://betapartner-api.tradhox.com/api` for Supplier Central (both Beta and Local Testing). +- **Customer API Base URL**: Always use `https://beta-api.tradhox.com/api` for both local running `customerwebsite` and `beta.tradhox.com` site. - **Database Cluster**: Host `16.113.106.152:5432` | User `vignesh` | Pass `vignesh_secret_pass_2026` (Never alter DB password on server). - **Databases**: Beta (`sellerprofile_beta`, `productprofile_beta`, `customerprofile_beta`) / Prod (`sellerprofile_prod`, `productprofile_prod`, `customerprofile_prod`). - **Media S3 Bucket**: `betasupplierdocumentstorage` (Region: `ap-south-2`). @@ -49,8 +50,10 @@ graph TD S3_Customer --> CustomerApp[React 19 + Vite] S3_CSA --> CsaApp[React 19 + TS + Vite] SupplierApp -- REST / JWT --> APIEndpoint[https://betapartner-api.tradhox.com/api\n(Beta & Local Testing)] + CustomerApp -- REST / JWT --> CustBackend[customerwebsitebackend\nDjango 6.1 DRF Port 8082] CustomerApp -- REST / State --> APIEndpoint CsaApp -- REST / JWT --> CsaAPIEndpoint[https://betaapicsa.tradhox.com/api\ncrmbackend] + CustBackend --> DB[(PostgreSQL Cluster\n16.113.106.152:5432\ncustomerprofile_beta/prod)] APIEndpoint --> Backend[seller_central_backend\nDjango 6.1 DRF] CsaAPIEndpoint --> CsaBackend[crmbackend\nDjango 6.1 DRF] Backend -- Logistics API --> ShippingService[shippingservice\nDjango + EKart + SFX Client] diff --git a/KNOWLEDGE.md b/KNOWLEDGE.md index e430a68..37b1dd5 100644 --- a/KNOWLEDGE.md +++ b/KNOWLEDGE.md @@ -18,7 +18,8 @@ This document contains full technical specifications, data models, API endpoints | Parameter | Configuration / Value | Scope / Usage | | :--- | :--- | :--- | -| **API Base URL** | `https://betapartner-api.tradhox.com/api` | Primary DRF Backend API for Beta and Local testing | +| **Supplier API Base URL**| `https://betapartner-api.tradhox.com/api` | Primary DRF Backend API for Supplier Central (Beta & Local) | +| **Customer API Base URL**| `https://beta-api.tradhox.com/api` | Primary DRF Backend API for Customer Website (Beta & Local) | | **CSA API Base URL** | `https://betaapicsa.tradhox.com/api` | CSA Backend API (`crmbackend`) for Beta & Local testing | | **CSA Production Domain**| `https://csa.tradhox.com` | Customer Service & Support Portal (S3 Bucket: `csawebsite`) | | **CSA Beta Domain** | `https://betacsa.tradhox.com` | Staging / Beta CSA Portal (S3 Bucket: `betacsa`) | @@ -59,8 +60,9 @@ graph TD --- -## 1. 🛍️ Frontend: `supplier_central_frontend` +## 1. 🛍️ Frontend (FOR SELLERS & SUPPLIERS): `supplier_central_frontend` +- **Target Audience**: Sellers & Artisans (Product ingestion, stock management, order acceptance, payouts & shipping label printing). - **Directory**: `d:/Tradhox_workspace/supplier_central_frontend` - **Tech Stack**: React 19, TypeScript, Vite, TailwindCSS v4, Bulma CSS, Lucide React, FontAwesome. - **Hosting**: AWS S3 Static Hosting / CloudFront CDN. @@ -81,27 +83,81 @@ graph TD - `OrdersPage.tsx` & Order Views - Order acceptance, rescheduling, damage reporting. - `PayoutsPage.tsx` - Wallet balance & withdrawal requests. - `ReturnsTrackerPage.tsx` - Reverse shipment tracking & Quality Check (QC). - - `ShippingLabelsPage.tsx` & `LabelPreviewPage.tsx` - Thermal AWB label preview & batch printing. - `StorefrontPage.tsx` & `SettingsPage.tsx` - Seller brand settings. --- -## 2. 🏛️ Frontend: `customerwebsite` +## 2. 🏛️ Frontend & Backend (FOR CONSUMERS & END CUSTOMERS): `customerwebsite` & `customerwebsitebackend` +### A. Frontend: `customerwebsite` (FOR CONSUMERS) +- **Target Audience**: End Consumers & Patrons (Catalog browsing, shopping bag, checkout, order tracking & sovereign wallet). - **Directory**: `d:/Tradhox_workspace/customerwebsite` -- **Tech Stack**: React 19, Vite, TailwindCSS v4, Lucide React, Google Material Symbols. +- **Tech Stack**: React 19, Vite, TailwindCSS v4, Lucide React, Google Material Symbols, React Router DOM. - **Hosting**: AWS S3 Static Hosting / CloudFront CDN. - **Dev Server**: `http://localhost:5173/` - **Zero Mock / Guest First Architecture**: - Initial state defaults strictly to **Guest Mode** (Sign In / Register CTAs in Header, 0 badge counts). - - Authentication is **100% Mobile Number + OTP** based (Email & Password removed). - - Clean initial states for Cart `[]`, Wishlist `[]`, Orders `[]`, Addresses `[]`, and Wallet balance `₹0`. + - Authentication is **100% Mobile Number + WhatsApp OTP** based (Email & Password removed). + - Clean initial states for Cart `[]`, Wishlist `[]`, Orders `[]`, Addresses `[]`, and Sovereign Wallet balance `₹0`. - Zero hardcoded mock products or fake user credentials. - Full dynamic state management in `src/context/AuthContext.jsx`. +- **Key Modules & Context (`AuthContext.jsx`)**: + - Auth: `isLoggedIn`, `user`, `sendOtp`, `loginWithOtp`, `registerWithOtp`, `logout`, `updateProfile`. + - Cart / Bag: `cart`, `addToCart`, `removeFromCart`, `updateCartQuantity`, `clearCart`, `cartSubtotal`, `cartTax`, `cartShipping`, `cartTotal`, `cartCount`. + - Wishlist: `wishlist`, `toggleWishlist`, `removeFromWishlist`, `isInWishlist`, `wishlistCount`. + - Delivery Addresses: `addresses`, `addAddress`, `updateAddress`, `deleteAddress`, `setDefaultAddress`, `getSelectedAddress`. + - Orders: `orders`, `activeOrderId`, `placeOrder`, `cancelOrder`, `requestReturn`, `getOrderById`. + - Sovereign Wallet: `walletBalance`, `walletTransactions`, `addMoneyToWallet`, `payWithWallet`. +- **Page Route Specs (`App.jsx`)**: + - `/` & `/home` - `HomePage.jsx` (Hero banner, heritage categories, curated collections, trending products). + - `/products` - `ProductListingPage.jsx` (Catalog grid, price filtering, category taxonomy, sorting). + - `/product/:id` - `ProductDetailPage.jsx` (Gallery, variant selector, stock status, add to cart/buy now). + - `/cart` - `CartPage.jsx` (Bag items, quantity adjustments, tax/shipping breakdown). + - `/checkout` - `CheckoutPage.jsx` (Delivery address selection & order summary). + - `/select-payment` & `/payment` - `SelectPaymentPage.jsx` (UPI, Cards, NetBanking, Sovereign Wallet, COD). + - `/payment-retry` - `PaymentRetryPage.jsx` (Transaction failure recovery). + - `/orders` - `OrderConfirmationPage.jsx` (Success message & invoice summary). + - `/tracking` - `OrderTrackingPage.jsx` (Real-time tracking, Shadowfax AWB timeline). + - `/wishlist` - `WishlistPage.jsx` (Saved patron wishlist grid). + - `/account` - `AccountPage.jsx` (Patron dashboard hub). + - `/wallet` - `WalletPage.jsx` & `/add-money` - `AddMoneyWalletPage.jsx` (Sovereign wallet ledger & top-up). + - `/profile` - `ProfilePage.jsx` & `/change-password` - `ChangePasswordPage.jsx` (Profile & security settings). + - `/addresses` - `AddressesPage.jsx` & `/add-address` - `AddAddressPage.jsx` (Saved address management). + - `/login` - `LoginPage.jsx` & `/register` - `RegisterPage.jsx` (WhatsApp OTP login/registration). + - `/order-cancellation` & `/return-request` - Cancellation & return request flows. --- -## 3. ⚙️ Backend Core: `seller_central_backend` +### B. Backend Microservice: `customerwebsitebackend` (FOR CONSUMERS) +- **Directory**: `d:/Tradhox_workspace/customerwebsitebackend` +- **Tech Stack**: Python 3.14, Django 6.1, DRF, SimpleJWT, `django-cors-headers`, Gunicorn, PostgreSQL. +- **Daemon Service**: `customer-website-backend.service` on AWS EC2 (`16.113.57.127:8082`). +- **CORS Setup**: `CorsMiddleware` #1 position, `CORS_ALLOW_ALL_ORIGINS = True`, `CORS_ALLOW_CREDENTIALS = True`, full HTTP methods & headers. +- **Database Routing**: Multi-database setup (`DatabaseRouter` in `customerwebsitebackend/db_router.py`): + - `default` / `customerprofile`: Database `customerprofile_beta` or `customerprofile_prod` (Users, CustomerProfiles, Carts, CartItems, Orders). + - `productprofile`: Database `productprofile_beta` or `productprofile_prod` (Categories, `Product` unmanaged model pointing to `api_product` table). + - `sellerprofile`: Database `sellerprofile_beta` or `sellerprofile_prod` (`SellerOrder` unmanaged model pointing to `api_order` table). +- **Core API Endpoints**: + | Endpoint | Method | Class View | Description | + | :--- | :--- | :--- | :--- | + | `/api/v1/customer/auth/send-whatsapp/`| `POST` | `SendWhatsAppOTPView` | Dispatch WhatsApp OTP to mobile number | + | `/api/v1/customer/auth/register/` | `POST` | `UserRegisterView` | Register customer account | + | `/api/v1/customer/auth/login/` | `POST` | `TokenObtainPairView` | JWT Token generation | + | `/api/v1/customer/auth/refresh/` | `POST` | `TokenRefreshView` | JWT Token refresh | + | `/api/v1/customer/profile/` | `GET`, `PUT` | `UserProfileView` | Fetch & update customer profile | + | `/api/v1/customer/categories/` | `GET` | `CategoryListView` | Public category taxonomy list | + | `/api/v1/customer/products/` | `GET` | `ProductListView` | Catalog product listing & search | + | `/api/v1/customer/products//` | `GET` | `ProductDetailView` | Single product details | + | `/api/v1/customer/cart/` | `GET`, `POST` | `CartView` | View shopping cart / Add item | + | `/api/v1/customer/cart/items//` | `PUT`, `DELETE` | `CartItemDetailView` | Update item quantity / Delete | + | `/api/v1/customer/cart/checkout/` | `POST` | `CheckoutView` | Create Order & sync `SellerOrder` (`api_order`) | + | `/api/v1/customer/cart/payment-success/`| `POST` | `PaymentSuccessView` | Payment confirmation & update seller status | + | `/api/v1/customer/orders/` | `GET` | `OrderHistoryView` | Customer order history with tracking details | + | `/api/v1/customer/orders//` | `GET` | `OrderDetailView` | Customer order detail view | + +--- + +## 3. ⚙️ Backend Core (FOR SELLERS & SUPPLIERS): `seller_central_backend` - **Directory**: `d:/Tradhox_workspace/seller_central_backend` - **Tech Stack**: Python 3.14, Django 6.1, DRF, SimpleJWT, Gunicorn, PostgreSQL/SQLite, Boto3. @@ -122,7 +178,7 @@ graph TD --- -## 4. 🚚 Shipping & Logistics Microservice: `shippingservice` +## 5. 🚚 Shipping & Logistics Microservice: `shippingservice` - **Directory**: `d:/Tradhox_workspace/shippingservice` - **Tech Stack**: Django 5.x, Gunicorn, Requests, WhiteNoise. @@ -131,7 +187,7 @@ graph TD --- -## 5. 🌐 EC2 Server Infrastructure & Nginx Proxy Architecture +## 6. 🌐 EC2 Server Infrastructure & Nginx Proxy Architecture - **Server IP**: `16.113.57.127` (Region: `ap-south-2`, User: `ubuntu`, Key: `~/.ssh/vignesh_tipro_apsouth2.pem`) - **Database Cluster**: `16.113.106.152:5432` (`cisystem`) @@ -142,6 +198,7 @@ graph TD | :--- | :--- | :--- | :--- | :--- | | **80 / 443** | `0.0.0.0` | `nginx.service` | Reverse Proxy Master | `https://*.tradhox.com` | | **8080** | `0.0.0.0` | `seller-central-backend.service` | `http://127.0.0.1:8080` | `https://betapartner-api.tradhox.com` | +| **8082** | `0.0.0.0` | `customer-website-backend.service` | `http://127.0.0.1:8082` | Customer Website Backend API | | **8085** | `0.0.0.0` | `seller-central-backend-beta.service`| Standby Beta DRF API | Internal testing / staging | | **8086** | `0.0.0.0` | `shippingservice-beta.service` | `http://127.0.0.1:8086` | Logistics & AWB Label API | | **8087** | `0.0.0.0` | `searchengine.service` | `http://127.0.0.1:8087` | `https://betasearch-api.tradhox.com` | @@ -156,6 +213,7 @@ graph TD ### Nginx Configuration File Paths (`/etc/nginx/sites-available/`) - `seller-central-backend` $\rightarrow$ `/etc/nginx/sites-enabled/seller-central-backend` (Proxies port 8080) +- `customer-website-backend` $\rightarrow$ `/etc/nginx/sites-enabled/customer-website-backend` (Proxies port 8082) - `shippingservice-beta` $\rightarrow$ `/etc/nginx/sites-enabled/shippingservice-beta` (Proxies port 8086) - `searchengine` $\rightarrow$ `/etc/nginx/sites-enabled/searchengine` (Proxies port 8087) - `emailservice` $\rightarrow$ `/etc/nginx/sites-enabled/emailservice` (Proxies port 8091) @@ -178,11 +236,14 @@ cd d:/Tradhox_workspace/customerwebsite npm run build ``` -### Backend & Shipping Service Verification +### Backend, Customer Backend & Shipping Service Verification ```powershell cd d:/Tradhox_workspace/seller_central_backend python manage.py test +cd d:/Tradhox_workspace/customerwebsitebackend +python manage.py test + cd d:/Tradhox_workspace/shippingservice python manage.py test ```