What It Does

Black Bull Studio unites three workflows that Web3 creators and traders usually juggle across separate tools: a social community feed, a trading terminal (covering token mints and tokenized equities), and a creator studio, all enhanced with a Hybrid AI assistant (On-device via Gemini Nano when available, with automatic Cloud fallback protected by Firebase App Check).

Inspiration

When integrating AI into a real-time social and market platform, sending every single prompt to a remote cloud model creates avoidable trade-offs:

  • Latency & cost on lightweight creative tasks like drafting posts, writing bios, or refining studio prompts.
  • Privacy & responsiveness when creators iterate quickly on ideas.
  • Reliability & tool access when users ask for live token trends, liquidity checks, or deeper market context.

The Firebase AI Logic Hybrid Inference SDK gave us a clean way to pair local Gemini Nano on-device inference (when supported) with automatic Cloud AI fallback protected by Firebase App Check—giving users fast local execution for light tasks without sacrificing cloud intelligence for heavy or tool-driven workflows.

How We Built It

Black Bull Studio runs on a Firebase-centric stack (black-bull-studio-68c90) with Firebase Authentication, Firebase App Check, and the Firebase AI Logic Hybrid Inference SDK wired into our application architecture:

  • Central Hybrid AI Engine (lib/ai/engine.ts): Routes requests using InferenceMode.PREFER_ON_DEVICE for lightweight creation and editing tasks and InferenceMode.ONLY_IN_CLOUD for deeper or tool-assisted queries, paired with onDeviceReady() availability detection, response streaming, and normalized error handling (friendlyError).
  • App Check & Security (lib/ai/appCheck.ts): Protects cloud AI calls and backend endpoints so unverified clients cannot abuse cloud quota.
  • App-Wide Integration & Mode Transparency: Connected across AI Studio (prompt refinement and creative workflows), Home / Ask AI (live trending token discovery), Token Mint Terminal (/terminal/token/[mint] liquidity, holder, and risk analysis), Stock View (tokenized equities context), Create Post, and Edit Profile, with explicit On-device and Cloud indicators in the UI (AISheet.tsx and AIBadge).

Conceptually, our routing decision balances local readiness against task complexity and tool requirements:

$$P(\text{cloud}) = \begin{cases} 1, & \text{if } \text{mode} = \text{ONLY_IN_CLOUD} \lor \neg \text{onDeviceReady}() \lor \text{needsTools}(q) \ 0, & \text{otherwise} \end{cases}$$

Challenges We Faced

  • Device & Browser Support Variance: On-device Gemini Nano availability in the browser depends on client hardware and browser runtime support (such as desktop Chrome support vs. mobile browsers falling back to cloud). We had to ensure the UI and engine never stall or throw confusing errors when local inference is unavailable.
  • Routing Light vs. Heavy / Tool-Driven Prompts: Prompts that sound short on the surface—like asking for live trending tokens—still require real-time market tools and cloud execution, so routing had to account for capability and tool requirements rather than prompt length alone.
  • Securing Cloud Fallback with App Check: Configuring App Check cleanly across live deployments and test environments without blocking legitimate users required careful verification so cloud fallback remains reliable under real traffic.

What We Learned

  • Hybrid AI shines when fallback is invisible to the user: Treating on-device inference and cloud fallback as one unified flow—with clear mode badges (On-device vs. Cloud)—delivers speed and privacy when local models are ready while preserving full capability everywhere else.
  • Centralizing AI logic prevents feature drift: Keeping routing, streaming, App Check enforcement, and friendly error mapping inside a single engine (lib/ai/engine.ts) made it far easier to connect AI consistently across Home, Studio, Token Mint pages, and Stock views.
  • Graceful degradation is essential for real-world apps: Designing for heterogeneous devices from day one ensures every user gets a fast, dependable experience whether their device runs Gemini Nano locally or uses Cloud AI.

Built With

Share this project:

Updates

Submission history