Ichitux 166e9635a1
Build & Push Docker Images / test-backend (push) Successful in 2m1s
Build & Push Docker Images / test-frontend (push) Successful in 1m52s
Build & Push Docker Images / build-backend (push) Successful in 2m54s
Build & Push Docker Images / build-frontend (push) Successful in 1m13s
Build & Push Docker Images / deploy (push) Successful in 46s
Merge pull request 'feature/profile-redesign' (#12) from feature/profile-redesign into main
Reviewed-on: #12
2026-07-06 23:54:36 +00:00
2026-07-07 01:49:55 +02:00
2026-07-07 01:45:09 +02:00
2026-06-26 16:59:20 +02:00
2026-07-07 01:49:55 +02:00
2026-06-29 13:50:27 +02:00
2026-07-06 16:36:57 +02:00
2026-07-06 15:51:53 +02:00
2026-06-29 11:29:40 +02:00
2026-04-01 01:18:21 +02:00
2026-06-26 16:59:20 +02:00
2026-04-01 01:18:21 +02:00
2026-06-29 13:02:16 +02:00
2026-07-07 01:49:55 +02:00
2026-05-19 18:27:16 +02:00
2026-07-06 16:36:57 +02:00
2026-07-06 15:51:53 +02:00

FarmaFinder

A web application to search for medicines from the official Spanish CIMA database and find which pharmacies sell them.

Features

Web App (Desktop/PWA)

  • Real-time medicine search from CIMA API (Agencia Espanola de Medicamentos)
  • Redis caching for improved performance
  • View pharmacies that sell a specific medicine
  • See prices and stock availability
  • Responsive design for mobile and desktop
  • Admin Panel - Manage pharmacies and link medicines
    • Secure authentication - Login required to access admin features
    • Add, edit, and delete pharmacies
    • Search medicines from CIMA database
    • Link medicines to pharmacies with prices and stock

Mobile App (React Native)

  • Native iOS/Android experience with Expo
  • Medicine search with real-time results
  • Interactive map with pharmacy markers
  • Barcode scanner for quick medicine lookup
  • Push notifications for availability alerts
  • Biometric authentication (Face ID / Touch ID)
  • Offline cache for favorite medicines

Tech Stack

App Stack
Backend Node.js + Express, SQLite, Redis
Frontend (Web) React + Vite, Capacitor
Frontend (Mobile) Expo SDK 57 + React Native, Zustand, Axios + TanStack Query
Build system Turborepo
Package manager npm workspaces

Prerequisites

  • Node.js v20+
  • npm v9+
  • Redis server v6.0+ (or use Docker)
  • Docker + Docker Compose v2 (optional, for containerized deployment)

Project Structure

This is a Turborepo monorepo. All applications live under apps/:

FarmaFinder/
├── package.json              # Root: workspaces + turbo scripts
├── turbo.json                # Turborepo task configuration
├── docker-compose.yml        # Full stack: backend + frontend + Redis + Postgres
│
├── apps/
│   ├── backend/              # Node.js + Express API
│   │   ├── Dockerfile
│   │   ├── server.js         # Express server and API routes
│   │   ├── cima-service.js   # CIMA API integration with Redis cache
│   │   ├── redis-client.js   # Redis connection configuration
│   │   ├── seed.js           # Database seeding script
│   │   ├── create-admin.js   # Admin user creation script
│   │   └── package.json
│   │
│   ├── frontend/             # React + Vite (Desktop/PWA)
│   │   ├── Dockerfile
│   │   ├── nginx.conf        # Nginx config for Docker
│   │   ├── src/
│   │   │   ├── components/   # React components
│   │   │   ├── views/        # View components (Public/Admin)
│   │   │   ├── App.jsx
│   │   │   └── main.jsx
│   │   └── package.json
│   │
│   ├── frontend-mobile/      # Expo + React Native (iOS/Android)
│   │   ├── app/              # Expo Router screens
│   │   ├── components/
│   │   ├── services/
│   │   ├── store/
│   │   └── package.json
│   │
│   ├── scraper/              # Puppeteer scraper (standalone)
│   │   └── package.json
│   │
│   └── pip-platform/         # Python FastAPI platform (separate docker-compose)
│       ├── Dockerfile
│       ├── docker-compose.yml
│       └── pyproject.toml
│
├── API/                      # Shared API source files
├── scripts/                  # Build/utility scripts
└── docs/                     # Documentation

Quick Start

Install dependencies

npm install

This installs all workspace dependencies (backend, frontend, mobile, scraper) via npm workspaces.

Development

# Start everything (backend + frontend)
npm run dev

# Start only backend
npm run dev:backend

# Start only frontend
npm run dev:frontend

# Start mobile app
npx turbo run dev --filter=frontend-mobile

Build

# Build all apps
npm run build

# Build only frontend
npm run build:web

Test

# Run all tests
npm test

# Test specific app
npm test --workspace=farma-clic-backend
npm test --workspace=farma-clic-frontend

Docker Setup

Runs the full stack (backend, frontend, Redis, Postgres) with a single command.

# Copy and configure environment (optional - defaults work for local dev)
cp apps/backend/.env.example apps/backend/.env

docker compose up --build

App available at http://localhost:4000 (frontend) and http://localhost:3001 (backend API).

First run - create an admin user:

docker compose exec backend node create-admin.js
# Default: admin / admin123 - change after first login

Seed sample pharmacies:

docker compose exec backend node seed.js

Stop:

docker compose down

Database is persisted in named Docker volumes (backend_data, postgres_data). To wipe:

docker compose down -v

Manual Setup

1. Install Redis

Ubuntu/Debian:

sudo apt-get install redis-server
sudo systemctl start redis-server

macOS:

brew install redis
brew services start redis

Docker:

docker run -d -p 6379:6379 redis:alpine

Verify: redis-cli ping should respond PONG.

2. Configure Environment (Optional)

Create apps/backend/.env:

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
SESSION_SECRET=your-secret-key-here

3. Initialize Database

# Seed sample pharmacies
npm run dev --workspace=farma-clic-backend -- run seed

# Create admin user (default: admin / admin123)
npm run dev --workspace=farma-clic-backend -- run create-admin

4. Run

npm run dev

API Endpoints

Public

  • GET /api/medicines/search?q=<query> - Search medicines (CIMA API, cached in Redis)
  • GET /api/medicines/:nregistro - Medicine details
  • GET /api/medicines/:nregistro/pharmacies - Pharmacies selling a medicine
  • GET /api/pharmacies - All pharmacies

Auth

  • POST /api/auth/login - Login
  • POST /api/auth/logout - Logout
  • GET /api/auth/check - Check auth status

Admin (requires authentication)

  • POST /api/admin/pharmacies - Add pharmacy
  • PUT /api/admin/pharmacies/:id - Update pharmacy
  • DELETE /api/admin/pharmacies/:id - Delete pharmacy
  • GET /api/admin/medicines?q=<query> - Search medicines
  • GET /api/admin/pharmacies/:id/medicines - Linked medicines
  • POST /api/admin/pharmacy-medicines - Link medicine to pharmacy
  • PUT /api/admin/pharmacy-medicines/:id - Update price/stock
  • DELETE /api/admin/pharmacy-medicines/:id - Remove link

Database Schema

SQLite Tables

pharmacies: id, name, address, phone, latitude, longitude

pharmacy_medicines: id, pharmacy_id, medicine_nregistro, medicine_name, price, stock

users: id, username, password_hash, created_at

Redis Cache

  • medicines:search:{query} - Search results (TTL: 1h)
  • medicine:{nregistro} - Medicine details (TTL: 24h)

Mobile App Setup

Prerequisites

  • Node.js v20+
  • Expo CLI: npm install -g expo-cli
  • EAS CLI: npm install -g eas-cli
  • iOS: Xcode + CocoaPods (Mac only)
  • Android: Android Studio + SDK

Development

# Install dependencies (already done via npm install at root)

# Start mobile dev server
npx turbo run dev --filter=frontend-mobile

# Scan QR code with Expo Go app

Native Features

Feature Implementation
Barcode Scanner expo-camera with CameraView
Push Notifications expo-notifications
Biometrics expo-local-authentication
Maps react-native-maps
Secure Storage expo-secure-store

EAS Build

cd apps/frontend-mobile

# Development build
eas build --profile development --platform ios
eas build --profile development --platform android

# Production build
eas build --profile production --platform android
eas build --profile production --platform ios

# Submit to stores
eas submit --profile production --platform android
eas submit --profile production --platform ios

Environment Configuration

// apps/frontend-mobile/constants/config.ts
const ENV = {
  development: { API_BASE_URL: 'http://localhost:3001/api' },
  production: { API_BASE_URL: 'https://your-production-api.com/api' },
};

Troubleshooting

Redis Connection Issues

redis-cli ping          # Should respond: PONG
redis-server            # Start if not running
redis-cli FLUSHALL      # Clear cache

CIMA API Timeout

  • Check internet connection
  • CIMA API may be temporarily unavailable
  • App falls back to cached data

Database Reset

cd apps/backend
rm database.sqlite
npm run seed
npm run create-admin

Turborepo Cache Issues

npx turbo clean         # Clear Turbo cache
rm -rf node_modules     # Full reset
npm install

External Resources

License

ISC

S
Description
No description provided
Readme 14 MiB
Languages
JavaScript 39.8%
Python 32.6%
TypeScript 16.9%
CSS 8.5%
HTML 1.8%
Other 0.3%