File size: 5,569 Bytes
64d289f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
version: "3.9"

# =============================================================================
# Omnichannel Fact & Hallucination Intelligence System
# HuggingFace Spaces compatible β€” single `docker compose up` deployment
# Services: FastAPI (7860), Qdrant (6333), Memgraph (7687), Redpanda (9092), Redis Stack (6379)
# =============================================================================

networks:
  fact-net:
    driver: bridge

volumes:
  qdrant_storage:
  memgraph_data:
  redpanda_data:
  redis_data:

services:
  # ---------------------------------------------------------------------------
  # QDRANT β€” Vector DB for claim embeddings (self-hosted, sub-ms HNSW search)
  # ---------------------------------------------------------------------------
  qdrant:
    image: qdrant/qdrant:v1.9.2
    container_name: fact-qdrant
    restart: unless-stopped
    networks: [fact-net]
    ports:
      - "6333:6333"
      - "6334:6334"   # gRPC
    volumes:
      - qdrant_storage:/qdrant/storage
    environment:
      QDRANT__SERVICE__GRPC_PORT: 6334
      QDRANT__TELEMETRY_DISABLED: "true"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:6333/readyz"]
      interval: 10s
      timeout: 5s
      retries: 5

  # ---------------------------------------------------------------------------
  # MEMGRAPH β€” In-memory graph DB for trust-score traversal (Cypher compatible)
  # 10-100x faster than Neo4j for real-time traversal since everything is in RAM
  # ---------------------------------------------------------------------------
  memgraph:
    image: memgraph/memgraph-platform:2.16.0
    container_name: fact-memgraph
    restart: unless-stopped
    networks: [fact-net]
    ports:
      - "7687:7687"   # Bolt
      - "3000:3000"   # Memgraph Lab UI
    volumes:
      - memgraph_data:/var/lib/memgraph
    environment:
      MEMGRAPH_USER: memgraph
      MEMGRAPH_PASSWORD: memgraph123
    healthcheck:
      test: ["CMD", "mg_client", "--host", "localhost", "--port", "7687", "--use-ssl=false", "-q", "RETURN 1;"]
      interval: 15s
      timeout: 10s
      retries: 5

  # ---------------------------------------------------------------------------
  # REDPANDA β€” Kafka-compatible message queue (no JVM, no ZooKeeper, 10x lower
  # latency). Handles the omnichannel ingestion firehose from all producers.
  # ---------------------------------------------------------------------------
  redpanda:
    image: redpandadata/redpanda:v24.1.7
    container_name: fact-redpanda
    restart: unless-stopped
    networks: [fact-net]
    ports:
      - "9092:9092"   # Kafka API
      - "9644:9644"   # Admin API
      - "8081:8081"   # Schema registry
    volumes:
      - redpanda_data:/var/lib/redpanda/data
    command:
      - redpanda
      - start
      - --smp=1
      - --memory=512M
      - --overprovisioned
      - --kafka-addr=PLAINTEXT://0.0.0.0:9092
      - --advertise-kafka-addr=PLAINTEXT://redpanda:9092
      - --pandaproxy-addr=0.0.0.0:8082
      - --advertise-pandaproxy-addr=redpanda:8082
      - --schema-registry-addr=0.0.0.0:8081
      - --rpc-addr=redpanda:33145
      - --advertise-rpc-addr=redpanda:33145
    healthcheck:
      test: ["CMD", "rpk", "cluster", "health"]
      interval: 15s
      timeout: 10s
      retries: 5

  # ---------------------------------------------------------------------------
  # REDIS STACK β€” Redis + RedisJSON + RedisSearch for structured claim caching
  # TTL: 6h for Green/Red verdicts, 15min for Yellow, no cache for Purple
  # ---------------------------------------------------------------------------
  redis-stack:
    image: redis/redis-stack:7.4.0-v0
    container_name: fact-redis
    restart: unless-stopped
    networks: [fact-net]
    ports:
      - "6379:6379"   # Redis
      - "8001:8001"   # RedisInsight UI
    volumes:
      - redis_data:/data
    environment:
      REDIS_ARGS: "--maxmemory 256mb --maxmemory-policy allkeys-lru"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  # ---------------------------------------------------------------------------
  # BACKEND β€” FastAPI intelligence engine (HF Spaces listens on 7860)
  # Waits for all upstream services to be healthy before starting
  # ---------------------------------------------------------------------------
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: fact-backend
    restart: unless-stopped
    networks: [fact-net]
    ports:
      - "7860:7860"   # HuggingFace Spaces default port
    depends_on:
      qdrant:
        condition: service_healthy
      memgraph:
        condition: service_healthy
      redpanda:
        condition: service_healthy
      redis-stack:
        condition: service_healthy
    environment:
      # LLM providers β€” set in HF Space secrets
      GROQ_API_KEY: ${GROQ_API_KEY:-}
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
      X_BEARER_TOKEN: ${X_BEARER_TOKEN:-}

      # Infrastructure endpoints (internal Docker network)
      QDRANT_HOST: qdrant
      QDRANT_PORT: 6333
      MEMGRAPH_HOST: memgraph
      MEMGRAPH_PORT: 7687
      MEMGRAPH_PASSWORD: memgraph123
      REDPANDA_BROKERS: redpanda:9092
      REDIS_URL: redis://redis-stack:6379

      # App config
      PORT: 7860
      LOG_LEVEL: INFO
      DEMO_MODE: ${DEMO_MODE:-false}   # true = use mock data, skip external APIs
    volumes:
      - ./backend:/app
    command: ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]