🎬 CinePulse AI: Autonomous Studio Executive Copilot

Real-Time Theatrical Box Office Telemetry, Emergency Screen Reallocation & Streaming Retention Diagnostics


💡 Inspiration

In the high-stakes entertainment industry, theatrical releases and streaming debuts are multi-hundred-million-dollar gambles. Yet, studio executives and distribution presidents are still forced to make critical business decisions using legacy reporting workflows: delayed weekend estimates, static post-mortems, and coarse 28-day streaming completion rates.

When a tentpole film collapses on premium screens on a Friday evening, or when subscribers drop off in droves during a confusing plot twist at minute 38 of a streaming premiere, every lost hour costs millions in unrecoverable revenue and subscriber churn:

$$\Delta \text{Revenue} = \sum_{s \in \text{Screens}} N_s \cdot \bar{P}{\text{ticket}} \cdot \left(\text{Occupancy}{\text{breakout}} - \text{Occupancy}_{\text{underperformer}}\right)$$

We were inspired to build CinePulse AI to eliminate this intelligence latency. By pairing the ultra-fast columnar OLAP power of ClickHouse Cloud with the autonomous analytical reasoning of Google Cloud Vertex AI / Gemini 3.1 Pro, CinePulse AI acts as a 24/7 Chief Intelligence Copilot that continuously monitors global theater telemetry, diagnoses audience retention drop-offs down to the exact second, and formulates emergency commercial directives in real time.


🧠 What It Does

CinePulse AI is an autonomous, full-stack decision-intelligence platform engineered for studio heads, distribution executives, and chief content officers.

  1. 🎟️ Autonomous Emergency Screen Optimization:
    Continuously audits seat occupancy across Standard 2D, Dolby Cinema, 4DX, IMAX Digital, and IMAX 70mm formats. When an underperforming title occupies high-margin premium large formats (PLF) at depressed capacity ($<25\%$), the agent autonomously generates emergency screen reallocation directives to shift capacity to capacity-constrained breakout titles ($>90\%$ occupancy).
  2. 📉 Second-by-Second Streaming Retention Diagnostics:
    Ingests minute-by-minute streaming telemetry to detect exact narrative churn cliffs (e.g., Min 38 exposition slumps or convoluted non-linear flashbacks) and prescribes immediate editorial intervention (such as commissioning an alternate "Linear Streaming Cut" or in-app interactive timeline overlays).
  3. ⭐ Multi-Dimensional Exit Poll & Sentiment Analytics:
    Correlates verified exit-poll sentiment, CinemaScore proxies, and critical reviews against pacing, VFX, and acting metrics using ClickHouse's native statistical aggregation functions: $$r_{xy} = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum (x_i - \bar{x})^2 \sum (y_i - \bar{y})^2}}$$
  4. ⚡ Live Transparent Execution Inspector:
    Every directive produced by Gemini displays the exact ClickHouse SQL query executed, engine type, row counts, and query latency (typically $150\text{--}800\text{ ms}$).
  5. 🔄 Dynamic Multi-Stage Visual Feedback:
    The UI provides real-time progress cards that visually step through query formulation, schema introspection, ClickHouse OLAP execution, and executive directive synthesis.

  • AI Reasoning & Function Calling: Powered by Google Cloud Vertex AI / Gemini 3.1 Pro using the official google-genai Python SDK. We leveraged native Automatic Function Calling (AFC) with client.chats.create and chat.send_message, equipping Gemini with dynamic database introspection (get_schema_metadata) and read-only analytical SQL execution tools (execute_clickhouse_query).
  • Telemetry Store & Real-Time OLAP: Hosted on ClickHouse Cloud (zzrypx1oh0.us-central1.gcp.clickhouse.cloud:8443). We designed custom MergeTree engines partitioned by toYYYYMM(event_time) with LowCardinality dictionary encoding across territories, genres, formats, and user segments.
  • Frontend & Data Visualization: Built with Streamlit styled with a custom cinematic dark-glass glassmorphism theme, Plotly Express interactive charts, and dynamic st.status multi-stage containers.
  • Containerization & Deployment: Built with a multi-stage Dockerfile and deployed serverlessly to Google Cloud Run in us-central1 with automated scaling and health checks.

🧗 Challenges We Faced

  1. Autonomous SQL Generation Without Hallucination:
    Ensuring that Gemini consistently generated valid, dialect-compliant ClickHouse SQL (e.g. LowCardinality filters, toYYYYMM partitioning, and quantileExact functions) required a carefully crafted system prompt and dynamic schema introspection tool.
  2. Cross-Engine SQL Dialect Normalization:
    While ClickHouse supports specialized functions like any(), embedded fallback engines (DuckDB/SQLite) threw parser exceptions. We resolved this by standardizing queries on ANSI MAX() and building a regex-based query transformer in agent.py to guarantee zero-downtime resilience.
  3. Stateless HTTP Protocol & Connection Management:
    ClickHouse HTTP connections over port 8443 require explicit database qualification per request. We implemented auto-provisioning connection pooling in ClickHouseTelemetryEngine to ensure instant table verification and telemetry availability.
  4. Real-Time Visual Execution Feedback:
    Standard static spinners did not reflect the complex multi-step reasoning happening behind the scenes. We developed a callback mechanism in the agent loop to stream progress updates directly into Streamlit's st.status component.

🎓 What We Learned

  • The Synergy of Vectorless OLAP + LLM Agents: Combining ClickHouse’s sub-second aggregations over massive tabular datasets with Gemini's high-level strategic reasoning creates a powerful paradigm for autonomous business intelligence.
  • Modern Google GenAI SDK Patterns: Mastering Automatic Function Calling in google-genai (specifically using client.chats.create rather than legacy single-turn calls) produces clean, multi-turn tool calling without deprecation warnings.
  • Serverless Resilience on Cloud Run: Containerizing Streamlit with non-privileged execution and explicit environment variable files (env.yaml) ensures repeatable, reliable deployments on Google Cloud Run.

🔮 What's Next for CinePulse AI

  • Direct Ticketing Chain API Integrations: Real-time webhooks connecting to AMC, Regal, and Cinépolis POS APIs to execute automated screen schedule swaps directly.
  • Multimodal Video Ingestion: Utilizing Gemini Multimodal video processing to ingest raw film footage and automatically correlate script scenes with streaming audience drop-off timestamps.
  • Predictive Box Office Forecasting: Monte Carlo revenue simulation models combining historical box office data with live social sentiment to project 4-week theatrical trajectories.

Built With

Share this project:

Updates

Submission history