Django-based REST API backend for CyberWiki - a collaborative documentation platform with Git integration.
Based on the Backend Design Specification, this backend implements:
- Django 5.2.9 + Django REST Framework 3.16.1
- Modular app structure: users, wiki, git_provider, source_provider, enrichment_provider
- SQLite (dev) / PostgreSQL (production)
- OpenAPI/Swagger documentation via drf-spectacular
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txtcp .env.example .env.dev
# Edit .env.dev with your settingspython manage.py migratepython manage.py createsuperuserpython manage.py runserverThe API will be available at:
- API: http://localhost:8000/api/
- Admin: http://localhost:8000/admin/
- API Docs: http://localhost:8000/api/docs/
- OpenAPI Schema: http://localhost:8000/api/schema/
From the main cyber-wiki repository root:
./scripts/run-local.shThis script will:
- Start the backend on port 8000
- Start the frontend on port 3000 (if available)
- Auto-create admin user (admin/admin)
.
├── src/ # Source code directory
│ ├── config/ # Django project settings
│ │ ├── settings.py # Main configuration
│ │ ├── urls.py # Root URL routing
│ │ └── wsgi.py # WSGI application
│ ├── users/ # User management & auth
│ ├── wiki/ # Wiki/document management
│ ├── git_provider/ # Git provider abstraction
│ ├── source_provider/ # Source addressing layer
│ └── enrichment_provider/ # Enrichment system
├── data/ # Runtime data (SQLite, etc.)
├── venv/ # Virtual environment (not in git)
├── manage.py # Django management script
├── requirements.txt # Python dependencies
└── requirements-prod.txt # Production dependencies (PostgreSQL)
GET /api/users/health/- Health check
GET /api/wiki/spaces/- List spaces
GET /api/git/repositories/- List repositories
GET /api/source/get/- Get source content
GET /api/enrichment/list/- List enrichments
Run unit tests with coverage:
# From repo root
./scripts/run-unit-tests.sh
# Or from backend directory
./scripts/run-unit-tests.sh
# With coverage report
pytest src/unit_tests/ --cov=src --cov-report=term-missing --cov-report=htmlCurrent Coverage: 21% (35 tests passing)
See COVERAGE.md for detailed coverage report.
Run integration tests:
# From repo root
./scripts/run-integration-tests.sh
# Or from backend directory
./scripts/run-integration-tests.shNote: Integration tests require API token. See integration test documentation.
Run both unit and integration tests:
./scripts/run-backend-tests.shRun pre-commit checks (unit tests + coverage):
./scripts/pre-commit-backend-tests.shThis will:
- ✅ Run all unit tests
- ✅ Generate coverage report
- ✅ Fail if coverage drops below 20%
- ✅ Create HTML coverage report in
htmlcov/
python manage.py startapp myappThen add to INSTALLED_APPS in config/settings.py.
python manage.py makemigrations
python manage.py migratepython manage.py shellSee .env.example for all available configuration options.
Key variables:
DJANGO_SECRET_KEY- Django secret key (required)DEBUG- Debug mode (default: True)ALLOWED_HOSTS- Comma-separated list of allowed hostsCORS_ALLOWED_ORIGINS- Comma-separated list of CORS originsDATABASE_URL- PostgreSQL connection string (optional)
This is a minimal stub implementation. See the Backend Design Specification for the full architecture and implementation roadmap