# EBC – building materials marketplace

## Project

- Client: **ExpertBuildCare Private Limited** (EBC), Coimbatore. Multi-vendor B2B + B2C building materials platform: website, admin panel, seller (vendor) panel, and a Flutter customer app on `/api/v1/*` (Sanctum).
- Copied from the multivendor marketplace (`d:\xampp\htdocs\multivendor`): Laravel 12, Blade, Bootstrap 5 (prebuilt CSS/JS in `public/assets`, no Node or npm), vanilla JS, MySQL 8 in production (MariaDB 10.4 on local XAMPP: keep migrations portable), India timezone (Asia/Kolkata).
- Already built: three panels (storefront, admin, seller), two-step sign-in, security and logs, Razorpay + RazorpayX payouts, SMS and WhatsApp, commission engine, GST, PDFs, reports, Excel exports.
- Runs on port 8001 (`php artisan serve --port=8001`). Databases: `ebc` (site) and `ebc_test` (tests).
- Front-end without a build: `public/assets/{css,js}/storefront|admin|seller.*` are minified; don't rewrite them. Put new storefront styles/scripts in the plain files `public/assets/css/ebc-extras.css` and `public/assets/js/ebc-extras.js` (loaded on every storefront page), or a page file pushed with `@push('styles')` (e.g. `contact.css`, `order-success.css`, `quote.css`). Only tiny targeted fixes go inside the minified files.
- Tests: `php artisan test` (266 passing on 2026-12-03). `tests/Feature/QA/RouteSmokeTest.php` opens every GET page as guest, customer, seller and super admin after a real order (checkout, ship, deliver, payout) and fails on any 5xx or an own-area page that does not open; keep it passing when adding routes. Tests use the sample building-materials catalogue in `database/seeders/data/demo-products.php` (`SHOW_DEMO_PRODUCTS=true` in `phpunit.xml`). The site itself has `SHOW_DEMO_PRODUCTS=false`.
- All uploaded images (product, review, banner, brand, category) are converted to WebP by `ProductImageService` (JPG/PNG/WebP accepted, transparency kept). Exceptions: site logo and SEO share image (PDFs, emails and WhatsApp previews need PNG/JPG). The sample products use our own drawn transparent pack shots in `public/images/products`. Don't copy product photos from competitor sites (copyright).
- `public/.htaccess` sets gzip and browser caching (needs mod_deflate and mod_headers on the server).
- Category and section photos: `public/images/photos` (Unsplash License, see `CREDITS.md`); illustrations in `public/images/catalog`.
- Brand: logo files in `public/images/brand` (white version for dark backgrounds; app icons use the building mark). Colours from the logo: red `#d71616` (buttons, prices) and charcoal `#242529` (text, category bar, footer). Storefront layout follows the client's reference (ibo.com) in structure, with our own category mosaic and sections; sample brands in the demo seeder are fictional on purpose.
- Create the first admin with `php artisan app:create-admin`.
- Local preview with sample products, without touching `ebc`: `DB_DATABASE=ebc_test SHOW_DEMO_PRODUCTS=true php artisan migrate:fresh --seed`, then serve on another port with the same variables (the next test run wipes it).

## Spec decisions (from the client brief)

- **Extend the existing codebase**, don't rebuild. Spec table names map to existing tables: vendors = `seller_stores`, gst_invoices = `tax_invoices`, commission_ledgers = `seller_earnings`, vendor_payouts = `payouts`, notification_logs = `message_logs`. New tables: `categories`, `brands`, `product_price_slabs`, `vehicle_types`, `delivery_zones`, `zone_vehicle_rates`, `pincode_rates`, `carts`, `vendor_sub_orders`, `payment_transactions`, `rfq_enquiries`, `rfq_items`, `fcm_tokens`, `personal_access_tokens`.
- **Vendor anonymity:** customers never see a vendor's name, GSTIN, address or phone (web, app, SMS, WhatsApp, invoices). Everything appears sold and fulfilled by ExpertBuildCare.
- **Commission (deduction model):** vendor net = item subtotal − commission − TDS. Priority: product SKU override > vendor custom rate > category default; % or flat ₹ per unit.
- **TDS:** only 194Q, behind a switch that is off by default until the CA confirms (EBC turnover over ₹10 crore). No TCS (sec. 52) and no 194-O in the reseller model.
- Approved packages: sanctum, spatie/laravel-permission, barryvdh/laravel-dompdf, intervention/image v3, razorpay/razorpay; PhonePe, WhatsApp, DLT SMS and FCM through the `Http` facade.

## Client

- Startup with turnover under ₹5 crore, so e-invoice is not mandatory yet. E-way bill is still needed for most loads; confirm Tamil Nadu's intra-state limit with the CA.
- Sells building materials: cement, stone, sand and similar. Buyers are mostly contractors and builders with a GSTIN; fewer home buyers.

## Invoicing model (reseller)

- All customer invoices are in EBC's name, so EBC is the seller. Vendors bill EBC ("bill to EBC, ship to site").
- One EBC invoice per dispatched sub-order, since each truckload needs its own e-way bill with its own dispatch address, vehicle and distance.
- EBC also sells its own (in-house) products. Both vendors and EBC deliver.
- E-invoice: build it ready but switched off, so it can be turned on after crossing ₹5 crore.
- E-way bill: start with the JSON download, then a live connection through a GST Suvidha Provider later.

## Waiting on the client

1. Does EBC's own delivery also pick up vendor goods, or only deliver EBC's stock?
2. How many EBC yards or warehouses, and where? (Needed for pincode distances and zone fares.)
3. Delivery zones, pincodes and fares per vehicle.
4. Credit terms for contractors.

## Plan (client brief, 5 phases; wait for confirmation after each)

1. Schema, migrations and models. **(Done 2026-11-29.)**
2. **(Next.)** Security middleware (separate admin / vendor / customer guards, rate limits, CSP), policies, FormRequests, and services: PricingAndFreightService, CommissionCalculatorService, OrderSplitService, GstInvoiceService + PDF. Also: `preventLazyLoading` outside production, vendor anonymity on every customer page.
3. Payments (Razorpay, PhonePe, webhooks, advance payments) and queued notifications (DLT SMS, WhatsApp with invoice PDF, FCM).
4. Admin and seller panels for the new features.
5. Customer website flows (slab prices, pincode freight, RFQ, GST credit at checkout) and the Flutter app.

Earlier foundation step (done 2026-11-29): removed gifting, gift wrap, open box delivery, the craft design and sample catalogue, and product questions; renamed to EBC; new storefront design.

## Working preferences

- Don't change things that weren't asked for.
- SEO-friendly URLs.
- Fast, secure, good UI/UX.
- Never run two test runs at the same time (they share the test database).
