Commit Graph

285 Commits

Author SHA1 Message Date
Antoni Nuñez Romeu de8fdbb904 feat: add sort by distance and directions to ProductView
Run Tests on Branches / Detect Changes (push) Successful in 13s
Run Tests on Branches / Backend Tests (push) Failing after 17s
Run Tests on Branches / Frontend Tests (push) Failing after 16s
Run Tests on Branches / Frontend Mobile Tests (push) Failing after 18s
Run Tests on Branches / Parapharmacy API Tests (push) Has been skipped
- Added sort by distance functionality (same as SearchView)
- Added PharmacyList component with distance display
- Added 'Cómo llegar' button in map popup (Google Maps directions)
- Uses haversineKm for distance calculation
2026-07-16 16:55:48 +02:00
Antoni Nuñez Romeu 6155fdcd15 fix: add pharmacy map to ProductView and fix pharmacies endpoint
- Added PharmacyMap component to ProductView
- Updated backend to accept all valid sources for pharmacies endpoint
- Shows map with pharmacy locations and list of pharmacies with prices
2026-07-16 16:48:25 +02:00
Antoni Nuñez Romeu 08b7437803 fix: add 'seed' and 'manual' to valid product sources
Products created via seed script or manual entry have source='seed'
or 'manual', which wasn't in the valid sources list.
2026-07-16 16:40:41 +02:00
Antoni Nuñez Romeu 26e7d92079 fix: handle both array and object responses in admin search
The CIMA search API returns {results: [...]} but the admin panel
was treating it as an array, causing CIMA products to be lost.

Now handles both formats:
- Array: [...]
- Object: {results: [...]}
2026-07-16 16:32:24 +02:00
Antoni Nuñez Romeu dca7e373cd fix: use parapharmacy endpoint for all non-CIMA sources
- ProductView now checks if source is 'cima' to decide endpoint
- All other sources (seed, promofarma, docmorris, primor) use parapharmacy endpoint
- Same fix applied to mobile getProduct function

Before: only 'parapharmacy' source used parapharmacy endpoint
After: all non-CIMA sources use parapharmacy endpoint
2026-07-16 16:23:57 +02:00
Antoni Nuñez Romeu 63b25e3f4f fix: use _id for MongoDB products in frontend
- SearchView now uses p._id || p.id for product navigation
- ProductResults uses product._id || product.id for React key
- Fixes 'undefined' error when clicking parapharmacy products
2026-07-16 16:18:22 +02:00
Antoni Nuñez Romeu e5dcfbd2f5 fix: allow parapharmacy sources in pharmacy-products endpoint
Updated validation to accept: cima, promofarma, docmorris, primor, parapharmacy

Before: product_source must be 'cima'
After: product_source must be one of: cima, promofarma, docmorris, primor, parapharmacy
2026-07-16 16:02:25 +02:00
Antoni Nuñez Romeu 3666f4dee8 fix: update ProductResults and admin panel for parapharmacy
- Updated ProductResults component with new source labels
- Added price display for parapharmacy products
- Updated admin panel to search both CIMA and Parapharmacy
- Updated getSourceBadge to handle parapharmacy sources
- Added CSS for product price display
2026-07-16 15:58:35 +02:00
Antoni Nuñez Romeu 3429b7e548 fix: product detail view for parapharmacy products
- Updated ProductView to use correct endpoint for parapharmacy
- Updated getProduct service to handle parapharmacy products
- Shows price, category, brand, source for parapharmacy products
- Updated labels from 'OFF' to 'Parafarmacia'
2026-07-16 15:47:14 +02:00
Antoni Nuñez Romeu 570d4ab43e feat: unified search - remove filter tabs, show all results together
- Frontend now searches both CIMA and Parapharmacy simultaneously
- Removed filter tabs (Todos/Medicamentos/Parafarmacia)
- Results show in a single unified list
- Mobile: Shows medicines first, then parapharmacy section
- Web: Same unified approach with results summary
2026-07-16 15:36:08 +02:00
Antoni Nuñez Romeu 05b99e9ed4 feat: working scraping for Promofarma, DocMorris, and Primor
- Fixed Primor URL format and selectors
- Created simple N8N webhook that calls scraper API
- All 3 sources now working:
  - Promofarma: 20 products
  - DocMorris: 10 products
  - Primor: 20 products
- Total: 130 products in database
- N8N webhook at /webhook/scrape working correctly
2026-07-16 15:19:07 +02:00
Antoni Nuñez Romeu 972a59662d fix: fix parapharmacy proxy route order and add axios import
- Moved parapharmacy routes before :source/:id routes to prevent conflicts
- Added axios import to server.js
- Backend proxy now correctly forwards to parapharmacy-api
- Tested: search for 'capricare' returns 1 result, 'crema' returns 7 results
2026-07-16 15:03:46 +02:00
Antoni Nuñez Romeu a5a75d3249 feat: working Puppeteer scraper for Promofarma
- Added Puppeteer with Chrome in Docker
- Scraper extracts products using data attributes
- Added /api/scrape endpoint
- Tested: 10 products scraped from Promofarma

The scraper now works with Promofarma's HTML structure which uses
data-name, data-pvp attributes on article elements.
2026-07-16 14:54:51 +02:00
Antoni Nuñez Romeu 2ad4210221 feat: add scrape script and fix N8N webhook workflow
- Add direct scrape.js script for testing
- Fix N8N webhook workflow (lastNode response mode)
- Note: Real scraping requires Puppeteer for anti-bot sites
2026-07-16 13:14:56 +02:00
Antoni Nuñez Romeu e2dd3474a4 fix: add 'seed' and 'manual' to Product source enum
Allows seed script and manual product creation to work.
2026-07-16 13:06:17 +02:00
Antoni Nuñez Romeu 30f97fe87d feat: complete N8N scrapers for 6 sources and seed script
- Create comprehensive N8N workflow for all 6 parapharmacy sources
- Create webhook-triggered manual scraping workflow
- Add seed script with 20 sample products
- Update n8n/README.md with complete documentation
- Update docs/parapharmacy.md with seeding instructions
- Add seed script to package.json

Sources configured:
- Promofarma
- Pharmarket
- DocMorris
- 1001Farma
- Primor
- MiFarma
2026-07-16 13:00:20 +02:00
Antoni Nuñez Romeu cb564fb170 docs: add comprehensive parapharmacy and N8N documentation
- Create docs/parapharmacy.md with full API, N8N, and setup documentation
- Update README.md with parapharmacy system overview and links
- Add project structure for parapharmacy-api and n8n
- Update Docker setup section with all services
- Add API endpoints for parapharmacy
- Add N8N workflow automation section
2026-07-16 12:51:48 +02:00
Antoni Nuñez Romeu 52ddb9c21c chore: add .env.example with all environment variables 2026-07-16 12:47:04 +02:00
Antoni Nuñez Romeu 1c70f0a914 feat: add N8N workflows and auto-setup configuration
- Add parapharmacy-scraper workflow (scheduled every 3 days)
- Add parapharmacy-manual-scraper workflow (webhook triggered)
- Configure N8N to auto-create owner account (skips /setup)
- Add N8N environment variables to docker-compose.yml
- Add README with setup and usage instructions
2026-07-16 12:46:20 +02:00
Antoni Nuñez Romeu 0c2f1cf928 fix: use npm install instead of npm ci in Dockerfile
npm ci requires package-lock.json which is at root level in monorepo.
npm install works without it.
2026-07-16 12:40:22 +02:00
Antoni Nuñez Romeu c509253764 fix: correct Dockerfile build context for parapharmacy-api
Changed build context from '.' to './apps/parapharmacy-api' so the
Dockerfile can find the src/ directory.
2026-07-16 12:37:54 +02:00
Antoni Nuñez Romeu 7274979f62 chore: remove Open Food Facts (OFF) integration
- Remove off-service.js and off-service.test.js
- Remove OFF import from server.js
- Simplify /api/products/search to only use CIMA
- Remove 'openfoodfacts' from valid product sources
- Update frontend-mobile Product interface to remove OFF source
- Remove OFF env vars from .env.example
- Add PARAPHARMACY_API_URL to .env.example

OFF was replaced by the new parapharmacy-api microservice.
2026-07-16 12:34:08 +02:00
Antoni Nuñez Romeu b34657c78f feat: add parapharmacy API with MongoDB and N8N setup
- Create parapharmacy-api microservice with Express + Swagger + MongoDB
- Add product model with full-text search and deduplication
- Add CRUD endpoints and bulk upsert for scrapers
- Update docker-compose.yml with MongoDB, N8N, and parapharmacy-api services
- Add proxy endpoints in FarmaFinder backend for parapharmacy
- Update frontend services to use parapharmacy API
- Add Swagger documentation at /api/docs
2026-07-16 12:26:54 +02:00
Ichitux 837f2cd4f3 Merge pull request 'feat/parapharmacy-baby-products' (#31) from feat/parapharmacy-baby-products into main
Build & Push Docker Images / Detect Changes (push) Successful in 10s
Build & Push Docker Images / Backend Tests (push) Successful in 1m44s
Build & Push Docker Images / Frontend Tests (push) Successful in 1m43s
Build & Push Docker Images / Build Backend (push) Successful in 32s
Build & Push Docker Images / Build Frontend (push) Successful in 48s
Build & Push Docker Images / Deploy (push) Successful in 29s
Reviewed-on: #31
2026-07-16 08:54:57 +00:00
Antoni Nuñez Romeu 5aadc096d1 fix: add ok: true to fetch mocks in SearchView tests
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Backend Tests (push) Successful in 1m37s
Run Tests on Branches / Frontend Tests (push) Successful in 1m41s
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
2026-07-16 10:51:01 +02:00
Antoni Nuñez Romeu a85fd6cd05 Merge origin/main into feat/parapharmacy-baby-products - resolve conflicts keeping feature branch improvements
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Backend Tests (push) Successful in 1m37s
Run Tests on Branches / Frontend Tests (push) Failing after 1m41s
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
2026-07-16 10:29:02 +02:00
Ichitux 1180599260 Background fixes & improvements
Run Tests on Branches / Detect Changes (push) Successful in 16s
Run Tests on Branches / Backend Tests (push) Successful in 1m53s
Run Tests on Branches / Frontend Tests (push) Failing after 1m57s
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m44s
2026-07-16 10:13:25 +02:00
Antoni Nuñez Romeu f88c9db0a2 fix: regenerate backend package-lock.json — sync OTel dependencies 2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu 562201869a Fixed backend test 2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu 8245abd313 fix: skip Redis connection in test mode — prevents CI hang
The top-level await redisClient.connect() in redis-client.js was
blocking module import when no Redis server is available (CI env).
Add NODE_ENV guard + reconnect strategy with max retries.
2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu a73ef4d422 fix(backend): use string resource attribute keys instead of semantic-conventions named exports
The resolved @opentelemetry/semantic-conventions version in CI does not
export ATTR_SERVICE_NAMESPACE/ATTR_SERVICE_NAME as named exports, breaking
the backend test import. Use plain 'service.name'/'service.namespace'
string keys so the code is independent of the semantic-conventions version.
2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu c165359fd9 Package json outdated 2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu 295e5cd8fb feat: add end-to-end observability (metrics, health, mobile RUM, dashboards, alerts)
- Backend: OTel metrics via OTLP -> Alloy -> Prometheus (OTEL_METRICS_EXPORTER=otlp)
- New business metrics (src/metrics.js): searches, CIMA latency/errors, cache
  hits/misses, logins, rate-limits, pharmacy writes/links, push sent/failed,
  DB + Redis timings/errors, HTTP req count/duration, heartbeat
- Backend health endpoints /healthz and /readyz
- Mobile (Expo): Grafana Faro RUM via @grafana/faro-react-native
- redis/postgres exporters in docker-compose + Prometheus scrape jobs
- Grafana dashboards (backend, datastores, mobile RUM, overview)
- Prometheus alert rules (farmafinder_*) -> existing Alertmanager (Telegram)
- Design/spec saved to docs/superpowers/specs/
2026-07-16 10:13:04 +02:00
Antoni Nuñez Romeu d66a9184aa fix: skip Redis connection in test mode — prevents CI hang
The top-level await redisClient.connect() in redis-client.js was
blocking module import when no Redis server is available (CI env).
Add NODE_ENV guard + reconnect strategy with max retries.
2026-07-16 10:12:37 +02:00
Antoni Nuñez Romeu 3bfc0524d5 ci: optimize test performance — from ~3h to 3.5s
- Lazy-load tesseract.js only in OCR route (skips 30MB WASM download)
- Conditional tracing.js import (skip OTel gRPC in test mode)
- Remove unused barcode-detector import
- Add testTimeout/openHandlesTimeout to jest.config.js
- Add --forceExitTimeout=30000 to test script
- Split CI test jobs into parallel workflows (backend/frontend/mobile)
- Add timeout-minutes: 15 to all test jobs
- Use npm ci --ignore-scripts + selective native rebuild
2026-07-16 10:12:37 +02:00
Antoni Nuñez Romeu d3e4b0e05a ci: consolidate test jobs into single workflow with npm caching
- Merge 3 parallel test jobs (backend/frontend/mobile) into one sequential job
- Remove dependency on dorny/paths-filter@v3 (replaced with git diff script)
- Add npm cache via setup-node to speed up dependency installation
- Downgrade Node.js from 24 to 22 LTS for stability
- Reduce checkout fetch-depth from full history to 2 commits
2026-07-16 10:12:37 +02:00
Antoni Nuñez Romeu 3a082877dd fix: add missing mocks for off-service.js and searchOTC in backend tests
The backend test was hanging in CI because server.js imports off-service.js
which pulls in redis-client.js. Without a mock, it tries to connect to Redis
at import time, hanging indefinitely in CI where no Redis server exists.

Also added the missing searchOTC mock for cima-service.js to fix the
SyntaxError from the export mismatch.
2026-07-16 10:12:37 +02:00
Ichitux 6aec9c52d0 Actualizar .gitea/workflows/test-branches.yaml 2026-07-16 09:56:56 +02:00
Ichitux 5c782dede7 Merge pull request 'Background fixes & improvements' (#37) from mobile_app_hotfixes into main
Build & Push Docker Images / Detect Changes (push) Successful in 12s
Build & Push Docker Images / Backend Tests (push) Has been skipped
Build & Push Docker Images / Frontend Tests (push) Has been skipped
Build & Push Docker Images / Build Backend (push) Has been skipped
Build & Push Docker Images / Build Frontend (push) Has been skipped
Build & Push Docker Images / Deploy (push) Has been skipped
Reviewed-on: #37
2026-07-14 17:56:19 +00:00
Ichitux ff387e3d20 Background fixes & improvements
Run Tests on Branches / Detect Changes (push) Successful in 14s
Run Tests on Branches / Backend Tests (push) Has been skipped
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m52s
2026-07-14 19:52:55 +02:00
Ichitux 58c1fb5bb6 Merge pull request 'fix: regenerate backend package-lock.json — sync OTel dependencies' (#36) from fix/backend-lockfile-sync into main
Build & Push Docker Images / Frontend Tests (push) Has been skipped
Build & Push Docker Images / Detect Changes (push) Successful in 11s
Build & Push Docker Images / Backend Tests (push) Successful in 1m36s
Build & Push Docker Images / Build Backend (push) Successful in 3m7s
Build & Push Docker Images / Build Frontend (push) Has been skipped
Build & Push Docker Images / Deploy (push) Successful in 1m5s
Reviewed-on: #36
2026-07-14 12:21:47 +00:00
Antoni Nuñez Romeu e83f32324f fix: regenerate backend package-lock.json — sync OTel dependencies
Run Tests on Branches / Backend Tests (push) Successful in 1m37s
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
Run Tests on Branches / Detect Changes (push) Successful in 12s
2026-07-14 14:16:57 +02:00
Antoni Nuñez Romeu 59f81c9203 Merge branch 'feat/observability-metrics-monitoring'
Build & Push Docker Images / Detect Changes (push) Successful in 11s
Build & Push Docker Images / Frontend Tests (push) Has been skipped
Build & Push Docker Images / Backend Tests (push) Successful in 1m38s
Build & Push Docker Images / Build Backend (push) Failing after 35s
Build & Push Docker Images / Build Frontend (push) Has been skipped
Build & Push Docker Images / Deploy (push) Has been skipped
2026-07-14 13:44:07 +02:00
Antoni Nuñez Romeu 809d4b8a7f Fixed backend test
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m34s
Run Tests on Branches / Backend Tests (push) Successful in 1m36s
2026-07-14 13:38:16 +02:00
Antoni Nuñez Romeu e281bd4fa8 fix: skip Redis connection in test mode — prevents CI hang
Run Tests on Branches / Frontend Mobile Tests (push) Successful in 1m58s
Run Tests on Branches / Detect Changes (push) Successful in 12s
Run Tests on Branches / Backend Tests (push) Failing after 1m58s
Run Tests on Branches / Frontend Tests (push) Has been skipped
The top-level await redisClient.connect() in redis-client.js was
blocking module import when no Redis server is available (CI env).
Add NODE_ENV guard + reconnect strategy with max retries.
2026-07-14 13:25:17 +02:00
Antoni Nuñez Romeu 52b5b72cfb ci: optimize test performance — from ~3h to 3.5s
- Lazy-load tesseract.js only in OCR route (skips 30MB WASM download)
- Conditional tracing.js import (skip OTel gRPC in test mode)
- Remove unused barcode-detector import
- Add testTimeout/openHandlesTimeout to jest.config.js
- Add --forceExitTimeout=30000 to test script
- Split CI test jobs into parallel workflows (backend/frontend/mobile)
- Add timeout-minutes: 15 to all test jobs
- Use npm ci --ignore-scripts + selective native rebuild
2026-07-14 13:24:19 +02:00
Ichitux 89cb8ee2fb Merge pull request 'ci: optimize test performance — from ~3h to 3.5s' (#35) from ci/optimize-test-performance into main
Build & Push Docker Images / Detect Changes (push) Successful in 12s
Build & Push Docker Images / Backend Tests (push) Successful in 1m36s
Build & Push Docker Images / Frontend Tests (push) Has been skipped
Build & Push Docker Images / Build Backend (push) Successful in 3m9s
Build & Push Docker Images / Build Frontend (push) Has been skipped
Build & Push Docker Images / Deploy (push) Successful in 1m2s
Reviewed-on: #35
2026-07-14 11:08:41 +00:00
Antoni Nuñez Romeu bd7fe56330 fix: skip Redis connection in test mode — prevents CI hang
Run Tests on Branches / Detect Changes (push) Successful in 13s
Run Tests on Branches / Backend Tests (push) Successful in 2m9s
Run Tests on Branches / Frontend Tests (push) Has been skipped
Run Tests on Branches / Frontend Mobile Tests (push) Has been skipped
The top-level await redisClient.connect() in redis-client.js was
blocking module import when no Redis server is available (CI env).
Add NODE_ENV guard + reconnect strategy with max retries.
2026-07-14 13:03:46 +02:00
Antoni Nuñez Romeu e3db56715b ci: optimize test performance — from ~3h to 3.5s
Run Tests on Branches / Detect Changes (push) Successful in 13s
Run Tests on Branches / Frontend Tests (push) Has been cancelled
Run Tests on Branches / Frontend Mobile Tests (push) Has been cancelled
Run Tests on Branches / Backend Tests (push) Has been cancelled
- Lazy-load tesseract.js only in OCR route (skips 30MB WASM download)
- Conditional tracing.js import (skip OTel gRPC in test mode)
- Remove unused barcode-detector import
- Add testTimeout/openHandlesTimeout to jest.config.js
- Add --forceExitTimeout=30000 to test script
- Split CI test jobs into parallel workflows (backend/frontend/mobile)
- Add timeout-minutes: 15 to all test jobs
- Use npm ci --ignore-scripts + selective native rebuild
2026-07-14 12:42:02 +02:00
Ichitux 84bf5f3f79 Merge branch 'main' into feat/observability-metrics-monitoring
Run Tests on Branches / Run Tests (push) Failing after 3h11m0s
2026-07-13 23:08:19 +00:00