Skip to content

Commit d0ccb36

Browse files
committed
Unify Executive Intelligence showcase page structure to match standard format
1 parent 8c5e117 commit d0ccb36

File tree

1 file changed

+57
-301
lines changed

1 file changed

+57
-301
lines changed
Lines changed: 57 additions & 301 deletions
Original file line numberDiff line numberDiff line change
@@ -1,329 +1,85 @@
11
---
2-
title: Executive Intelligence
3-
description: Competitor intelligence, market info, risk analysis, and benchmark. Imagine you’re a CEO, and you need to know these —instantly and reliably.
4-
sidebar_position: 6
5-
keywords: [Executive Intelligence, Next.js AI Application, Perplexity Sonar API, Competitive Intelligence, React TypeScript AI]
2+
title: Executive Intelligence | AI-Powered Strategic Decision Platform
3+
description: A comprehensive Perplexity Sonar-powered application that provides executives and board members with instant, accurate, and credible intelligence for strategic decision-making
4+
sidebar_position: 16
5+
keywords: [executive intelligence, perplexity sonar, competitive intelligence, strategic decision, next.js, typescript, ai]
66
---
7-
# Executive Intelligence
8-
Executive Intelligence is a Perplexity Sonar powered application designed to provide executives and board members with instant, accurate, and credible intelligence for strategic decision-making.
9-
Recognizing the challenges of sifting through vast amounts of information quickly and reliably, this project focuses on delivering board-ready insights derived from real-time data sources, powered by Perplexity's Sonar API.
10-
*Built by [Raish Shrestha](https://www.linkedin.com/in/raishs/)*
7+
8+
**Executive Intelligence** is a comprehensive Perplexity Sonar-powered application that provides executives and board members with instant, accurate, and credible intelligence for strategic decision-making. It delivers board-ready insights derived from real-time data sources, powered by Perplexity's Sonar API.
9+
10+
<iframe
11+
className="w-full aspect-video rounded-xl"
12+
src="https://www.youtube.com/embed/SB1pxIl9Mp0"
13+
title="YouTube video player"
14+
frameBorder="0"
15+
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
16+
allowFullScreen
17+
></iframe>
1118

1219
## Features
1320

14-
- **Competitive Intelligence Briefs**: Generate comprehensive, board-ready competitive analysis for any company. Provides executive summaries, recent competitor moves, market shifts, recommendations, and full, verifiable citations for every claim.
15-
- **Scenario Planning (“What If?” Analysis)**: Dynamically generate and analyze potential future scenarios based on real-time competitor and industry data. Get structured, cited reports exploring risks, opportunities, and recommendations for hypothetical situations.
16-
- **Board Pack Memory**: Save and organize key intelligence briefs, scenario analyses, and benchmark reports. Create a persistent, searchable knowledge base accessible in a dedicated Board Pack section.
17-
- **Instant Benchmarking & Peer Comparison**: Quickly generate source-cited, visual comparisons of your company against top competitors across critical metrics. Data points are linked to their sources, providing reliable support for strategic discussions.
21+
* **Competitive Intelligence Briefs** with comprehensive, board-ready competitive analysis and verifiable citations
22+
* **Scenario Planning ("What If?" Analysis)** for dynamic future scenario generation based on real-time data
23+
* **Board Pack Memory** for saving and organizing intelligence briefs, scenario analyses, and benchmark reports
24+
* **Instant Benchmarking & Peer Comparison** with source-cited visual comparisons across critical metrics
25+
* **Real-time Data Integration** leveraging Perplexity Sonar API for up-to-date market intelligence
26+
* **Professional Formatting** with structured reports, executive summaries, and board-ready presentations
1827

1928
## Prerequisites
2029

21-
* Node.js (v18 or later recommended)
22-
* npm or yarn
23-
* Git
24-
* A Perplexity API key
30+
* Node.js 18+ and npm/yarn
31+
* Git
32+
* Perplexity API key (Sonar Pro)
2533

2634
## Installation
2735

28-
1. Clone the repository:
29-
```bash
30-
git clone [Your GitHub Repo URL]
31-
cd [Your Repo Name]
32-
```
33-
2. Install dependencies:
34-
```bash
35-
npm install
36-
# or
37-
yarn install
38-
```
39-
3. Set up environment variables:
40-
Create a `.env.local` file in the root of the project.
41-
```env
42-
PERPLEXITY_API_KEY=YOUR_PERPLEXITY_API_KEY
43-
```
44-
Replace `YOUR_PERPLEXITY_API_KEY` with your actual Perplexity API key.
45-
46-
4. Run the development server:
47-
```bash
48-
npm run dev
49-
# or
50-
yarn dev
51-
```
52-
5. Open [http://localhost:3000](http://localhost:3000) in your browser to see the application.
53-
54-
## Usage
55-
56-
* **Company Input:** Enter the company you want to analyze in the input field at the top.
57-
* **Boardroom Intelligence:** Click the buttons within the "Executive Intelligence" card to generate Competitive Analysis Briefs, explore Scenario Planning, or view the Instant Benchmarking board.
58-
* **Save to Board Pack:** Use the "Save to Board Pack" button within the modals to store generated reports for later access.
59-
* **Board Pack:** Click the "📁 Board Pack" button on the main card to view saved items.
60-
61-
## Code Explanation
62-
63-
### Core Architecture
36+
```bash
37+
# Clone the repository
38+
git clone https://github.com/raishs/perplexityhackathon.git
39+
cd perplexityhackathon
6440

65-
The Executive Intelligence application is built as a Next.js application with TypeScript, leveraging Perplexity's Sonar API for AI-powered intelligence generation. Here are the key code snippets and their explanations:
41+
# Install dependencies
42+
npm install
6643

67-
#### 1. Perplexity API Integration
68-
69-
```typescript
70-
// lib/perplexity.ts
71-
export async function askPerplexity(question: string) {
72-
const res = await fetch('/api/perplexity', {
73-
method: 'POST',
74-
headers: { 'Content-Type': 'application/json' },
75-
body: JSON.stringify({ query: question }),
76-
})
77-
if (!res.ok) throw new Error('Perplexity API error')
78-
return res.json()
79-
}
80-
```
81-
**How it works:** This is a simple wrapper function that forwards user queries to the Perplexity API endpoint. It handles the basic HTTP request/response cycle and error handling for API communication.
82-
83-
#### 2. API Route Handler
84-
85-
```typescript
86-
// app/api/perplexity/route.ts
87-
export async function POST(req: NextRequest) {
88-
const { query } = await req.json()
89-
const apiKey = process.env.PERPLEXITY_API_KEY
90-
91-
const requestBody = {
92-
model: 'sonar-pro',
93-
messages: [
94-
{ role: 'system', content: 'Be precise and concise.' },
95-
{ role: 'user', content: query },
96-
],
97-
}
98-
99-
const res = await fetch('https://api.perplexity.ai/chat/completions', {
100-
method: 'POST',
101-
headers: {
102-
'Authorization': `Bearer ${apiKey}`,
103-
'accept': 'application/json',
104-
'content-type': 'application/json',
105-
},
106-
body: JSON.stringify(requestBody),
107-
signal: controller.signal,
108-
timeout: 30000, // 30 second timeout
109-
})
110-
}
44+
# Set up environment variables
45+
cp .env.example .env.local
11146
```
11247

113-
**How it works:** This API route handler:
114-
- Extracts the query from the request body
115-
- Validates the API key from environment variables
116-
- Constructs the proper request format for Perplexity's Sonar API
117-
- Implements timeout handling (30 seconds) to prevent hanging requests
118-
- Includes comprehensive error handling for network issues, timeouts, and API errors
48+
## Configuration
11949

120-
#### 3. Boardroom Memory Context
121-
122-
```typescript
123-
// components/context/boardroom-memory.tsx
124-
export interface MemoryItem {
125-
id: number;
126-
title: string;
127-
description: string;
128-
timestamp: string;
129-
type: 'board-pack' | 'brief' | 'alert';
130-
actionItems?: string[];
131-
references?: string[] | { [num: string]: string };
132-
}
133-
134-
const BoardroomMemoryContext = createContext<BoardroomMemoryContextType | undefined>(undefined);
135-
136-
export function BoardroomMemoryProvider({ children }: { children: ReactNode }) {
137-
const [memory, setMemory] = useState<MemoryItem[]>(initialMemory);
138-
const [pinnedId, setPinnedId] = useState<number | null>(null);
139-
140-
// Add logging wrapper for setMemory
141-
const wrappedSetMemory: React.Dispatch<React.SetStateAction<MemoryItem[]>> = (newState) => {
142-
console.log('BoardroomMemoryProvider: setMemory called with:', newState);
143-
// ... implementation
144-
};
145-
}
50+
Create `.env.local` file:
51+
```ini
52+
PERPLEXITY_API_KEY=your_perplexity_api_key
14653
```
14754

148-
**How it works:** This React Context provides persistent state management for:
149-
- Storing generated intelligence briefs, scenario analyses, and alerts
150-
- Maintaining a searchable knowledge base of board-ready insights
151-
- Supporting pinned items for quick access to critical information
152-
- Including comprehensive logging for debugging state changes
153-
154-
#### 4. Competitive Intelligence Generation
155-
156-
```typescript
157-
// components/CompetitiveThreatAlertCard.tsx
158-
const handleCompetitiveAnalysis = async () => {
159-
setIsLoading(true);
160-
try {
161-
const prompt = `Generate a comprehensive competitive intelligence brief for ${company}.
162-
Include: Executive Summary, Recent High-Impact Competitor Moves, Market Shifts & Opportunities,
163-
and Board-Ready Recommendations. Format with clear sections and numbered references.`;
164-
165-
const response = await askPerplexity(prompt);
166-
const content = response.choices[0].message.content;
167-
168-
// Parse the response into structured sections
169-
const sections = parseMarkdownSections(content);
170-
const references = extractReferences(content);
171-
172-
setAnalysis({ sections, references, rawContent: content });
173-
} catch (error) {
174-
toast.error('Failed to generate competitive analysis');
175-
} finally {
176-
setIsLoading(false);
177-
}
178-
};
179-
```
180-
181-
**How it works:** This function:
182-
- Constructs detailed prompts for Perplexity API to generate competitive intelligence
183-
- Parses the AI response into structured sections (Executive Summary, Competitor Moves, etc.)
184-
- Extracts and formats references for proper citation linking
185-
- Handles loading states and error scenarios
186-
- Integrates with the boardroom memory system for persistence
187-
188-
#### 5. Benchmark Board Component
189-
190-
```typescript
191-
// components/BenchmarkBoard.tsx
192-
const generateBenchmark = async () => {
193-
setIsLoading(true);
194-
try {
195-
const competitors = [company, ...selectedCompetitors].join(', ');
196-
const prompt = `Create a visual benchmark comparison of ${competitors} across key metrics:
197-
${selectedMetrics.join(', ')}. Include data visualization suggestions and source citations.`;
198-
199-
const response = await askPerplexity(prompt);
200-
const content = response.choices[0].message.content;
201-
202-
// Extract reference links and format for display
203-
const refMap = extractReferenceLinks(content);
204-
const linkedContent = linkReferencesInMarkdown(content, refMap);
205-
206-
setBenchmarkData({ content: linkedContent, references: refMap });
207-
} catch (error) {
208-
toast.error('Failed to generate benchmark');
209-
} finally {
210-
setIsLoading(false);
211-
}
212-
};
213-
```
214-
215-
**How it works:** This component:
216-
- Generates peer comparison benchmarks using Perplexity's analysis capabilities
217-
- Supports dynamic competitor selection and metric customization
218-
- Automatically links citations to their sources for verification
219-
- Provides visual data representation suggestions
220-
- Maintains source integrity for board-ready presentations
55+
## Usage
22156

222-
#### 6. Markdown Processing & Citation Handling
57+
1. **Start Development Server**:
58+
```bash
59+
npm run dev
60+
```
22361

224-
```typescript
225-
// Utility functions for processing AI responses
226-
function parseMarkdownSections(markdown: string) {
227-
const sectionRegex = /^(###? .*)$/gm;
228-
const matches: { match: string; index: number }[] = [];
229-
let match;
230-
while ((match = sectionRegex.exec(markdown)) !== null) {
231-
matches.push({ match: match[1], index: match.index! });
232-
}
233-
234-
const sections = [];
235-
for (let i = 0; i < matches.length; i++) {
236-
const start = matches[i].index;
237-
const end = i < matches.length - 1 ? matches[i + 1].index : markdown.length;
238-
const title = matches[i].match.replace(/^#+\s*/, '');
239-
const content = markdown.slice(start + matches[i].match.length, end).trim();
240-
sections.push({ title, content });
241-
}
242-
return sections;
243-
}
62+
2. **Access Application**: Open http://localhost:3000 in your browser
24463

245-
function postProcessCitations(markdown: string): string {
246-
// Find the References section and add anchor tags
247-
const refSectionMatch = markdown.match(/(### References[\s\S]*)/i);
248-
let processed = markdown;
249-
if (refSectionMatch) {
250-
const refSection = refSectionMatch[1];
251-
const refAnchored = refSection.replace(/^(\d+)\.?\s+/gm, (m, n) => `<a id='ref${n}'>${n}.</a> `);
252-
processed = processed.replace(refSection, refAnchored);
253-
}
254-
// Replace citation markers with clickable links
255-
processed = processed.replace(/\[(\d+)\](?!\()/g, (m, n) => `[${n}](#ref${n})`);
256-
return processed;
257-
}
258-
```
64+
3. **Generate Intelligence**:
65+
- Enter a company name in the input field
66+
- Click "Competitive Analysis" for comprehensive briefs
67+
- Use "Scenario Planning" for "what-if" analysis
68+
- Access "Benchmarking" for peer comparisons
69+
- Save reports to "Board Pack" for later access
25970

260-
**How it works:** These utilities:
261-
- Parse AI-generated markdown into structured sections for better UI presentation
262-
- Automatically link citations to their corresponding references
263-
- Handle various citation formats ([1], [1,2], [1-3])
264-
- Create clickable reference links for source verification
265-
- Maintain document structure for professional board presentations
71+
4. **Board Pack Management**: Use the "📁 Board Pack" button to view and manage saved intelligence reports
26672

267-
#### 7. Scenario Planning Implementation
73+
## Code Explanation
26874

269-
```typescript
270-
const handleScenarioPlanning = async (scenario: string) => {
271-
setIsLoading(true);
272-
try {
273-
const prompt = `Analyze this scenario for ${company}: "${scenario}".
274-
Provide: Risk Assessment, Opportunity Analysis, Strategic Recommendations,
275-
and Implementation Timeline. Include specific data points and citations.`;
276-
277-
const response = await askPerplexity(prompt);
278-
const content = response.choices[0].message.content;
279-
280-
setScenarioAnalysis({ content, scenario });
281-
} catch (error) {
282-
toast.error('Failed to generate scenario analysis');
283-
} finally {
284-
setIsLoading(false);
285-
}
286-
};
287-
```
288-
**How it works:** This function enables:
289-
- Dynamic scenario generation based on user-defined "what-if" questions
290-
- Structured analysis of risks, opportunities, and strategic implications
291-
- Time-based planning with implementation timelines
292-
- Data-driven recommendations with source citations
293-
- Integration with the boardroom memory for scenario tracking
75+
* **Frontend**: Next.js with TypeScript and React for modern, responsive UI
76+
* **Backend**: Next.js API routes handling Perplexity Sonar API integration
77+
* **AI Integration**: Perplexity Sonar Pro for real-time competitive intelligence and scenario analysis
78+
* **State Management**: React Context for boardroom memory and persistent data storage
79+
* **Markdown Processing**: Custom utilities for parsing AI responses and citation handling
80+
* **Error Handling**: Comprehensive timeout and error management for API calls
81+
* **Professional Output**: Structured formatting for board-ready presentations with source citations
29482

29583
## Links
29684

29785
- [GitHub Repository](https://github.com/raishs/perplexityhackathon)
298-
- [Live Demo](https://www.youtube.com/watch?v=SB1pxIl9Mp0)
299-
300-
## Limitations
301-
302-
1. **Memory Persistence**
303-
- Boardroom memory is currently stored in React state (client-side only)
304-
- Data is lost on page refresh or browser restart
305-
- No database integration for permanent storage
306-
- No user authentication or multi-user support
307-
308-
2. **Scalability Constraints**
309-
- Single-page application architecture may not scale for enterprise use
310-
- No caching mechanisms for repeated queries
311-
- Synchronous API calls can block UI during processing
312-
- No background processing for long-running analyses
313-
-
314-
3. **Needs Access Control**
315-
- No user authentication or authorization
316-
- No role-based access controls
317-
- No audit trails for intelligence generation
318-
- No data encryption for sensitive information
319-
320-
### Recommendations for Production Use
321-
322-
1. **Implement proper data persistence** with a database backend
323-
2. **Add user authentication and authorization** for enterprise security
324-
3. **Integrate with additional data sources** for comprehensive intelligence
325-
4. **Implement caching mechanisms** to reduce API calls and improve performance
326-
5. **Add export functionality** for board presentations and reports
327-
6. **Develop offline capabilities** for critical intelligence access
328-
7. **Implement real-time notifications** for competitive alerts
329-
8. **Add collaborative features** for team-based intelligence gathering

0 commit comments

Comments
 (0)