Skip to main content

PostgreSQL

OWASP Nest uses PostgreSQL as its primary database. The Django ORM manages all schema changes through versioned migration files located in each app’s migrations/ directory. Connection settings are configured through environment variables:
VariableDescription
DJANGO_DB_HOSTDatabase server hostname
DJANGO_DB_PORTDatabase server port (default 5432)
DJANGO_DB_NAMEDatabase name
DJANGO_DB_USERDatabase username
DJANGO_DB_PASSWORDDatabase password
See Environment variables for the full reference.

pgvector

The pgvector PostgreSQL extension is used to store high-dimensional vector embeddings generated by OpenAI. These embeddings power the AI retrieval-augmented generation (RAG) features in the ai app, enabling semantic search over OWASP content such as projects, chapters, repositories, and Slack messages. The pgvector Python package (pgvector = "^0.4.1") is listed as a core dependency in pyproject.toml.

Migrations

OWASP Nest uses Django’s built-in migration framework. Migrations are auto-generated from model changes and applied with manage.py migrate.
# Generate new migration files after model changes
make migrations

# Apply all pending migrations
make migrate

# Merge diverging migration branches
make merge-migrations
Never modify existing migration files that have already been applied in production. Always generate a new migration to change a schema.

Key models

OWASP app

ModelDescription
ProjectAn OWASP project with level, type, leader, and health metrics.
ChapterA regional OWASP chapter with geographic coordinates, country, and region.
CommitteeAn OWASP committee.
EventA scheduled OWASP event.
SnapshotA periodic community snapshot recording new projects, chapters, issues, releases, and members within a date range.
SponsorAn OWASP sponsor organization.
MemberProfileExtended profile data for OWASP community members.

GitHub app

ModelDescription
OrganizationA GitHub organization (primarily the OWASP org and related orgs).
RepositoryA GitHub repository linked to an OWASP project or chapter.
IssueA GitHub issue with state, labels, assignees, and linked pull requests.
PullRequestA GitHub pull request, linked to closing issues via keywords.
ReleaseA GitHub release with tag name, published date, and body.
UserA GitHub user with login, name, and avatar.
LabelA GitHub label.
MilestoneA GitHub milestone.

Nest app

ModelDescription
UserThe custom Django user model referenced by AUTH_USER_MODEL.
ApiKeyAPI keys used to authenticate requests to the REST v0 API.

Algolia search index

Alongside PostgreSQL, Algolia provides fast full-text search for the frontend. The algoliasearch-django library synchronizes model data to Algolia indices when records are saved. Key operations:
# Re-index all data in Algolia
make index-data
This runs three management commands in sequence:
python manage.py algolia_reindex
python manage.py algolia_update_replicas
python manage.py algolia_update_synonyms
Algolia indices are prefixed with the value of DJANGO_CONFIGURATION (lowercased), so local development writes to local_* indices and never pollutes production data.
Exclude specific indices from local indexing using DJANGO_ALGOLIA_EXCLUDED_LOCAL_INDEX_NAMES.

Loading and restoring data

# Restore a pg_dump from backend/data/nest.dump
make load-data

# Create a new dump
make dump-data

Build docs developers (and LLMs) love