The a11yhood backend is designed to provide access to the a11yhood data and to support scraping of new data. See the a11yhood frontend (a11yhood/a11yhood.github.io) for the ux side of this project.
Additional documentation files can be found in the documentation directory.
backend/
βββ main.py # FastAPI application entry point
βββ config.py # Configuration and environment settings
βββ database_adapter.py # Database access wrapper used by the API and scripts
βββ requirements.txt # Python dependencies
βββ pyproject.toml # Project metadata and dependencies
β
βββ models/ # Data models
β βββ activities.py
β βββ blog_posts.py
β βββ collections.py
β βββ discussions.py
β βββ product_urls.py
β βββ products.py
β βββ ratings.py
β βββ reviews.py
β βββ scrapers.py
β βββ sources.py
β βββ users.py
β
βββ routers/ # API route handlers
β βββ activities.py
β βββ blog_posts.py
β βββ collections.py
β βββ discussions.py
β βββ product_urls.py
β βββ products.py
β βββ ratings.py
β βββ requests.py
β βββ scrapers.py
β βββ sources.py
β βββ users.py
β
βββ services/ # Business logic and utilities
β βββ auth.py # Authentication handling
β βββ database.py # Database connections
β βββ scrapers.py # Scraping logic
β βββ sources.py # Source management
β βββ scheduled_scrapers.py # Scheduled scraping jobs
β βββ security_logger.py # Security event logging
β βββ error_handler.py
β βββ id_generator.py
β βββ sanitizer.py # HTML/text sanitization
β
βββ scrapers/ # Platform-specific scrapers
β βββ base_scraper.py
β βββ github.py
β βββ goat.py
β βββ ravelry.py
β βββ thingiverse.py
β βββ scraper.py
β
βββ migrations/ # Database migration scripts
βββ scripts/ # Utility scripts
βββ seed_scripts/ # Database seeding scripts
βββ tests/ # Test suite
βββ documentation/ # Detailed documentation
βββ certs/ # SSL certificates for development
- Docker & Docker Compose (recommended) OR
- Python 3.14+ with pip/venv
- Supabase/PostgreSQL access for development and production workflows
-
Clone the repository
git clone https://github.com/a11yhood/backend.git cd backend -
Configure environment
cp .env.example .env # Edit .env with your settings if needed
# Start development server
# The API will be available at `https://localhost:8000/api`
./scripts/start-dev.sh
# Start with database reset
./scripts/start-dev.sh --reset-db
# Start production server
# The API will be available at `https://localhost:8001/api`
./scripts/start-prod.sh
# Start production server using the compiled docker image on github
# The API will be available for external use
./scripts/start-prod.sh --no-build
# Stop the server
./scripts/stop-dev.sh# Create virtual environment
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run directly
python main.py
# Or with uvicorn:
uvicorn main:app --reload --ssl-keyfile=localhost+2-key.pem --ssl-certfile=localhost+2.pemThe API is organized into the following resource groups:
| Resource | Endpoint | Purpose |
|---|---|---|
| Users | /api/users |
User profiles and authentication |
| Products | /api/products |
Product listings, search, filtering |
| Sources | /api/sources |
Product source platforms (GitHub, Ravelry, etc.) |
| Ratings | /api/ratings |
Product ratings and credibility |
| Reviews | /api/reviews |
Detailed product reviews |
| Collections | /api/collections |
User-created product collections |
| Discussions | /api/discussions |
Threaded discussions about products |
| Scrapers | /api/scrapers |
Web scraper management |
| Blog Posts | /api/blog_posts |
Community blog content |
| Activities | /api/activities |
User activity feed |
Most endpoints require authentication via OAuth (GitHub) or JWT tokens. Include the authorization header:
Authorization: Bearer <token>
Configuration is managed via environment variables in .env:
# Server
ENVIRONMENT=development
HOST=localhost
PORT=8001
# Database
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-service-role-key
SUPABASE_ANON_KEY=your-anon-key
# OAuth
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
# API Keys
SUPABASE_URL=...
SUPABASE_KEY=...
# CORS
ALLOWED_ORIGINS=http://localhost:4173,https://localhost:4173See .env.example for a complete list of configuration options.
- QUICK_START.md β One-command startup, URLs, seeded users, quick troubleshooting
- LOCAL_TESTING.md β Full local setup, env vars, test data seeding, common tasks
- DEVELOPER_GUIDE.md β End-to-end development workflow
- PRD.md β Product requirements
- AGENT_GUIDE.md β What an agent should read and the helper conventions to follow
Additional documentation in the documentation/ folder:
- LOCAL_TESTING.md - Local development and testing guide
- API_REFERENCE.md - Detailed API endpoint reference
- CODE_STANDARDS.md - Coding standards and conventions
- SECURITY_BEST_PRACTICES.md - Security guidelines
- ARCHITECTURE.md - System architecture and design
For additional documentation, use the guides listed above and browse the documentation/ folder directly.
This repository publishes release artifacts from tags, not from every merge to main.
- Pull request to
main: validation/build checks run. - Push tag
v*: Docker image publish workflow runs. - There is currently no repository workflow triggered by
db-v*tags.
- Open a PR to
mainand wait for checks to pass. - Merge the PR.
- If you want to publish an app image, create and push an app tag:
git checkout main
git pull
git tag vX.Y.Z
git push origin vX.Y.Z- If you want to publish DB exports, create and push a DB tag:
git checkout main
git pull
git tag db-vX.Y.Z
git push origin db-vX.Y.Z- Use semantic versioning for both app and DB tags.
- Cut tags from up-to-date
mainonly. - Do not push release tags from feature branches.
Run the test suite using the provided script:
# Run all tests
./scripts/run-tests.sh
# Run with verbose output
./scripts/run-tests.sh -v
# Run specific test
./scripts/run-tests.sh -k test_name
# Run with coverage report
./scripts/run-tests.sh --cov
# Show help
./scripts/run-tests.sh --helpKey test commands are documented in documentation/QUICK_TEST_GUIDE.md.
This project prioritizes security and accessibility:
- CORS - Restricted to trusted origins
- Rate Limiting - API rate limiting via slowapi
- SQL Injection Prevention - SQLAlchemy parameterized queries
- XSS Protection - HTML sanitization via bleach
- Authentication - OAuth 2.0 and JWT tokens
- HTTPS - SSL/TLS for all communications
See documentation/SECURITY_BEST_PRACTICES.md for detailed security information.
a11yhood uses Supabase/PostgreSQL for both production and the shared test environment.
Database schema and migrations:
- Schema: supabase-schema.sql
- Migrations: migrations/ directory
The platform includes scrapers for multiple sources:
- GitHub - Open-source accessible projects
- Ravelry - Accessible crafting patterns
- Thingiverse - Accessible 3D printable designs
Scrapers run on a schedule and can be manually triggered. See documentation/AGENT_GUIDE.md for scraper management.
For most development tasks, the provided scripts handle setup automatically. If you need to install dependencies manually:
# Create virtual environment (if not using scripts)
python3 -m venv .venv
source .venv/bin/activate
# Install development dependencies
pip install -r requirements.txt
pip install -e . # Install in editable mode
# Set up pre-commit hooks (recommended)
git config core.hooksPath .git/hooksThe development server automatically reloads on code changes:
./scripts/start-dev.sh# Seed test data
python seed_scripts/seed_all.py
# Reset the test database from the checked-in snapshot
pixi run reset- Follow documentation/CODE_STANDARDS.md
- Create tests in
tests/ - Run tests locally before pushing
- Update documentation for API changes
- Create a route handler in
routers/ - Define models in
models/ - Add business logic in
services/ - Write tests in
tests/ - Document in documentation/API_REFERENCE.md
- Create scraper class in
scrapers/extendingBaseScraper - Add source configuration
- Register in scraper registry
- Add tests for scraper functionality
- Create migration file in
migrations/with timestamp prefix - Apply migration to the production and test Supabase projects
- Update schema documentation
- Update models if schema changes
- Port 8001 already in use: Kill the process or use different port:
PORT=8002 python main.py - Database connection error: Check your Supabase credentials in
.envor.env.test, and setSUPABASE_DB_URLwhen a direct Postgres connection is required - CORS errors: Verify
ALLOWED_ORIGINSin.envincludes your frontend URL - Scraper failures: Check scraper logs and network connectivity
See documentation/LOCAL_TESTING.md for more troubleshooting help.
- Rate limiting is configured via
slowapi - Database queries are optimized with indexes
- Scheduled scrapers run asynchronously
- Activities and events are logged for debugging
Please follow the CODE_STANDARDS.md and ensure:
- All tests pass locally
- Code follows the project standards
- Documentation is updated
- Commit messages are clear and descriptive
This project is licensed under the LICENSE file in this repository.
##Support & Issues
For issues, questions, or feature requests:
- Check existing GitHub Issues
- Review documentation/ for existing guidance
- Create a new issue with detailed information
- For security issues, follow responsible disclosure
- Check documentation/LOCAL_TESTING.md for complete local setup
- Review API_REFERENCE.md for endpoint details
- See AGENT_GUIDE.md for development patterns
- Visit the examples notebook for request/response examples