A lean Node.js backend that uses AI to research topics through Reddit discussions.
- Semantic Layer - Analyzes user queries using OpenAI to extract intent, tags, and keywords
- Reddit Fetcher - Searches Reddit using generated keywords across relevant subreddits
- Summarizer - Uses AI to summarize Reddit posts and extract key insights
- Coordinator - Orchestrates the entire pipeline
Research a topic through Reddit discussions.
Headers:
Authorization: Bearer <firebase-id-token>
Content-Type: application/json
Request Body:
{
"query": "How do indie SaaS founders get first 100 users?",
"maxPosts": 20,
"timeFilter": "month",
"subreddits": ["entrepreneur", "SaaS", "startups"]
}Response:
{
"success": true,
"data": {
"query": "How do indie SaaS founders get first 100 users?",
"analysis": {
"intent": "Growth strategies for SaaS founders to acquire their first customers",
"tags": ["SaaS growth", "first users", "startup marketing"],
"keywords": ["SaaS first 100 users", "indie hacker customer acquisition"]
},
"posts": [
{
"id": "abc123",
"title": "How I got my first 100 SaaS customers",
"summary": "Founder shares strategy of direct outreach and content marketing...",
"insights": ["Direct outreach to target audience", "Content marketing builds trust"],
"relevanceScore": 9,
"url": "https://reddit.com/r/entrepreneur/comments/abc123",
"subreddit": "entrepreneur",
"score": 245,
"comments": 67
}
],
"meta": {
"totalFound": 156,
"processed": 20,
"summarized": true
}
}
}-
Environment Variables - Copy
.env.exampleto.envand fill in:- OpenAI API key
- Reddit API credentials (create app at https://www.reddit.com/prefs/apps)
-
Install Dependencies
npm install
-
Start Server
npm run dev # Development with auto-reload npm start # Production
- 100 requests per 15 minutes per IP
- Max 50 posts per research request
The API returns structured error responses:
{
"error": "Query not suitable for Reddit research",
"suggestion": "Try: 'Reddit communities discussing SaaS growth'"
}- Helmet.js for security headers
- CORS protection
- Rate limiting
- Input validation
- Firebase token verification# reddit-backend