Self-host Screenshothis
Take complete control of your screenshot infrastructure by running Screenshothis on your own servers. This guide walks you through everything from local development setup to production deployment.Why self-host? While our hosted service provides simplicity and reliability, self-hosting gives you complete data control, unlimited customization options, and eliminates external dependencies.
Project architecture
Screenshothis uses a modern monorepo architecture built with TypeScript:Backend API
Location:
apps/serverHono + tRPC API with TypeScript for fast, type-safe screenshot generationFrontend Web App
Location:
apps/webReact with TanStack Start and TailwindCSS for the dashboard and playgroundShared Packages
Location:
packages/*Common schemas, utilities, and types shared across applicationsInfrastructure
DependenciesPostgreSQL, Redis, and S3-compatible storage for complete functionality
Technology stack
| Component | Technology | Purpose |
|---|---|---|
| Runtime | Node.js + TypeScript | Fast, type-safe execution |
| API Framework | Hono + tRPC | Lightweight, type-safe API |
| Frontend | React + TanStack Start | Modern, fast web interface |
| Database | PostgreSQL + Drizzle ORM | Reliable data persistence |
| File Storage | S3-compatible storage | Screenshot and asset storage |
| Cache/Sessions | Redis | Fast caching and session management |
| Styling | TailwindCSS | Utility-first CSS framework |
| Linting/Formatting | Biome | Fast, consistent code formatting |
| Package Manager | pnpm | Efficient dependency management |
| Monorepo | Turborepo | Fast, scalable build system |
| Containerization | Docker + Docker Compose | Easy deployment and scaling |
Prerequisites
Before you begin, ensure you have these tools installed:1
Install Node.js
Download and install Node.js v18 or later from nodejs.org
Verify your installation:
node --version should show v18.0.0 or higher2
Install pnpm
Install the pnpm package manager:
Verify:
pnpm --version should show the installed version3
Install Docker
Download and install Docker Desktop for your operating system
Verify:
docker --version and docker-compose --version should both work4
Install Git
Ensure Git is installed for cloning the repository
Verify:
git --version should show your Git installationQuick setup
Get Screenshothis running locally in under 10 minutes:1
Clone the repository
You should now be in the screenshothis directory with all source code
2
Install dependencies
You should see “Dependencies installed” and no error messages
3
Start supporting services
Launch PostgreSQL, Redis, and MinIO (for local storage):This starts:
- PostgreSQL on
localhost:5432 - Redis on
localhost:6379 - MinIO (S3-compatible) on
localhost:9000(API) andlocalhost:9001(Console)
Verify services:
docker-compose ps should show all services as “Up”4
Configure environment variables
Copy and customize the environment files:The default values work for local development with Docker Compose.
5
Set up the database
Apply the database schema:This creates all necessary tables in your PostgreSQL database.
You should see “Schema applied successfully” or similar confirmation
6
Configure local storage
Set up MinIO for local screenshot storage:
- Open MinIO console at http://localhost:9001
- Login with credentials:
- Username:
screenshothis-access-key - Password:
screenshothis-secret-key
- Username:
- Create a bucket named
screenshothis-bucket - Verify access - you should see the empty bucket
MinIO provides S3-compatible storage for local development. For production, use AWS S3, DigitalOcean Spaces, or another S3-compatible service.
7
Start the applications
Launch both the web interface and API server:This starts:
- Web UI: http://localhost:3001
- API Server: http://localhost:3000
Visit both URLs to verify everything is working. You should see the Screenshothis interface and API health check.
Environment configuration
Server environment (apps/server/.env)
Configure the server with these essential variables:
Web environment (apps/web/.env)
Configure the web interface:
Available scripts
Run these commands from the root directory:Development scripts
| Command | Description |
|---|---|
pnpm install | Install all dependencies for the monorepo |
pnpm run dev | Start both web and server in development mode |
pnpm run dev:web | Start only the web (frontend) application |
pnpm run dev:server | Start only the server (backend) application |
Build and production scripts
| Command | Description |
|---|---|
pnpm run build | Build all applications for production |
pnpm run start | Start production builds (after building) |
Database management scripts
| Command | Description |
|---|---|
pnpm run db:push | Apply Drizzle schema changes to the database |
pnpm run db:studio | Open Drizzle Studio to view and manage the database |
pnpm run db:generate | Generate migration files for schema changes |
pnpm run db:migrate | Apply migrations to the database |
Code quality scripts
| Command | Description |
|---|---|
pnpm run check-types | Run TypeScript type checking across all packages |
pnpm run check | Run Biome linting and formatting checks |
pnpm run format | Apply Biome formatting to the codebase |
pnpm run lint | Run Biome linting checks |
pnpm run lint:fix | Run Biome linting and fix issues automatically |
Production deployment
Docker production setup
Build and deploy production-ready Docker images:1
Build production images
2
Set up external services
Configure production-grade external services:
- PostgreSQL: Use managed PostgreSQL (AWS RDS, DigitalOcean Managed Databases, etc.)
- Redis: Use managed Redis (AWS ElastiCache, DigitalOcean Managed Redis, etc.)
- S3 Storage: Use AWS S3, DigitalOcean Spaces, Cloudflare R2, or Backblaze B2
3
Configure production environment
Create production environment files with:
- Strong, unique passwords and secrets
- Production database connections
- Production S3-compatible storage credentials
- Appropriate rate limits and timeouts
4
Set up infrastructure
Configure your production infrastructure:
- Reverse proxy: nginx, Traefik, or cloud load balancer
- SSL certificates: Let’s Encrypt, cloud provider, or custom certificates
- Container orchestration: Docker Compose, Kubernetes, or cloud container services
Environment variables for production
Ensure these are properly configured for production:Strong, unique secret for authentication. Generate with
openssl rand -base64 32Connection string for your production PostgreSQL database
Connection string for your production Redis instance
Access key for your S3-compatible storage service
Secret key for your S3-compatible storage service
Name of your production storage bucket
Security considerations
Built-in security features
Screenshothis includes several security measures:Request size limits
Request size limits
- Header size limit: 8 KB (8192 characters) per request
- Cookie size limit: 4 KB (4096 characters) per request
- URL length limit: Standard browser limits (2048 characters)
- Request timeout: 30 seconds maximum
Rate limiting
Rate limiting
- Screenshot generation is limited per user
- Configurable rate limits via environment variables
- Built-in protection against abuse
CSP bypass auditing
CSP bypass auditing
- Every use of
bypass_csp=trueis audit-logged server-side - Helps identify potential security issues
- Enables security review and compliance
Input validation
Input validation
- All API inputs are validated using Zod schemas
- URL validation prevents malicious requests
- Parameter validation ensures data integrity
Additional security recommendations
1
Keep dependencies updated
Regularly update Node.js, dependencies, and base Docker images to get security patches.
2
Secure your database
- Use strong passwords
- Enable SSL/TLS connections
- Restrict network access
- Regular backups
3
Configure HTTPS
- Use SSL/TLS certificates for all connections
- Configure secure headers
- Enable HSTS (HTTP Strict Transport Security)
4
Monitor and log
- Set up application logging
- Monitor resource usage
- Track API usage patterns
- Set up alerts for unusual activity
Database management
View and manage data
Use Drizzle Studio for a visual database interface:http://localhost:4983 where you can:
- View all tables and data
- Edit records
- Run queries
- Manage relationships
Handle schema changes
For development, use the simple approach:Development vs Production: Use
db:push for rapid development iteration, but use migrations (db:generate and db:migrate) for production deployments where you need versioned, reversible database changes.Troubleshooting
Common issues and solutions
Port conflicts
Port conflicts
Problem: Services fail to start due to port conflictsSolutions:
- Change ports in
docker-compose.yml - Update environment variables to match new ports
- Stop conflicting services:
sudo lsof -i :5432to find what’s using PostgreSQL port
Database connection errors
Database connection errors
Problem: Cannot connect to PostgreSQLSolutions:
- Verify PostgreSQL container is running:
docker-compose ps - Check database credentials in environment variables
- Ensure database exists:
docker-compose exec postgres psql -U screenshothis -d screenshothis - Reset database:
docker-compose down && docker-compose up -d
S3 storage connection errors
S3 storage connection errors
Problem: Screenshot storage not workingSolutions:
- For local development: Verify MinIO container is running and accessible at
http://localhost:9001 - Check AWS environment variables match your storage configuration
- Ensure the bucket exists and has proper permissions
- For production: Verify your S3-compatible service credentials and bucket permissions
- Test connection:
curl http://localhost:9000/minio/health/live
Build and dependency errors
Build and dependency errors
Problem: Installation or build failuresSolutions:
- Clear node_modules and reinstall:
rm -rf node_modules && pnpm install - Clear Turborepo cache:
rm -rf .turbo - Check TypeScript types:
pnpm run check-types - Verify Node.js version:
node --version(should be v18+) - Update pnpm:
npm install -g pnpm@latest
Getting help
GitHub Issues
Search existing issues or create a new one for bugs and feature requests
View Docker Logs
Check service logs:
docker-compose logs or docker-compose logs <service-name>Community Discussions
Join discussions for questions, ideas, and community support
Documentation
Browse complete documentation for configuration and usage guides
Contributing
Screenshothis is an open source project (AGPL-3.0) with an active community. Your contributions help make it better for everyone.Ways to contribute
1
Report issues
Found a bug or have a feature request? Create an issue with detailed information.
2
Improve documentation
Help others by improving documentation, adding examples, or fixing typos.
3
Submit code changes
Follow our development guidelines:
- Run
pnpm run checkbefore committing - Ensure TypeScript types are correct:
pnpm run check-types - Test your changes locally with
pnpm run dev - Follow existing code style (Biome handles formatting)
4
Join discussions
Participate in GitHub Discussions to share ideas and help other users.
Development workflow
- Quick Fix
- Feature Development
- Documentation
- Fork the repository
- Create a feature branch:
git checkout -b fix-something - Make your changes
- Test locally:
pnpm run dev - Submit a pull request
Next steps
Configuration Guide
Learn about all environment variables and configuration options
Deployment Guide
Production deployment strategies for different platforms
Troubleshooting
Detailed troubleshooting guide for common issues
API Reference
Complete API documentation for your self-hosted instance
License: AGPL-3.0 • Repository: github.com/screenshothis/screenshothis