Phase 3: AI recommendation engine and analytics layer - #4
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a full “Phase 3” slice of functionality across the monorepo: a React/Vite frontend dashboard experience (auth, products, competitor monitoring, recommendations) paired with FastAPI backend services for products/auth, scraping orchestration (Celery), and AI-backed recommendation generation with supporting analytics utilities.
Changes:
- Added a new React + Vite frontend application structure with routing, auth flows, product CRUD UI, competitor monitoring UI, and an AI recommendations dashboard.
- Added backend API surface area for auth/products/competitors/scraper/recommendations plus the underlying services/models/schemas to support scraping and AI recommendations.
- Added analytics utilities/engines and a recommendation orchestration service that combines analytics + LLM generation + persistence.
Reviewed changes
Copilot reviewed 171 out of 185 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds security/ops notes (JWT storage + DB bootstrap behavior). |
| frontend/vite.config.ts | Adds Vite config with @ alias for frontend imports. |
| frontend/tsconfig.node.json | Adds TS config for Vite/node-side TS build inputs. |
| frontend/tsconfig.json | Adds baseUrl/paths mapping for @/* in TS. |
| frontend/tsconfig.app.json | Adds app TS config (bundler resolution, JSX, linting flags). |
| frontend/tailwind.config.js | Adds Tailwind config with CSS-variable-driven theme tokens. |
| frontend/src/utils/validation.ts | Adds basic email/password/phone validators for auth forms. |
| frontend/src/utils/formatters.ts | Adds number/currency/percent formatting helpers (BDT-focused). |
| frontend/src/utils/errors.ts | Adds shared error-message extraction (Axios-aware). |
| frontend/src/utils/env.ts | Adds Vite env parsing for API base URL with dev fallback. |
| frontend/src/types/product.ts | Adds frontend product domain types + input payload type. |
| frontend/src/types/navigation.ts | Adds typed navigation item shape used by sidebar/header. |
| frontend/src/types/dashboard.ts | Adds dashboard KPI/insight types for summary payloads. |
| frontend/src/types/auth.ts | Adds auth/user types plus auth context contract. |
| frontend/src/services/product-service.ts | Adds product API client + mapping from API to UI types. |
| frontend/src/services/dashboard-service.ts | Adds dashboard summary API client (currently points to /dashboard/summary). |
| frontend/src/services/auth-storage.ts | Adds localStorage-based token/user persistence. |
| frontend/src/services/auth-service.ts | Adds auth/profile API client + mapping from API seller to UI user. |
| frontend/src/routes/protected-route.tsx | Adds auth-gated routing wrapper for /app/*. |
| frontend/src/routes/nav-config.ts | Adds sidebar/header nav configuration (dashboard/products/etc.). |
| frontend/src/routes/index.tsx | Adds router definition with protected app shell + lazy routes. |
| frontend/src/pages/recommendations/utils/recommendationHelpers.ts | Adds formatting and UI metadata helpers for recommendation rendering. |
| frontend/src/pages/recommendations/types/recommendation.ts | Adds recommendation + analytics API and UI type definitions. |
| frontend/src/pages/recommendations/services/recommendationApi.ts | Adds recommendation API client + mapping and 404 handling for “latest”. |
| frontend/src/pages/recommendations/recommendations-page.tsx | Route entry that re-exports the recommendations dashboard component. |
| frontend/src/pages/recommendations/RecommendationDashboardPage.tsx | Adds recommendation dashboard UI with product selection + generation flow. |
| frontend/src/pages/recommendations/hooks/useRecommendation.ts | Adds React Query hook for latest+generate recommendation orchestration. |
| frontend/src/pages/recommendations/components/RevenueOpportunityCard.tsx | Adds revenue opportunity UI card for recommendation dashboard. |
| frontend/src/pages/recommendations/components/RecommendationSkeleton.tsx | Adds loading skeleton for recommendation dashboard. |
| frontend/src/pages/recommendations/components/RecommendationCard.tsx | Adds recommendation display card (confidence, Bangla reasoning, timestamp). |
| frontend/src/pages/recommendations/components/GenerateRecommendationButton.tsx | Adds button with spinner state for recommendation generation. |
| frontend/src/pages/recommendations/components/EmptyRecommendationState.tsx | Adds empty state prompting recommendation generation. |
| frontend/src/pages/recommendations/components/AnalyticsStats.tsx | Adds analytics stat tiles for recommendation dashboard. |
| frontend/src/pages/recommendations/components/ActionBadge.tsx | Adds action badge UI for recommendation action labeling. |
| frontend/src/pages/realtime/realtime-page.tsx | Adds placeholder realtime monitoring page. |
| frontend/src/pages/products/product-list-page.tsx | Adds product list page with delete flow + error handling. |
| frontend/src/pages/products/product-form-page.tsx | Adds “create product” page using shared form component. |
| frontend/src/pages/products/product-edit-page.tsx | Adds “edit product” page using shared form component. |
| frontend/src/pages/pricing/pricing-page.tsx | Adds placeholder pricing analytics page. |
| frontend/src/pages/not-found.tsx | Adds not-found page with navigation back to dashboard. |
| frontend/src/pages/competitors/types/competitor.types.ts | Adds competitor API/UI types and scraper run response type. |
| frontend/src/pages/competitors/services/competitorService.ts | Adds competitor list + run scraper API client with response normalization. |
| frontend/src/pages/competitors/hooks/useRunScraper.ts | Adds React Query mutation hook to enqueue scraper + invalidate competitors. |
| frontend/src/pages/competitors/hooks/useCompetitors.ts | Adds React Query hook for competitor list fetching. |
| frontend/src/pages/competitors/components/RunScraperButton.tsx | Adds scraper run button with status/error messaging UI. |
| frontend/src/pages/competitors/components/LoadingState.tsx | Adds competitor dashboard loading skeletons. |
| frontend/src/pages/competitors/components/ErrorState.tsx | Adds competitor dashboard error wrapper around shared error component. |
| frontend/src/pages/competitors/components/EmptyState.tsx | Adds competitor dashboard empty state component. |
| frontend/src/pages/competitors/components/CompetitorTable.tsx | Adds competitor table/card layout switch with sorting by confidence. |
| frontend/src/pages/competitors/competitors-page.tsx | Route entry that re-exports the competitors dashboard component. |
| frontend/src/pages/auth/register-page.tsx | Adds registration page with validation and auth integration. |
| frontend/src/pages/auth/login-page.tsx | Adds login page with validation and redirect-to-origin support. |
| frontend/src/pages/alerts/alerts-page.tsx | Adds placeholder WhatsApp alerts page. |
| frontend/src/main.tsx | Adds frontend entrypoint mounting <App />. |
| frontend/src/lib/utils.ts | Adds cn(...) Tailwind class merge helper. |
| frontend/src/layouts/root-layout.tsx | Adds root layout wrapper for routing. |
| frontend/src/layouts/dashboard-layout.tsx | Adds app shell layout (sidebar + header + content outlet). |
| frontend/src/index.css | Adds Tailwind layers + shadcn/tw-animate/geist imports + CSS variables. |
| frontend/src/hooks/use-products.ts | Adds React Query hooks for product CRUD operations. |
| frontend/src/hooks/use-auth.ts | Adds auth context hook with provider guard. |
| frontend/src/env.d.ts | Adds typing for import.meta.env variables. |
| frontend/src/context/auth-provider.tsx | Adds auth provider with login/register/profile update + localStorage persistence. |
| frontend/src/context/auth-context.ts | Adds auth context definition. |
| frontend/src/components/ui/input.tsx | Adds shared input component (shadcn-style). |
| frontend/src/components/ui/button.tsx | Adds shared button component (CVA + Radix Slot). |
| frontend/src/components/products/product-list.tsx | Adds responsive product list/table component with margin calc + actions. |
| frontend/src/components/common/route-error.tsx | Adds router error boundary UI. |
| frontend/src/components/common/page-header.tsx | Adds reusable page header (title/description/action). |
| frontend/src/components/common/loading-state.tsx | Adds reusable loading spinner state with aria attributes. |
| frontend/src/components/common/inline-alert.tsx | Adds reusable inline alert component. |
| frontend/src/components/common/form-field.tsx | Adds reusable labeled field wrapper with error text. |
| frontend/src/components/common/error-state.tsx | Adds reusable error empty state component. |
| frontend/src/components/auth/auth-layout.tsx | Adds auth page layout (form + side content). |
| frontend/src/components/auth/auth-highlights.tsx | Adds marketing/highlight side panel component. |
| frontend/src/components/auth/auth-form-alert.tsx | Adds auth form-level error banner. |
| frontend/src/components/auth/auth-footer-link.tsx | Adds auth footer link component. |
| frontend/src/components/auth/auth-field.tsx | Adds auth input field wrapper with error display. |
| frontend/src/components/app/user-menu.tsx | Adds user menu dropdown with profile completeness indicator + logout. |
| frontend/src/components/app/app-sidebar.tsx | Adds app sidebar navigation (desktop). |
| frontend/src/components/app/app-header.tsx | Adds app header and mobile nav pills. |
| frontend/src/App.tsx | Adds top-level providers (React Query, Auth) and router suspense fallback. |
| frontend/src/App.css | Adds CSS (appears to be template/legacy styling). |
| frontend/src/api/client.ts | Adds Axios client with auth header interceptor and baseURL from env. |
| frontend/README.md | Adds default Vite template README content. |
| frontend/postcss.config.js | Adds PostCSS config for Tailwind + autoprefixer. |
| frontend/package.json | Adds frontend dependencies/scripts (Vite, React Query, axios, Tailwind, etc.). |
| frontend/jsconfig.json | Adds JS tooling paths mapping for @/*. |
| frontend/index.html | Adds Vite HTML entrypoint. |
| frontend/eslint.config.js | Adds ESLint flat config for TS/React hooks/refresh. |
| frontend/components.json | Adds shadcn configuration (style, aliases, Tailwind integration). |
| frontend/.gitignore | Adds frontend-specific gitignore. |
| docker-compose.yml | Present in PR context (no diff shown). |
| backend/requirements.txt | Adds pinned backend Python dependencies (FastAPI, Celery, Playwright, ML libs, etc.). |
| backend/app/utils/init.py | Initializes utils package. |
| backend/app/tasks/scraper_tasks.py | Adds Celery tasks for manual/periodic scraping with retries + DB checks. |
| backend/app/tasks/init.py | Initializes tasks package and imports scraper tasks for discovery. |
| backend/app/services/tasks/init.py | Placeholder for future service-layer tasks. |
| backend/app/services/product_service.py | Adds product service for list/get/create/update/delete + searchable text building. |
| backend/app/services/health_service.py | Adds DB health check service. |
| backend/app/services/competitor_service.py | Adds competitor persistence + “latest competitors” listing logic. |
| backend/app/services/auth_service.py | Adds auth service for register/authenticate/update profile. |
| backend/app/services/init.py | Exposes service classes/exceptions through a package facade. |
| backend/app/scraper/utils.py | Adds scraper utility functions (parsing, retry, UA, delays, headers). |
| backend/app/scraper/services/competitor_service.py | Adds Daraz scrape orchestration using shared Playwright browser manager. |
| backend/app/scraper/services/init.py | Exports scraper services. |
| backend/app/scraper/selectors.py | Adds CSS selectors for Daraz scraping extraction. |
| backend/app/scraper/schemas.py | Adds Pydantic schemas for scrape results. |
| backend/app/scraper/exceptions.py | Adds typed scraper exception hierarchy. |
| backend/app/scraper/constants.py | Adds scraper constants and env-configurable tuning knobs. |
| backend/app/scraper/browser.py | Adds shared Playwright browser manager with context/page helpers. |
| backend/app/scraper/init.py | Initializes scraper package. |
| backend/app/schemas/scrape.py | Adds API schemas for scrape run + scrape task enqueue responses. |
| backend/app/schemas/recommendation.py | Adds API schemas for recommendation generation + analytics response payloads. |
| backend/app/schemas/health.py | Adds health check response schema. |
| backend/app/schemas/auth.py | Adds auth/register/login/profile schemas. |
| backend/app/schemas/init.py | Adds schema package exports. |
| backend/app/models/seller.py | Adds seller SQLAlchemy model. |
| backend/app/models/scrape_run.py | Adds scrape run SQLAlchemy model. |
| backend/app/models/product.py | Adds product SQLAlchemy model + pricing warning property. |
| backend/app/models/price_history.py | Adds price history SQLAlchemy model. |
| backend/app/models/competitor.py | Adds competitor SQLAlchemy model with richer metadata fields. |
| backend/app/models/init.py | Adds model package exports. |
| backend/app/middleware/init.py | Initializes middleware package. |
| backend/app/main.py | Adds FastAPI app factory, lifespan DB check/bootstrap, CORS, and router registration. |
| backend/app/dependencies/db.py | Adds request-scoped DB session dependency. |
| backend/app/dependencies/auth.py | Adds JWT auth dependency via OAuth2PasswordBearer + token decoding. |
| backend/app/dependencies/init.py | Initializes dependencies package. |
| backend/app/db/session.py | Adds SQLAlchemy engine + SessionLocal setup. |
| backend/app/db/bootstrap.py | Adds optional runtime bootstrap helpers for sellers/products tables/columns. |
| backend/app/db/base.py | Adds declarative base. |
| backend/app/db/init.py | Initializes DB package. |
| backend/app/core/security.py | Adds password hashing + JWT create/decode helpers. |
| backend/app/core/config.py | Adds settings loader from env/.env with required vars and defaults. |
| backend/app/core/celery_app.py | Adds Celery app configuration + beat schedule. |
| backend/app/core/init.py | Initializes core package. |
| backend/app/api/v1/scraper.py | Adds scraper API routes (direct Daraz scrape + enqueue run). |
| backend/app/api/v1/recommendations.py | Adds recommendation generate/latest endpoints with structured error responses. |
| backend/app/api/v1/products.py | Adds product CRUD endpoints. |
| backend/app/api/v1/health.py | Adds health endpoint. |
| backend/app/api/v1/competitors.py | Adds competitor listing endpoint for latest scrape run. |
| backend/app/api/v1/auth.py | Adds register/login/me/profile endpoints. |
| backend/app/api/v1/init.py | Initializes v1 API package. |
| backend/app/api/router.py | Centralizes router wiring under API v1 prefix. |
| backend/app/api/init.py | Initializes API package. |
| backend/app/analytics/stock_engine.py | Adds stock analytics engine used in recommendation pipeline. |
| backend/app/ai/schemas.py | Adds AI recommendation prompt/response schemas with Bangla validation. |
| backend/app/init.py | Initializes app package. |
| backend/alembic/versions/1c8c3e4d9a5b_add_product_and_competitor_metadata.py | Adds Alembic migration for product + competitor metadata columns/indexes. |
| backend/alembic/script.py.mako | Adds Alembic revision template. |
| backend/alembic/README | Adds Alembic README. |
| backend/alembic/env.py | Adds Alembic environment configuration for migrations. |
| backend/alembic.ini | Adds Alembic configuration file. |
| .gitignore | Expands repo-level ignores (Python/Node/env/IDE artifacts). |
| .github/copilot-instructions.md | Documents build/lint commands and repo architecture/conventions. |
| .env.example | Present in PR context (no diff shown). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+20
| "lucide-react": "^1.16.0", | ||
| "radix-ui": "^1.4.3", | ||
| "react": "^19.2.6", |
Comment on lines
+74
to
+79
| export type ScraperRunResponse = { | ||
| message: string | ||
| status?: string | ||
| run_id?: string | ||
| triggered_at?: string | ||
| } |
Comment on lines
+4
to
+6
| export async function getDashboardSummary(): Promise<DashboardSummary> { | ||
| const { data } = await apiClient.get<DashboardSummary>("/dashboard/summary") | ||
| return data |
Comment on lines
+86
to
+93
| run_migrations_online() | ||
|
|
||
| import os | ||
|
|
||
| config.set_main_option( | ||
| "sqlalchemy.url", | ||
| os.getenv("DATABASE_URL") | ||
| ) No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
Testing