## Worker System - Role-agnostic workers that can handle any task type - Pod-based architecture with StatefulSet (5-15 pods, 5 workers each) - Custom pod names (Aethelgard, Xylos, Kryll, etc.) - Worker registry with friendly names and resource monitoring - Hub-and-spoke visualization on JobQueue page ## Stealth & Anti-Detection (REQUIRED) - Proxies are MANDATORY - workers fail to start without active proxies - CrawlRotator initializes on worker startup - Loads proxies from `proxies` table - Auto-rotates proxy + fingerprint on 403 errors - 12 browser fingerprints (Chrome, Firefox, Safari, Edge) - Locale/timezone matching for geographic consistency ## Task System - Renamed product_resync → product_refresh - Task chaining: store_discovery → entry_point → product_discovery - Priority-based claiming with FOR UPDATE SKIP LOCKED - Heartbeat and stale task recovery ## UI Updates - JobQueue: Pod visualization, resource monitoring on hover - WorkersDashboard: Simplified worker list - Removed unused filters from task list ## Other - IP2Location service for visitor analytics - Findagram consumer features scaffolding - Documentation updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
115 lines
4.3 KiB
Markdown
115 lines
4.3 KiB
Markdown
# Findagram Development Notes
|
|
|
|
## Overview
|
|
|
|
Findagram (findagram.co) is a consumer-facing cannabis product discovery app. Users can search products across dispensaries, set price alerts, and save favorites.
|
|
|
|
## Architecture
|
|
|
|
- **Frontend**: React (Create React App) at `findagram/frontend/`
|
|
- **Backend**: Shared CannaiQ Express API at `backend/`
|
|
- **Auth**: JWT-based consumer auth via `/api/consumer/auth/*`
|
|
- **Domain**: `findagram.co` (passed in all auth requests)
|
|
|
|
## Key Files
|
|
|
|
| File | Purpose |
|
|
|------|---------|
|
|
| `src/context/AuthContext.js` | Global auth state, login/register, token management |
|
|
| `src/components/findagram/AuthModal.jsx` | Login/signup modal popup |
|
|
| `src/api/client.js` | API client for products, dispensaries, categories, brands |
|
|
| `src/api/consumer.js` | API client for favorites, alerts, saved searches (auth required) |
|
|
|
|
## Backend Consumer API Endpoints
|
|
|
|
All require JWT token in `Authorization: Bearer <token>` header.
|
|
|
|
### Auth (`/api/consumer/auth/*`)
|
|
- `POST /register` - Create account (requires `domain: 'findagram.co'`)
|
|
- `POST /login` - Login (requires `domain: 'findagram.co'`)
|
|
- `GET /me` - Get current user
|
|
- `PUT /me` - Update profile
|
|
|
|
### Favorites (`/api/consumer/favorites/*`)
|
|
- `GET /` - Get user's favorites
|
|
- `POST /` - Add favorite (`{ productId, dispensaryId? }`)
|
|
- `DELETE /:id` - Remove by favorite ID
|
|
- `DELETE /product/:productId` - Remove by product ID
|
|
- `GET /check/product/:id` - Check if product is favorited
|
|
|
|
### Alerts (`/api/consumer/alerts/*`)
|
|
- `GET /` - Get user's alerts
|
|
- `POST /` - Create alert (`{ alertType, productId, targetPrice }`)
|
|
- Alert types: `price_drop`, `back_in_stock`, `product_on_special`
|
|
- `PUT /:id` - Update alert
|
|
- `DELETE /:id` - Delete alert
|
|
- `POST /:id/toggle` - Toggle active status
|
|
|
|
### Saved Searches (`/api/consumer/saved-searches/*`)
|
|
- `GET /` - Get user's saved searches
|
|
- `POST /` - Create saved search
|
|
- `PUT /:id` - Update
|
|
- `DELETE /:id` - Delete
|
|
- `POST /:id/run` - Get search params for execution
|
|
|
|
## Database Tables (Consumer)
|
|
|
|
| Table | Purpose |
|
|
|-------|---------|
|
|
| `users` | User accounts (shared across domains via `domain` column) |
|
|
| `findagram_users` | Findagram-specific user profile data |
|
|
| `findagram_favorites` | Product favorites |
|
|
| `findagram_alerts` | Price/stock alerts |
|
|
| `findagram_saved_searches` | Saved search filters |
|
|
|
|
## Auth Flow
|
|
|
|
1. User clicks favorite/alert on a product
|
|
2. If not logged in → AuthModal opens
|
|
3. User logs in or creates account
|
|
4. JWT token stored in localStorage (`findagram_auth`)
|
|
5. Pending action (favorite/alert) executes automatically after auth
|
|
6. All subsequent API calls include `Authorization: Bearer <token>`
|
|
|
|
## Environment Variables
|
|
|
|
```bash
|
|
# Frontend (.env)
|
|
REACT_APP_API_URL=http://localhost:3010 # Local
|
|
REACT_APP_API_URL=https://cannaiq.co # Production
|
|
```
|
|
|
|
## Future: Migration to cannabrands.app
|
|
|
|
Currently uses CannaiQ backend. Later will migrate auth to cannabrands.app:
|
|
- Update `API_BASE_URL` for auth endpoints
|
|
- Keep product/dispensary API pointing to CannaiQ
|
|
- May need to sync user accounts between systems
|
|
|
|
## Important Notes
|
|
|
|
1. **Domain is critical** - All auth requests must include `domain: 'findagram.co'`
|
|
2. **Favorites are product-based** (unlike findadispo which is dispensary-based)
|
|
3. **Price alerts** require `targetPrice` for `price_drop` type
|
|
4. **Mock data** in `src/mockData.js` is no longer imported - can be safely deleted
|
|
5. **Token expiry** is 30 days (`JWT_EXPIRES_IN` in backend)
|
|
|
|
## Pages Using Real API
|
|
|
|
All pages are now wired to the real CannaiQ API:
|
|
|
|
| Page | API Endpoint | Notes |
|
|
|------|--------------|-------|
|
|
| Home | `/api/products`, `/api/dispensaries` | Featured products, deals |
|
|
| Products | `/api/products` | Search, filters, pagination |
|
|
| ProductDetail | `/api/products/:id` | Single product with dispensaries |
|
|
| Deals | `/api/products?hasSpecial=true` | Products on sale |
|
|
| Brands | `/api/brands` | Brand listing |
|
|
| BrandDetail | `/api/brands/:name` | Brand products |
|
|
| Categories | `/api/categories` | Category listing |
|
|
| CategoryDetail | `/api/products?category=...` | Category products |
|
|
| Dashboard | `/api/consumer/favorites`, alerts, searches | User dashboard (auth) |
|
|
| Favorites | `/api/consumer/favorites` | User favorites (auth) |
|
|
| Alerts | `/api/consumer/alerts` | Price alerts (auth) |
|
|
| SavedSearches | `/api/consumer/saved-searches` | Saved searches (auth) |
|