- Node.js 22.2.0 or higher
- npm or yarn
- Reddit account
- Google AI Studio API key (free tier available)
git clone <your-repo-url>
cd ocrdocs
npm install- Go to https://aistudio.google.com/apikey
- Click "Create API Key"
- Copy the generated key
Create a .env file in the root directory:
DEVVIT_SUBREDDIT=r/your_test_subreddit
STORAGE_PROVIDER=redis
GEMINI_API_KEY=your_api_key_hereImportant: Never commit your .env file to git. It's already in .gitignore.
npm run loginFollow the prompts to authenticate with your Reddit account.
npm run buildnpm run deployAfter deployment, you need to set the API key in Redis for each subreddit:
- Install the app to your test subreddit
- Create a post using the mod menu
- Open the post and open browser console (F12)
- Run this command:
fetch('/api/temp-set-key', { method: 'POST' })
.then(r => r.json())
.then(console.log);This will read the API key from your environment and store it in Redis.
npm run devThis will:
- Start the client build watcher
- Start the server build watcher
- Start Devvit playtest on your test subreddit
src/
├── client/ # React frontend
│ ├── components/ # UI components
│ └── public/ # Static assets (splash screen, icons)
├── server/ # Express backend
│ ├── ai/ # Gemini AI integration
│ ├── core/ # Post creation logic
│ └── storage/ # Storage adapters (Redis, S3, PostgreSQL)
└── shared/ # Shared types
- ✅ Upload images and PDFs (up to 500KB)
- ✅ AI-powered document analysis using Gemini 2.5 Flash
- ✅ Auto-generate descriptions and summaries
- ✅ Store up to 20 documents per post
- ✅ 7-day caching for AI results
- ✅ Rate limiting (100 requests/day per user)
- ✅ Mobile-friendly interface
The app uses Redis by default (built into Devvit). External storage options (S3, PostgreSQL) are available but not recommended due to Devvit limitations.
Edit src/server/ai/gemini.ts to adjust:
- Model:
gemini-2.5-flash(default) - Temperature:
0.4(lower = more consistent) - Max tokens:
1000(response length limit)
Edit src/server/index.ts to adjust the rate limit:
const RATE_LIMIT = 100; // requests per day per usernpm run build
npx devvit uploadnpm run launchThis submits your app to Reddit for review. Apps installed on subreddits with >200 members require approval.
After approval:
- Go to your subreddit
- Mod Tools → Apps → Install App
- Select "OCR Document Manager"
- Create a post using the mod menu
Don't forget to set the Gemini API key in Redis for each subreddit (see step 7 above).
The API key needs to be set in Redis. Run the /api/temp-set-key endpoint as described in step 7.
Devvit builds can be inconsistent. If a build fails:
- Try running
npm run buildagain - Check that Node.js version is 22.2.0+
- Clear
dist/folder and rebuild
- Check that the API key is valid at https://aistudio.google.com/apikey
- Verify the key is set in Redis
- Check browser console for errors
- Check Devvit logs:
npx devvit logs r/your_subreddit --since 15m
- API keys should only be in
.env(which is gitignored) - The code now reads from environment variables
- Set keys in Redis after deployment using the temp endpoint
Gemini 2.5 Flash pricing:
- Free tier: 15 requests/minute
- Paid: ~$0.0002 per analysis
- With 100 requests/day: ~$0.60/month
- 7-day caching reduces costs significantly
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly with
npm run dev - Submit a pull request
BSD-3-Clause
For issues and questions:
- Check the Development Journey for common problems
- Open an issue on GitHub
- See Reddit Devvit docs: https://developers.reddit.com/docs
Built with:
- React & TypeScript
- Devvit (Reddit's developer platform)
- Google Gemini AI
- Tailwind CSS
Developed during the AWS AI Agent Hackathon and ported to Reddit Devvit.