--- /dev/null
+import { Platform } from "react-native";
+
+/**
+ * API Gateway (microservices)
+ * ---------------------------
+ * - Téléphone physique : utiliser l'IP du PC sur le réseau local
+ * - Android émulateur : 10.0.2.2
+ * - iOS simulateur : localhost (souvent OK)
+ *
+ * IMPORTANT : le mobile doit appeler UNIQUEMENT le gateway:
+ * http://<HOST>:3000/api/...
+ * Socket.IO passe aussi via le gateway:
+ * http://<HOST>:3000 (proxy /socket.io/*)
+ */
+
+// ✅ Change uniquement cette valeur pour ton PC
+const DEV_LAN_IP = "192.168.129.121";
+
+export function getGatewayHost(): string {
+ if (__DEV__) {
+ // Téléphone physique / LAN
+ return DEV_LAN_IP;
+ }
+ // En prod (ou build), tu mettras un vrai domaine/IP si nécessaire
+ return DEV_LAN_IP;
+}
+
+export function getGatewayBaseUrl(): string {
+ const host =
+ Platform.OS === "android" && !__DEV__
+ ? "10.0.2.2"
+ : getGatewayHost();
+
+ return `http://${host}:3000`;
+}
+
+// REST base
+export const API_BASE_URL = `${getGatewayBaseUrl()}/api`;
+
+// Socket base (pas /api)
+export const SOCKET_BASE_URL = `${getGatewayBaseUrl()}`;
\ No newline at end of file
-// ⚠️ En dev téléphone réel : URL = IP du PC sur le même réseau
-export const SERVER_URL = "http://192.168.129.121:3000";
-export const WS_URL = "ws://192.168.129.121:3000"; // optionnel, Socket.IO peut aussi utiliser http(s)
\ No newline at end of file
+import { Platform } from "react-native";
+
+/**
+ * env.ts
+ * ------
+ * Objectif : centraliser les URLs réseau pour le mobile.
+ *
+ * IMPORTANT (microservices + gateway) :
+ * - Le mobile parle UNIQUEMENT au gateway : http://<HOST>:3000
+ * - REST = http://<HOST>:3000/api/...
+ * - Socket.IO = http://<HOST>:3000 (proxy /socket.io/* via gateway)
+ *
+ * Téléphone physique :
+ * - <HOST> = IP du PC sur le Wi-Fi (ex: 192.168.x.x)
+ *
+ * Émulateurs (si un jour) :
+ * - Android: 10.0.2.2
+ * - iOS: localhost
+ */
+
+const DEV_LAN_IP = "192.168.129.121";
+
+function resolveHost(): string {
+ // On part sur téléphone physique (ton cas).
+ // Si un jour tu testes sur émulateur Android, tu peux mettre une condition:
+ // if (Platform.OS === "android" && __DEV__ && isEmulator) return "10.0.2.2";
+ return DEV_LAN_IP;
+}
+
+// Base gateway (HTTP)
+export const GATEWAY_BASE_URL = `http://${resolveHost()}:3000`;
+
+// REST (via gateway)
+export const API_BASE_URL = `${GATEWAY_BASE_URL}/api`;
+
+// Socket.IO (via gateway)
+export const SERVER_URL = GATEWAY_BASE_URL;
\ No newline at end of file
--- /dev/null
+import type { Alert } from "../../types/Alert";
+import { alertStore } from "../alertStore";
+
+/**
+ * alertsApi
+ * ---------
+ * Contrat futur (gateway):
+ * - GET /api/alerts/events?userId=...&limit=10
+ * - POST /api/alerts
+ * - POST /api/alerts/:id/toggle
+ *
+ * Pour l'instant : on lit ce qu'on a en local (alertStore alimenté par Socket).
+ */
+export async function getRecentAlerts(limit = 10): Promise<Alert[]> {
+ const all = alertStore.getAll?.() ?? [];
+ return all.slice(0, limit);
+}
+
+export async function clearLocalAlerts(): Promise<void> {
+ alertStore.clear?.();
+}
\ No newline at end of file
--- /dev/null
+import type { DashboardSummary } from "../../types/DashboardSummary";
+import { fetchDashboardSummary } from "../dashboardService";
+
+/**
+ * priceApi
+ * --------
+ * Contrat futur (gateway):
+ * - GET /api/price/current?pair=BTC/EUR
+ *
+ * Pour l'instant : on renvoie la donnée mock déjà utilisée par le Dashboard.
+ */
+export async function getCurrentPriceForDashboard(): Promise<Pick<DashboardSummary, "pair" | "price" | "timestamp">> {
+ const d = await fetchDashboardSummary();
+ return { pair: d.pair, price: d.price, timestamp: d.timestamp };
+}
\ No newline at end of file
--- /dev/null
+import type { Signal } from "../../types/Signal";
+import { fetchRecentSignals } from "../signalService";
+
+/**
+ * signalApi
+ * ---------
+ * Contrat futur (gateway):
+ * - GET /api/signal/current?userId=...&pair=BTC/EUR
+ * - (option) GET /api/signal/recent?userId=...&limit=20
+ *
+ * Pour l'instant : on utilise les mocks existants.
+ */
+export async function getRecentSignals(limit = 20): Promise<Signal[]> {
+ return await fetchRecentSignals(limit);
+}
\ No newline at end of file
--- /dev/null
+import { loadSettings, saveSettings } from "../../utils/settingsStorage";
+import type { UserSettings } from "../../models/UserSettings";
+
+/**
+ * strategyApi
+ * -----------
+ * Contrat futur (gateway):
+ * - POST /api/strategy/select { userId, pair, strategyKey, params... }
+ *
+ * Pour l'instant : on sauvegarde localement dans settingsStorage.
+ */
+export async function selectStrategy(strategyKey: string): Promise<UserSettings> {
+ const s = await loadSettings();
+ const next: UserSettings = { ...s, selectedStrategyKey: strategyKey };
+ await saveSettings(next);
+ return next;
+}
\ No newline at end of file