
# Building a market research platform with Parallel Deep Research
This guide walks through building a comprehensive market research platform that generates detailed industry reports using Parallel's Deep Research product. The application demonstrates how to create a production-ready system that handles real-time streaming, intelligent input validation, email notifications, and robust error handling for AI-powered research tasks.

## Key Features
- - AI-Powered Research: Uses Parallel's Deep Research API with "ultra2x" processor for comprehensive market analysis
- - Real-Time Progress Streaming: Server-Sent Events (SSE[SSE]($https://docs.parallel.ai/task-api/task-sse)) for live task progress updates with source tracking
- - Email Notifications: Optional email alerts via Resend API when reports are ready
- - Public Report Library: Browse all generated reports without any authentication required
- - Global Access: No authentication needed - anyone can generate and view reports
- - Interactive Dashboard: Clean, modern web interface with real-time progress visualization
- - Download Support: Export reports as Markdown files
- - Shareable URLs: Each report gets a unique URL slug for easy sharing
- - Input Validation: Low-latency validation of inputs via Parallel's Chat API[Chat API]($https://docs.parallel.ai/chat-api/chat-quickstart)
## Platform Architecture
This market research platform is designed for production use with several key architectural decisions:
### Core Components
- - Flask Backend: Python web framework handling API requests and task management
- - PostgreSQL Database: Unified schema storing both running tasks and completed reports
- - Real-time Streaming: Server-Sent Events for live progress updates during research
- - AI Validation: Parallel's Chat API for intelligent input filtering
- - Email System: Resend API for user notifications when reports complete
- - Public Library: Persistent storage enabling report sharing and discovery
### Design Patterns
The platform implements two key production patterns that ensure reliability. First, **multi-layer task completion** – Tasks are monitored through background thread monitoring and each run ID is stored upon completion, allowing for state recovery if disconnected or on failure. This allows for the lower-latency ultra processors to complete gracefully and ensures reports can be tracked and kicked off concurrently.
Next, **intelligent input validation** – as a public application, it’s important to ensure the data quality to end-users is high. The Chat API is used for a low-latency verification system that checks that the inputs – market name, question, region – fit within the focus of the app, protecting against unrelated data populating the public library. This 2-step process (low-latency validation paired with high-latency deep research) is a helpful framework that can provide meaningful improvements to user experiences in other applications.
## Implementation Details
### Real-Time Progress Streaming
The market research platform uses Server-Sent Events (SSE) to provide live updates during report generation. This is crucial for user experience since research tasks can take 2-15 minutes to complete, and users need to understand what's happening.
The platform implements manual SSE handling rather than using the browser's built-in `EventSource` API because Parallel's API requires authentication via the `x-api-key` header, which `EventSource` doesn't support.
### SSE Implementation Challenges
SSE data arrives as a continuous stream that can be split across network packets. The implementation handles this with a robust buffering system:
This approach ensures reliable parsing of SSE events even when network packets split messages unpredictably.
### Connection Resilience
Since market research tasks can take 2-15 minutes, the platform implements robust reconnection logic to handle network interruptions:
The reconnection system includes exponential backoff, attempt limiting, and status-based retry logic to ensure reliable task completion.
### Event Processing
The platform processes different types of events from Parallel's SSE stream, each serving specific purposes in the user interface. In the below code snippet, we demonstrated how each type of event was handled for display:
The system handles multiple event types:
- - Task State Events: Lifecycle updates (queued → running → completed
- - Progress Statistic*: Quantitative metrics like sources processed and pages read
- - Progress Messages: Qualitative updates showing AI reasoning and analysis steps
- - Error Events: Detailed error information for troubleshooting
This event diversity enables rich UI updates including progress bars, reasoning displays, and comprehensive error handling.
### Email Notification System
When reports complete, the platform automatically notifies users via email using the Resend API:
### Database Design
The platform uses a unified PostgreSQL schema that efficiently stores both running tasks and completed reports in a single table:
This design enables efficient querying of both active tasks and completed reports while supporting the public report library feature.
## Resources
- - Complete Source Code[Complete Source Code]($https://github.com/parallel-web/parallel-cookbook/tree/main/python-recipes/market-analysis-demo)
- - Live Demo[Live Demo]($https://market-analysis-demo.parallel.ai/)
- - Parallel Deep Research[Parallel Deep Research]($https://docs.parallel.ai/task-api/features/task-deep-research)
- - Parallel SSE Documentation[Parallel SSE Documentation]($https://docs.parallel.ai/task-api/features/task-sse)
By Parallel
October 22, 2025



























