57## Getting Started
58
59The main entry point is `/backend/index.ts` which serves the React frontend and API routes.
6import { ValTransport } from "./mcp.tsx";
7
8const GEMINI_API_KEY = process.env.GEMINI_API_KEY;
9const QDRANT_API_KEY = process.env.QDRANT_API_KEY;
10
11const qdrant = new QdrantClient({
12 url: "https://fc7f61ca-9509-4bff-b81b-72b565d8fb6c.us-east4-0.gcp.cloud.qdrant.io:6333",
13 apiKey: QDRANT_API_KEY,
14});
15
16const ai = new GoogleGenAI({ apiKey: GEMINI_API_KEY });
17
18const createRandomGeminiVector = (): number[] => Array.from({ length: 768 }, () => Math.random() * 2 - 1);
20## Tech Stack
21
22- **Backend**: Hono.js API with Together AI integration
23- **Frontend**: React with TypeScript
24- **AI**: Together AI for content analysis and generation
30```
31โโโ backend/
32โ โโโ index.ts # Main API server
33โ โโโ routes/
34โ โ โโโ upload.ts # PDF upload handling
52## Environment Variables
53
54- `TOGETHER_API_KEY`: Your Together AI API key
55
56## Usage
57
581. Set your Together AI API key in environment variables
592. Upload your product PDF (ensure it has selectable text)
603. Enter your product purchase link
67 formData.append('pdf', selectedFile);
68
69 const response = await fetch('/api/upload', {
70 method: 'POST',
71 body: formData
30โ โ โโโ queries.ts # Database operations
31โ โโโ routes/
32โ โโโ notes.ts # Note API endpoints
33โโโ frontend/
34โ โโโ index.html # Main HTML template
42```
43
44## API Endpoints
45
46- `POST /api/notes` - Create a new note (admin only, requires admin password)
47- `GET /api/notes/:id` - Get a note (public access)
48- `POST /api/notes/:id/verify` - Verify password for protected note (public access)
49- `POST /api/notes/:id/delete` - Delete a note (admin only, requires admin password)
50
51## Tech Stack
47
48 try {
49 const response = await fetch(`/api/notes/${noteId}`);
50
51 if (!response.ok) {
84 };
85
86 const response = await fetch('/api/notes', {
87 method: 'POST',
88 headers: { 'Content-Type': 'application/json' },
123
124 try {
125 const response = await fetch(`/api/notes/${currentNoteId}/verify`, {
126 method: 'POST',
127 headers: { 'Content-Type': 'application/json' },
157
158 try {
159 const response = await fetch(`/api/notes/${currentNoteId}/delete`, {
160 method: 'POST',
161 headers: { 'Content-Type': 'application/json' },
17setInterval(cleanupExpiredNotes, 60 * 60 * 1000); // Every hour
18
19// API routes
20app.route("/api/notes", notes);
21
22// Serve static files
3import type { ContentAnalysis, LeadMagnetContent } from "../../shared/types.ts";
4
5const TOGETHER_API_URL = 'https://api.together.xyz/v1/chat/completions';
6
7export async function callTogetherAI(messages: any[], model = 'meta-llama/Llama-3-8b-chat-hf') {
8 const TOGETHER_API_KEY = Deno.env.get('TOGETHER_API_KEY');
9
10 if (!TOGETHER_API_KEY) {
11 throw new Error('TOGETHER_API_KEY environment variable is required. Please set it in your Val Town environment.');
12 }
13
14 const response = await fetch(TOGETHER_API_URL, {
15 method: 'POST',
16 headers: {
17 'Authorization': `Bearer ${TOGETHER_API_KEY}`,
18 'Content-Type': 'application/json',
19 },
30 if (!response.ok) {
31 const error = await response.text();
32 throw new Error(`Together AI API error: ${response.status} - ${error}`);
33 }
34
31 };
32
33 const response = await fetch('/api/generate', {
34 method: 'POST',
35 headers: {
50 };
51
52 const response = await fetch('/api/analyze', {
53 method: 'POST',
54 headers: {