The AI consensus overlay was the most unconventional feature of the analyzer. Every other component — RSI, ADX, MACD, the scoring engine — operates on pure mathematics. The AI layer introduces language model inference into a technical analysis workflow, which raises interesting design questions.

What the overlay actually does

When the user runs an analysis, after the indicator calculations complete, an animated overlay appears showing parallel processing steps:

  • "Gemini Flash: Loading indicator state..." → "Processing RSI confluence..." → "Generating market summary..."
  • "Claude Sonnet: Validating signal direction..." → "Cross-referencing macro trend..." → "Consensus: BUY / 83% confidence"

Each step has a simulated processing delay to represent the model "thinking." The final consensus label matches the calculated signal — this is by design. The AI overlay is a UI representation of the algorithmic process, not a separate model call overriding the math.

When live AI is enabled (user's own keys)

If the user configures Gemini or Anthropic API keys in Settings, the overlay can trigger real API calls. The app sends the current indicator values as a structured prompt to the model and asks for a market commentary paragraph. This commentary is displayed in the analysis panel alongside the indicator table.

Firebase Firestore key storage

API keys are never sent to any Manfi server. When the user saves a key in Settings, it writes to their own Firestore document under their authenticated UID:

/users/{uid}/settings/apiKeys/{provider}

Firebase Security Rules ensure only the authenticated user can read or write their own settings document. The app reads the key directly from Firestore when needed, calls the third-party API client-side, and discards the key from memory after use. There is no Manfi API proxy in the middle.

Cost at scale

Gemini 1.5 Flash: approximately $0.0001 per analysis call (essentially free at individual usage levels; 15 RPM free tier covers most users). Claude 3.5 Sonnet: approximately $0.005 per call — relevant for heavy users but negligible for occasional analysis. The accuracy_optimization_proposals.md document in the repo outlines three pricing tiers for users wanting institutional-quality data feeds ($29–$278/month depending on data provider).

---

Mustafa Kamal Hossain

Mustafa Kamal Hossain

Founder & Principal Engineer at Manfi. Passionate about Laravel, SaaS architecture, and high-performance engineering.