Overview
The OWASP Nest backend is built with Django 6.0 and Python 3.13, using modern Python frameworks and libraries for API development, search, and AI features.Tech Stack
Django 6.0
Web framework
Django Ninja
REST API framework
Strawberry
GraphQL library
PostgreSQL
Primary database
Redis
Cache & queue
Poetry
Dependency management
Project Structure
Development Setup
Prerequisites
Ensure you have completed the local development setup first.Dependencies
Dependencies are managed with Poetry and defined inpyproject.toml:
- Core
- Search & AI
- Integrations
- Testing
pyproject.toml
Update Dependencies
poetry update to update all backend dependencies.
Common Commands
- Django
- Data Management
- Database
Django Apps
AI App
Provides AI-powered features using LangChain and OpenAI:Agent System
Agent System
LangGraph Agent (
apps/ai/agent/)- Natural language query processing
- Multi-step reasoning with tools
- RAG (Retrieval-Augmented Generation)
- Context-aware responses
Vector Embeddings
Vector Embeddings
pgvector Integration
- Document chunking and embedding
- Semantic similarity search
- Context retrieval for RAG
Embedding- Vector representationsContext- Document contextsChunk- Text chunks
Management Commands
Management Commands
API App
Provides REST and GraphQL endpoints:- REST API
- GraphQL API
Django Ninja (Features:
apps/api/rest/)Base URL: /api/v0/apps/api/rest/projects.py
- Automatic OpenAPI docs at
/api/docs - Pydantic schema validation
- Built-in filtering and pagination
GitHub App
Syncs data from GitHub:Models
Models
Key models in
apps/github/models/:GitHubOrganization- OWASP and related orgsGitHubRepository- Project repositoriesGitHubIssue- Issues and contribution opportunitiesGitHubUser- User profilesGitHubPullRequest- Pull requests
Sync Commands
Sync Commands
API Integration
API Integration
Uses PyGithub for GitHub API access:
OWASP App
Manages OWASP-specific data:- Projects
- Chapters
- Committees
Project Model (
apps/owasp/models.py)Fields:name- Project namedescription- Project descriptionlevel- Project level (Lab, Production, Flagship)type- Project type (Code, Documentation, Tool)leaders_raw- Project leaders (JSON)repositories- Related GitHub repos (M2M)url- Project website
Slack App
NestBot Slack integration:Slash Commands
Slash Commands
Located in
apps/slack/commands/:/nest-find-issues- Search contribution opportunities/nest-find-projects- Search OWASP projects/nest-help- Get help
apps/slack/commands/find_projects.py
Event Handlers
Event Handlers
Located in
apps/slack/events/:app_mention- Handle @NestBot mentionsmessage- Handle DMs
Sync Data
Sync Data
- User profiles
- Channel information
- Message history
Configuration
Django Settings
Settings are organized usingdjango-configurations:
- Base
- Local
- Production
base.py - Shared settings
settings/base.py
Environment Variables
Key variables inbackend/.env:
.env
Testing
Test Configuration
Tests use pytest with Django plugin:pyproject.toml
Running Tests
Writing Tests
- Model Tests
- API Tests
- GraphQL Tests
tests/test_models.py
Code Quality
Linting & Formatting
backend/.pre-commit-config.yaml):
- Ruff - Python linter and formatter
- mypy - Type checking
- djlint - Django template linting
Ruff Configuration
pyproject.toml
Database Management
Migrations
Database Shell
Background Jobs
Django RQ
Background tasks use Redis Queue:apps/ai/tasks.py
docker-compose/local/compose.yaml:
Debugging
Django Debug Toolbar
Enabled in local development:- Visit any page
- Click debug toolbar on right side
- View SQL queries, cache hits, etc.
Python Debugger
- pdb
- ipdb
- VS Code
Logs
Next Steps
Frontend Development
Learn about Next.js frontend development
Testing Guide
Write and run tests
API Reference
Explore API endpoints
Contributing
Contribution guidelines