Intelligent multi-platform e-commerce aggregator, scraper, and market intelligence platform for Tokopedia and Amazon, powered by AI trend analytics and interactive data visualizations.
- Multi-Platform Web Scraping:
- Tokopedia Scraper: Direct GraphQL integration via
@bintangtimurlangit/tokopedia-mcpwith seamless fallback to public GraphQL search without requiring user login. - Amazon Scraper: High-reliability scraping powered by the Bright Data Dataset API (
gd_l7q7dkf244hwjntr0). Safely skips with descriptive logging if credentials are not configured. - Scheduled Cron Jobs: Automated background cron worker runs every 6 hours (
0 */6 * * *) vianode-cronto keep product catalogs up to date. - On-Demand Manual Scraping: Instantly trigger scrapes from either the public UI or via REST API with per-platform targeting (
TOKOPEDIA,AMAZON, orALL).
- Tokopedia Scraper: Direct GraphQL integration via
- Interactive Product Catalog & Filtering:
- Filter products in real time by platform (Tokopedia, Amazon, or All), price boundaries (minimum and maximum in IDR), and star rating thresholds.
- AI Trend Analysis:
- Automated sentiment, category movement, and price range evaluation powered by Groq Cloud AI using
llama-3.3-70b-versatile. - Price tier distribution bar charts rendered dynamically with Recharts.
- Automated sentiment, category movement, and price range evaluation powered by Groq Cloud AI using
- Protected Admin Dashboard:
- Secure administration panel with httpOnly JWT cookie authentication.
- Paginated product catalog management with single-click deletions.
- Real-time scrape activity logs tracking timestamp, item count, execution status, and diagnostic messages.
- Live API key configuration indicators for Groq and Bright Data credentials.
- Runtime: Node.js (v18+ or v20+)
- Language: TypeScript (ESM module format)
- Framework: Express.js
- ORM & Database: Prisma ORM with SQLite (local development) / PostgreSQL (production)
- Authentication: JWT (
jsonwebtoken) stored in secure,httpOnlycookies withbcryptjspassword hashing - AI Engine: Groq SDK (
llama-3.3-70b-versatile) - HTTP & Utilities: Axios,
cookie-parser,cors,dotenv,node-cron
- Framework: React 18 + Vite
- Language: TypeScript
- Routing: React Router (v7) with protected route guards
- Styling: Tailwind CSS (modern slate dark theme)
- Charts & Visualization: Recharts
- Icons: Lucide React
Before installing ScrapeHub, ensure your development system has:
- Node.js: v18.18.0 or v20.x or higher
- npm: v9.x or v10.x or higher (or
pnpm/yarn) - Git
scrapehub/
βββ backend/ # Backend REST API
β βββ src/
β β βββ index.ts # Express server entry point & middleware setup
β β βββ prisma.ts # PrismaClient shared singleton instance
β β βββ middlewares/
β β β βββ auth.middleware.ts # JWT verification & requireAdmin route guards
β β βββ routes/
β β β βββ admin.routes.ts # Protected administrative endpoints
β β β βββ ai.routes.ts # AI trend analysis & summary endpoints
β β β βββ auth.routes.ts # Authentication endpoints (login, logout, me)
β β β βββ product.routes.ts # Product catalog CRUD & query endpoints
β β β βββ scrape.routes.ts # Manual scraper trigger endpoints
β β βββ services/
β β β βββ ai.service.ts # Groq Cloud AI analysis service
β β β βββ scheduler.ts # node-cron 6-hour background scraping worker
β β β βββ scraper/
β β β βββ amazon.ts # Bright Data Amazon scraper integration
β β β βββ tokopedia.ts # Tokopedia GraphQL scraper engine
β β βββ prisma/
β β βββ schema.prisma # Database schema models
β β βββ seed.ts # Default administrator database seeder
β βββ .env.example # Backend environment variable template
β βββ package.json
β βββ Procfile # Railway process command
β βββ railway.json # Railway Nixpacks deployment config
β βββ tsconfig.json
βββ frontend/ # Frontend Single Page Application (SPA)
β βββ src/
β β βββ components/ # Reusable UI components
β β β βββ FilterBar.tsx # Platform, price, and rating filter controls
β β β βββ Navbar.tsx # Main header navigation bar & live system badges
β β β βββ ProductCard.tsx # Product display card with pricing & links
β β β βββ ProductGrid.tsx # Responsive grid container & loading skeletons
β β β βββ ProtectedRoute.tsx # Route authentication verification wrapper
β β β βββ StatCard.tsx # KPI metrics counter card
β β β βββ TrendSummary.tsx # Groq AI trend summary & Recharts price distribution
β β βββ pages/
β β β βββ AdminDashboard.tsx # Full admin portal (tables, logs, API keys)
β β β βββ LoginPage.tsx # Admin authentication login screen
β β β βββ PublicDashboard.tsx # Public product catalog & analytics dashboard
β β βββ services/
β β β βββ api.ts # Centralized Axios API client
β β βββ types/
β β β βββ index.ts # Shared TypeScript interface definitions
β β βββ App.tsx # Route declarations & top-level layout
β β βββ index.css # Tailwind CSS entry point
β β βββ main.tsx # React DOM mount point
β βββ .env.example # Frontend environment variable template
β βββ index.html
β βββ package.json
β βββ tailwind.config.js
β βββ tsconfig.json
β βββ vercel.json # Vercel SPA client rewrite configuration
β βββ vite.config.ts # Vite server & bundler configuration
βββ .env.example # Global environment variables template
βββ .gitignore # Git exclusion rules
βββ BUGFIX_REPORT.md # Comprehensive audit and bugfix report
βββ README.md # Main project documentation (this file)
Follow these step-by-step instructions to get ScrapeHub running locally:
git clone https://github.com/your-username/scrapehub.git
cd scrapehubcd backend
npm install
cp .env.example .envOpen backend/.env and configure your settings:
DATABASE_URL="file:./dev.db"
PORT=5001
NODE_ENV="development"
FRONTEND_URL="http://localhost:5173"
JWT_SECRET="scrapehub-admin-secret-jwt-key-2026-very-secure!"
ADMIN_EMAIL="admin@scrapehub.dev"
ADMIN_PASSWORD="Admin123!"
GROQ_API_KEY="" # Optional: Add your Groq API key (gsk_...)
BRIGHTDATA_API_KEY="" # Optional: Add your Bright Data API key
BRIGHTDATA_AMAZON_DATASET_ID="gd_l7q7dkf244hwjntr0"Initialize the database and seed the default administrator user:
npx prisma migrate dev --name init # or: npm run prisma:push
npx prisma db seed # or: npm run seedOpen a new terminal and navigate to the frontend directory:
cd ../frontend
npm install
cp .env.example .envEnsure frontend/.env points to the local backend server:
VITE_API_URL="http://localhost:5001"cd backend
npm run devThe backend API server starts at: http://localhost:5001
cd frontend
npm run devThe frontend application starts at: http://localhost:5173
Open your browser and navigate to http://localhost:5173 to explore the dashboard.
A default administrator account is generated during database seeding:
- Email:
admin@scrapehub.dev - Password:
Admin123! - Login Portal:
http://localhost:5173/login - Admin Dashboard:
http://localhost:5173/admin
β οΈ IMPORTANT SECURITY NOTICE: The default credentials above must be changed prior to deploying ScrapeHub to a public production environment. Set a strong, uniqueADMIN_PASSWORDandJWT_SECRETin your production environment variables.
| Variable | Type | Default Value | Description |
|---|---|---|---|
DATABASE_URL |
String | "file:./dev.db" |
Prisma connection string (SQLite file path or PostgreSQL URI). |
PORT |
Number | 5001 |
Port on which the Express server listens. |
NODE_ENV |
String | "development" |
Application environment (development or production). |
FRONTEND_URL |
String | "http://localhost:5173" |
Allowed CORS origins (supports comma-separated origins). |
JWT_SECRET |
String | (random secret) | Secret cryptographic key used to sign and verify authentication JWTs. |
ADMIN_EMAIL |
String | "admin@scrapehub.dev" |
Default admin account email used during database seeding. |
ADMIN_PASSWORD |
String | "Admin123!" |
Default admin account password hashed with bcrypt during seeding. |
GROQ_API_KEY |
String | "" |
Groq Cloud API key for Llama 3.3 AI trend analysis (optional). |
BRIGHTDATA_API_KEY |
String | "" |
Bright Data API token for Amazon scraping (optional). |
BRIGHTDATA_AMAZON_DATASET_ID |
String | "gd_l7q7dkf244hwjntr0" |
Target Amazon scraping dataset identifier on Bright Data. |
| Variable | Type | Default Value | Description |
|---|---|---|---|
VITE_API_URL |
String | "http://localhost:5001" |
Target backend API base URL called by Axios client. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
POST |
/api/auth/login |
Public | Authenticates admin credentials and sets httpOnly JWT cookie. |
POST |
/api/auth/logout |
Public | Clears authentication cookie. |
GET |
/api/auth/me |
Authenticated | Retrieves current authenticated session user profile. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
GET |
/api/products |
Public | Fetches filtered products (platform, minPrice, maxPrice, minRating, limit). |
GET |
/api/products/:id |
Public | Retrieves detailed information for a single product. |
POST |
/api/products |
Public / Admin | Manually creates a product item with input validation. |
PUT |
/api/products/:id |
Public / Admin | Updates an existing product item by ID with input validation. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
POST |
/api/scrape |
Public / Admin | Triggers scraping job. Accepts optional { platform: "TOKOPEDIA" | "AMAZON" | "ALL" }. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
GET |
/api/trends/latest |
Public | Retrieves the latest stored AI trend analysis record. |
POST |
/api/ai/analyze |
Public | Analyzes top 10 products with Groq AI (llama-3.3-70b-versatile) and stores summary. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
GET |
/api/admin/products |
Admin Only | Fetches products for admin management table. |
DELETE |
/api/admin/products/:id |
Admin Only | Deletes a product from the database by ID. |
GET |
/api/admin/logs |
Admin Only | Returns recent 50 scraping execution logs and error messages. |
GET |
/api/admin/config-status |
Admin Only | Returns status indicators for groq and brightdata API keys. |
| Method | Endpoint | Access | Description |
|---|---|---|---|
GET |
/api/health |
Public | Server uptime and health verification endpoint. |
GET |
/ |
Public | Welcome payload and API endpoint catalog. |
To achieve optimal performance and prevent serverless timeouts during long-running scraping tasks, ScrapeHub is architected for split deployment:
- Backend on Railway: Supports continuous background execution, node-cron schedulers, and managed PostgreSQL.
- Frontend on Vercel: High-speed edge CDN distribution for the React Single Page Application.
- Sign in to Railway.app and create a New Project.
- Add a PostgreSQL database (New -> Database -> Add PostgreSQL).
- Connect your repository and select the Root Directory as
backend. - Railway will automatically detect
railway.jsonandProcfile. - Under the Variables tab of the backend service, set:
DATABASE_URL: Reference your PostgreSQL instance:${{Postgres.DATABASE_URL}}NODE_ENV:productionPORT: (Managed automatically by Railway)JWT_SECRET: Generate a secure 32+ character random string.ADMIN_EMAIL: Your production admin email.ADMIN_PASSWORD: Your secure production admin password.GROQ_API_KEY: Your Groq Cloud API key.BRIGHTDATA_API_KEY: Your Bright Data API key (optional).FRONTEND_URL: Your Vercel frontend URL (e.g.,https://your-app.vercel.app).
- Navigate to Settings -> Networking -> Generate Domain to obtain your public backend domain (e.g.,
https://scrapehub-backend-production.up.railway.app).
- Sign in to Vercel.com and click Add New... -> Project.
- Select your repository.
- Configure the build parameters:
- Framework Preset:
Vite - Root Directory:
frontend - Build Command:
npm run build - Output Directory:
dist
- Framework Preset:
- In Environment Variables, define:
VITE_API_URL: Your Railway backend domain (e.g.,https://scrapehub-backend-production.up.railway.app, without trailing slash).
- The bundled
frontend/vercel.jsonensures all client-side routes (/login,/admin) are redirected seamlessly toindex.html. - Click Deploy.
- HttpOnly Cookie Authentication:
- Authentication tokens are delivered via
httpOnly,SameSite=Laxcookies, preventing cross-site scripting (XSS) token exfiltration.
- Authentication tokens are delivered via
- Never Commit Secrets:
.envfiles are strictly excluded via.gitignore. Always use.env.exampletemplates for configuration reference.
- Password Security:
- All user passwords are encrypted using
bcryptjswith salt rounds set to 10.
- All user passwords are encrypted using
- Rate Limiting:
- For high-exposure production environments, configure reverse-proxy rate limiting (e.g., Cloudflare) or add
express-rate-limitto protect/api/auth/loginand/api/scrape.
- For high-exposure production environments, configure reverse-proxy rate limiting (e.g., Cloudflare) or add
- Cause:
BRIGHTDATA_API_KEYis empty or unset inbackend/.env. - Solution: Amazon scraping requires Bright Data unlocker proxies. Add your key to
BRIGHTDATA_API_KEYinbackend/.env. If omitted, ScrapeHub gracefully skips Amazon and continues scraping Tokopedia without crashing.
- Cause:
GROQ_API_KEYis not configured inbackend/.env. - Solution: Obtain a free API key at console.groq.com and set
GROQ_API_KEY="gsk_..."inbackend/.env, then restart the backend server.
- Cause: The backend's
FRONTEND_URLdoes not match the origin URL sending requests. - Solution: In
backend/.env, setFRONTEND_URL="http://localhost:5173". If supporting multiple origins (e.g., local and staging), separate them with commas:FRONTEND_URL="http://localhost:5173,https://your-app.vercel.app".
- Cause: Prisma schema changes have not been applied to the local database file.
- Solution: Run
npm run prisma:pushinside thebackenddirectory, followed bynpm run seedto ensure tables and admin accounts are present.
- Cause: Another background process is occupying port 5001 or 5173.
- Solution: Identify and terminate the occupying process:
lsof -ti:5001 | xargs kill -9 lsof -ti:5173 | xargs kill -9
- Cause: Browser cookie blocked due to cross-site domain restrictions or insecure protocol in production.
- Solution: In production, ensure both backend and frontend use HTTPS. In development, verify
withCredentials: trueis enabled on the Axios client and the cookie domain matches.
This project is open source and available under the MIT License.
Test Pull Shark 2