Holding government institutions accountable through automated website performance and quality analysis.
Watchtower is a FastAPI-based service that monitors and evaluates government websites to ensure taxpayer money is being used effectively for digital services. The API automatically scans government websites, analyzes their performance using Google PageSpeed Insights, and critiques their design and content using AI-powered analysis.
Government websites should serve citizens effectively. Watchtower provides transparency by:
- Performance Monitoring: Tracking load times, accessibility, and technical performance
- AI-Powered Critique: Analyzing design quality, content clarity, and user experience
- Public Accountability: Creating leaderboards to highlight best and worst performers
- Data-Driven Insights: Providing actionable feedback for improvement
- API Framework: FastAPI
- Package Management: Poetry
- Database: Supabase (PostgreSQL)
- Performance Analysis: Google PageSpeed Insights API
- Web Crawling: Playwright
- AI Analysis: OpenAI/Anthropic APIs
- Python Version: 3.11+
- Website Registry: Maintain a database of government websites to monitor
- Automated Scanning: Scheduled performance and quality assessments
- Performance Metrics: PageSpeed Insights integration for Core Web Vitals
- AI Content Analysis: Automated critique of design, accessibility, and content quality
- Leaderboard System: Ranking websites from best to worst performers
- Historical Tracking: Monitor improvements or degradation over time
GET /websites
- List all monitored government websitesPOST /websites
- Add new website to monitoringGET /websites/{id}/reports
- Get analysis reports for a specific websiteGET /leaderboard
- View ranked performance leaderboardPOST /scan/{id}
- Trigger manual scan of a websiteGET /metrics
- Overall system metrics and statistics
- Core Web Vitals: LCP, FID, CLS scores
- PageSpeed Score: Overall performance rating
- Accessibility: WCAG compliance assessment
- Best Practices: Security and modern web standards
- Design Quality: Visual hierarchy, modern design principles
- Content Clarity: Language accessibility, information architecture
- User Experience: Navigation, mobile responsiveness
- Accessibility: Screen reader compatibility, color contrast
- Government Standards: Compliance with digital service standards
watchtower-api/
βββ app/
β βββ api/
β β βββ endpoints/
β β β βββ websites.py
β β β βββ reports.py
β β β βββ leaderboard.py
β β βββ deps.py
β βββ core/
β β βββ config.py
β β βββ security.py
β β βββ database.py
β βββ models/
β β βββ website.py
β β βββ report.py
β β βββ analysis.py
β βββ services/
β β βββ pagespeed.py
β β βββ crawler.py
β β βββ ai_analyzer.py
β β βββ scheduler.py
β βββ main.py
βββ tests/
βββ scripts/
βββ pyproject.toml
βββ README.md
βββ .env.example
- Python 3.11+
- Poetry
- Supabase account
- Google PageSpeed Insights API key
- OpenAI/Anthropic API key
-
Clone the repository
git clone https://github.com/codeforpakistan/watchtower-api.git cd watchtower-api
-
Install dependencies
poetry install
-
Environment setup
cp .env.example .env # Edit .env with your configuration
-
Database setup
poetry run python scripts/init_db.py
-
Run the application
poetry run uvicorn app.main:app --reload
# Database
SUPABASE_URL=your_supabase_url
SUPABASE_KEY=your_supabase_anon_key
# APIs
GOOGLE_PAGESPEED_API_KEY=your_pagespeed_api_key
OPENAI_API_KEY=your_openai_api_key
# Application
API_V1_STR=/api/v1
PROJECT_NAME=Watchtower API
DEBUG=False
# Scheduling
SCAN_INTERVAL_HOURS=24
MAX_CONCURRENT_SCANS=5
websites
id
(UUID, Primary Key)name
(Text) - Website/Agency nameurl
(Text) - Website URLgovernment_level
(Enum) - Federal, State, Localagency_type
(Text) - Department, Municipality, etc.created_at
(Timestamp)last_scanned
(Timestamp)
reports
id
(UUID, Primary Key)website_id
(UUID, Foreign Key)scan_date
(Timestamp)pagespeed_score
(Integer)core_web_vitals
(JSONB)ai_analysis
(JSONB)overall_score
(Float)
The AI analysis evaluates websites across multiple dimensions:
-
Accessibility Score (0-100)
- Color contrast ratios
- Alt text presence
- Keyboard navigation
- Screen reader compatibility
-
Design Quality Score (0-100)
- Visual hierarchy
- Modern design principles
- Consistency
- Professional appearance
-
Content Quality Score (0-100)
- Language clarity
- Information findability
- Content organization
- Citizen-focused messaging
-
Overall Usability Score (0-100)
- Combined weighted score
- Benchmarked against best practices
import requests
response = requests.post(
"http://localhost:8000/api/v1/websites",
json={
"name": "Department of Motor Vehicles",
"url": "https://dmv.example.gov",
"government_level": "state",
"agency_type": "department"
}
)
leaderboard = requests.get("http://localhost:8000/api/v1/leaderboard")
print(leaderboard.json())
docker build -t watchtower-api .
docker run -p 8000:8000 --env-file .env watchtower-api
- Set up proper logging and monitoring
- Configure rate limiting for external APIs
- Implement caching for frequently accessed data
- Set up automated backups for Supabase
- Use environment-specific configurations
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Phase 1: Core API with basic scanning
- Phase 2: AI analysis integration
- Phase 3: Public dashboard and leaderboards
- Phase 4: Automated reporting and alerts
- Phase 5: Historical trend analysis
- Phase 6: Cost-effectiveness analysis
For questions, suggestions, or issues:
- Create an issue on GitHub
- Email: [[email protected]]
- Twitter: [@watchtower_gov]
Empowering citizens through government website transparency and accountability.