Module 1 of the SpaceLens (PayAI x402) project. This API accepts Twitter Space links, extracts metadata and media streams, and initializes the SpaceLens processing pipeline.
- Accept Twitter Space URLs (live or recorded)
- Extract Space metadata using Twitter API v2
- Download and process Space recordings
- Extract audio from video files using FFmpeg
- Upload audio to Supabase Storage
- Queue jobs for transcription processing
- Track job progress and status
- Node.js + Express
- Supabase (Postgres + Storage)
- BullMQ (Redis) for background job queue
- Twitter API v2 for Space data
- FFmpeg for audio extraction
- Node.js v18 or higher
- Redis server (local or cloud)
- Supabase account and project
- Twitter API v2 Bearer Token (optional, uses mock data if not provided)
npm installCopy the .env file and configure the following variables:
# Supabase Configuration
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_KEY=your_service_role_key
# Twitter API
TWITTER_BEARER_TOKEN=your_twitter_bearer_token
# Redis
REDIS_URL=redis://localhost:6379
# Server
PORT=3000The database schema is automatically created through Supabase migrations:
spacestable: Stores Twitter Space metadatajobstable: Tracks processing jobsspace-audiostorage bucket: Stores extracted audio files
npm startThe server will start on http://localhost:3000
In a separate terminal:
npm run workerThe worker listens to the transcription queue and processes jobs.
Ingest a Twitter Space URL and start processing.
Request Body:
{
"twitter_space_url": "https://twitter.com/i/spaces/1YNGa..."
}Response:
{
"success": true,
"spaceId": "1yNGaabcdEF",
"jobId": "e3b9c03c-6e91-4bb2-b0da-fbaf16cbf7a7",
"status": "ingested"
}Get space metadata and job status.
Response:
{
"success": true,
"data": {
"space": {
"id": "uuid",
"spaceId": "1yNGaabcdEF",
"title": "Space Title",
"type": "audio",
"status": "ingested"
},
"jobs": [
{
"id": "uuid",
"stage": "transcription",
"progress": 10,
"resultUrl": "https://..."
}
]
}
}Health check endpoint.
src/
├── config/ # Configuration management
├── routes/ # API route handlers
├── services/ # Business logic services
│ ├── database.js # Supabase database operations
│ ├── twitterApi.js # Twitter API integration
│ ├── mediaProcessor.js # FFmpeg audio processing
│ ├── queue.js # BullMQ job queue
│ └── supabaseClient.js # Supabase client
├── utils/ # Helper functions
├── workers/ # Background job workers
└── server.js # Express server entry point
- If Twitter API credentials are not provided, the system uses mock data for development
- Audio files are stored in the
/tmp/spacelensdirectory during processing - The worker process runs concurrently with the API server
- Jobs are automatically retried up to 3 times on failure
This module queues jobs for Module 2, which will handle:
- Audio transcription
- Content analysis
- AI-powered insights
Private - SpaceLens Project Ltd