Firewall Cafe is built as a modern web application with a React frontend, Express.js backend, and PostgreSQL database. The system compares search results from Google and Baidu in real-time, stores the data for analysis, and provides geographic visualization of censorship patterns.
┌─────────────────────────────────────────────────────────────────┐
│ Users │
└─────────────────┬───────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Frontend (React App) │
│ ┌────────────┐ ┌──────────┐ ┌────────────┐ ┌────────────┐ │
│ │ Search │ │ Analytics│ │ Heatmaps │ │ Voting │ │
│ │ Comparison │ │Dashboard │ │ View │ │ System │ │
│ └────────────┘ └──────────┘ └────────────┘ └────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ React Context (ApiContext) │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────┬───────────────────────────────────────────────┘
│ HTTP/HTTPS
▼
┌─────────────────────────────────────────────────────────────────┐
│ Express Proxy Server (Port 8080) │
│ ┌────────────┐ ┌──────────┐ ┌────────────┐ ┌────────────┐ │
│ │ Route │ │ CORS │ │ Auth │ │ Cache │ │
│ │ Handler │ │ Handling │ │Middleware │ │ Layer │ │
│ └────────────┘ └──────────┘ └────────────┘ └────────────┘ │
└─────────────────┬───────────────────────────────────────────────┘
│
┌─────────┴─────────┬──────────────┬────────────┐
▼ ▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌─────────┐ ┌──────────┐
│ Serper.dev │ │ Baidu Search │ │ Google │ │ IP │
│ (Google API) │ │ API │ │Translate│ │Geolocation│
└───────────────┘ └───────────────┘ └─────────┘ └──────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Backend API Service (Port 11458) │
│ ┌────────────┐ ┌──────────┐ ┌────────────┐ ┌────────────┐ │
│ │ queries.js│ │Analytics │ │ Voting │ │ Image │ │
│ │ Database │ │Endpoints │ │ Handler │ │ Storage │ │
│ └────────────┘ └──────────┘ └────────────┘ └────────────┘ │
└─────────────────┬───────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ PostgreSQL Database │
│ ┌────────────┐ ┌──────────┐ ┌────────────┐ ┌────────────┐ │
│ │ searches │ │ images │ │have_votes │ │ votes │ │
│ └────────────┘ └──────────┘ └────────────┘ └────────────┘ │
└─────────────────────────────────────────────────────────────────┘
Technology: React 18.2.0, Tailwind CSS 3.4.3
Key Components:
- SearchForm: Handles user search input and language detection
- SearchComparison: Displays side-by-side Google vs Baidu results
- GeographicHeatmap: Interactive world map with search density
- AnalyticsDashboard: Charts and metrics visualization
- VotingInterface: Community assessment of censorship
State Management: React Context API (ApiContext) for global state
Routing: React Router DOM v6 for client-side navigation
Port: 8080 (development), configurable for production
Responsibilities:
- Route proxying between frontend and backend services
- CORS handling for cross-origin requests
- Request/response transformation
- Static file serving
- Session management
Key Files:
/client/index.js- Main server file/client/server/fetch.js- API integration functions/client/server/config.js- Server configuration
- Serper.dev: Google search results (cost-effective alternative to SerpAPI)
- Baidu Custom Integration: Direct Baidu search API access
- Google Translate API: Automatic translation between English/Chinese
- IP Geolocation Service: Maps IP addresses to geographic locations
- Data Points: Country, region, city, coordinates
Port: 11458 (production at api.firewallcafe.com)
Database: PostgreSQL with connection pooling
Key Endpoints:
GET /dashboard - Overview statistics
GET /analytics/searches - Search trends and patterns
GET /analytics/votes - Voting analytics
GET /analytics/geographic - Geographic distribution
GET /searches - Search records
POST /searches - Save new search
GET /images - Image records
POST /votes - Submit vote
Authentication: Shared secret for write operations
Core Tables:
-
searches
- Primary storage for search queries
- Fields: id, query, translation, timestamp, location, metadata
- Indexes on timestamp, location, query
-
images
- Search result images
- Fields: id, search_id, url, rank, source_engine
- AWS CDN via DigitalOcean
-
have_votes
- Junction table linking searches to votes
- Fields: search_id, vote_id, user_identifier
-
votes
- Vote categories definition
- Categories: censored, uncensored, bad_translation, etc.
- User enters search term in frontend
- Frontend sends request to Express proxy
- Proxy forwards to search APIs (Google/Baidu)
- Translation service converts query if needed
- Results returned and displayed side-by-side
- Data saved to PostgreSQL for analysis
- Frontend requests analytics data
- Express proxy queries backend API
- Backend aggregates data from PostgreSQL
- Formatted data returned to frontend
- Charts and visualizations rendered
- User submits vote on search result
- Vote sent through Express proxy
- Backend validates and stores in database
- Analytics updated with new vote data
┌─────────────────────────────────────────────────────┐
│ Google Cloud Platform │
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ App Engine (Frontend) │ │
│ │ firewallcafe.com (port 443) │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Cloud SQL (PostgreSQL) │ │
│ │ Production Database │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────┐ │
│ │ Cloud Storage (Future: Images) │ │
│ │ CDN for image data │ │
│ └──────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘
App Engine:
- Auto-scaling Node.js environment
- HTTPS termination
- Load balancing
Cloud SQL:
- Managed PostgreSQL instance
- Automated backups
- High availability configuration
Cloud Storage:
- Image file storage
- CDN distribution via DigitalOcean
- Reduce database size
- Shared secret authentication for write operations
- Rate limiting on public endpoints
- CORS configuration for allowed origins
- PostgreSQL connection over SSL
- Environment variables for secrets
- No sensitive data in client code
- Anonymous voting system
- IP addresses hashed for privacy
- No personal data collection
- Code splitting and lazy loading
- Image lazy loading
- React.memo for expensive components
- Debounced search inputs
- Database connection pooling
- Query result caching
- Indexed database columns
- Batch operations where possible
- Browser caching for static assets
- API response caching (5 minutes)
- Database query result caching
- CDN caching for images
- Error tracking and logging
- Performance metrics
- API response times
- Database query performance
- Server health checks
- Database connection pool metrics
- API rate limit tracking
- Storage usage monitoring
- Single backend API instance
- No horizontal scaling for database
- Frontend: http://localhost:3000
- Express Proxy: http://localhost:8080
- Backend API: Direct database connection
- Hot module replacement enabled
- Debug logging active
- Frontend: https://firewallcafe.com
- API: https://api.firewallcafe.com
- Cloud SQL managed database
- Production logging to Cloud Logging
- Error reporting to monitoring service
- 2016-2020: WordPress on DreamHost
- 2020: PostgreSQL and API on Digital Ocean
- 2021-Present: Google Cloud Platform
- Schema 0: WordPress posts (2016)
- Schema 1: WordPress flattened data
- Schema 2: WordPress custom posts
- Schema 3: PostgreSQL current (2020+)
See Database Migration Guide for details.