33800 Docs

← Retour

NeedFinder - Documentation technique

Dernière MAJ : 24/01/2026


Localisation

Composant Emplacement
Container needfinder sur prod-portainer (192.168.1.12)
Port 5200
Code source GitLab gouroubleu/needfinder
Database Supabase PROD (postgres, schema needfinder)

Structure base de données

SERVER: supabase-db-prod (prod-portainer)
    │
    └── DATABASE: postgres
            │
            └── SCHEMA: needfinder
                    │
                    ├── sources (2 rows)
                    ├── posts (450+ rows)
                    ├── needs (270+ rows)
                    ├── mentions (270+ rows)
                    └── collection_logs (81+ rows)

Connexion correcte

postgresql://needfinder_service:UK3GlkfwnFZZVAGxScyz5DF6@supabase-db-prod:5432/postgres

Note : Le code utilise SET search_path TO needfinder pour accéder au schema.

Tables

Table PK Description
sources UUID Reddit, HackerNews
posts UUID Posts collectés (Reddit/HN)
needs UUID Besoins détectés par IA
mentions UUID Liens need ↔ post
collection_logs UUID Historique collectes

Historique nettoyage

23/01/2026 - Migration PROD + Nettoyage DEV

Actions effectuées :

Etat actuel : Aucune donnée NeedFinder sur DEV. Tout est sur PROD.


Backup

Backup automatique

Le schema needfinder est inclus dans le backup O2switch (cron toutes les 6h) :

Backup manuel

# Dump schema needfinder depuis PROD
ssh gouroubleu@prod-portainer.local "docker exec supabase-db-prod pg_dump -U postgres postgres --schema=needfinder --inserts" > /stock_8to/backups/needfinder/needfinder_$(date +%Y%m%d_%H%M).sql

Restauration

ssh gouroubleu@prod-portainer.local "docker exec -i supabase-db-prod psql -U postgres" < /stock_8to/backups/needfinder/FICHIER.sql

API Endpoints

Endpoint URL
Health http://192.168.1.12:5200/health
Stats http://192.168.1.12:5200/api/stats
Posts http://192.168.1.12:5200/api/posts
Needs http://192.168.1.12:5200/api/needs
Logs http://192.168.1.12:5200/api/logs
Swagger http://192.168.1.12:5200/swagger

URLs publiques

URL Usage
https://needfinder-api.33800.nowhere84.com API PROD via nginx
https://dashboard.nowhere84.com/needfinder.html Dashboard (données live via API)

Scheduler


Système Webhook Async (24/01/2026)

Architecture

Post → submitAnalysisJobAsync() → AI-Orchestrator (queue)
                                        ↓
                                   Ollama traite
                                        ↓
                              Webhook /api/webhook/analysis
                                        ↓
                              Need créé → submitTranslationJobAsync()
                                        ↓
                              Webhook /api/webhook/translation
                                        ↓
                              need_statement_fr mis à jour

Endpoints Webhook

Endpoint Usage
POST /api/webhook/analysis Reçoit résultats analyse (crée need si has_need=true)
POST /api/webhook/translation Reçoit traduction FR
POST /api/analyze/async?batch=N Soumet N posts en async
POST /api/analyze/all Lance traitement complet (background)
GET /api/analyze/stats Stats pending/submitted/completed/failed

Champ analysis_status

Status Description
pending Pas encore soumis
submitted Job envoyé à l'orchestrator
completed Analyse terminée
failed Erreur d'analyse

Fonctions clés (orchestrator-client.ts)

submitAnalysisJobAsync(postId, prompt, options) → job_id
submitTranslationJobAsync(targetId, targetType, text, field) → job_id

Chaînage automatique

Quand un need est créé, la traduction FR est automatiquement soumise via submitTranslationJobAsync().


Historique des problèmes

Date Problème Cause Resolution
07/01/2026 Perte données décembre Migration vers Proxmox1, volume réinitialisé Recollecte
11/01/2026 Changement architecture Passage postgres.public → needfinder.needfinder Migration schema
20/01/2026 Confusion schéma Retour à needfinder.needfinder Documentation
23/01/2026 Migration PROD DEV → PROD pour backup O2switch Migration + nettoyage DEV
24/01/2026 Dashboard sans données live generate-needfinder.sh pointait sur DEV (.51) Corrigé vers PROD (.12)

Leçons :


Points critiques (NE PAS CASSER)

Fichier Variable Valeur correcte Impact si cassé
generate-needfinder.sh API_URL http://192.168.1.12:5200 Dashboard sans données live
generate-needfinder.sh limit 5000 (pas 200) Stats incorrectes, needs manquants
generate.d/01-index.sh services.needfinder Doit exister dans current.json Widget index cassé

ATTENTION : Après migration PROD, TOUJOURS mettre à jour les scripts de génération dashboard.

ATTENTION : Le fichier services-registry.json peut être créé par root (via cron). Si git add échoue avec "Permission denied", faire : sudo chown gouroubleu:gouroubleu services-registry.json


Convention projets/schemas

Règle : 1 projet = 1 schema dédié

Projet Database Schema
NeedFinder postgres (PROD) needfinder
Notifications postgres (PROD) notifications
QwikPress postgres (PROD) qwikpress
... ... ...

Avantages :


Commandes de vérification

# Vérifier la connexion actuelle du container
ssh gouroubleu@prod-portainer.local "docker exec needfinder env | grep DB"

# Compter les données
ssh gouroubleu@prod-portainer.local "docker exec supabase-db-prod psql -U postgres -d postgres -c \"
SELECT 'posts' as t, count(*) FROM needfinder.posts
UNION ALL SELECT 'needs', count(*) FROM needfinder.needs
UNION ALL SELECT 'mentions', count(*) FROM needfinder.mentions;
\""

# Vérifier le health
curl -s http://192.168.1.12:5200/health | jq

# Vérifier via API publique
curl -s https://needfinder-api.33800.nowhere84.com/api/stats | jq