This repository is now a read-only archive. Dalgo has moved to a monorepo at DalgoT4D/dalgo. All active development, issues, and contributions should go there.
Django application for the DDP platform's management backend. Exposes API endpoints for the management frontend to communicate with, for the purposes of
- Onboarding an NGO client
- Adding users from the client-organization
- Creating a client's workspace in our Airbyte installation
- Configuring that workspace i.e. setting up sources, destinations and connections
- Configuring data ingest jobs in our Prefect setup
- Connecting to the client's dbt GitHub repository
- Configuring dbt run jobs in our Prefect setup
- REST conventions are being followed.
- CRUD end points for a User resource would look like:
- GET /api/users/
- GET /api/users/user_id
- POST /api/users/
- PUT /api/users/:user_id
- DELETE /api/users/:user_id
- Route parameteres should be named in snake_case as shown above.
- All api docs are at
http://localhost:8002/api/docs
Pep8has been used to standardized variable names, classes, module names etc.Pylintis the linting tool used to analyze the code as per Pep8 style.Blackis used as the code formatter.
- Recommended IDE is VsCode.
- Install the pylint extension in vscode and enable it.
- Set the default format provider in vscode as
black - Update the vscode settings.json as follows
{ "editor.defaultFormatter": null, "python.linting.enabled": true, "python.formatting.provider": "black", "editor.formatOnSave": true }
The project uses uv as its package manager. You will need to install it on your machine
UV can be installed system-wide using cURL on macOS and Linux:
curl -LsSf https://astral.sh/uv/install.sh | sudo shAnd with Powershell on Windows (make sure you run Powershell with administrator privileges):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"UV is available via Homebrew as well:
brew install uvuv sync- Run "pre-commit install" after activating your virtual env created in above step
- Run "pre-commit run --all-files" to run the formatter
- create
.envfrom.env.template
-
create a SQL database and populate its credentials into
.env -
You can use a postgresql docker image for local development
docker run --name postgres-db -e POSTGRES_PASSWORD=<password> -p 5432:5432 -d <db name>
- Add the environment variable to .env
DBNAME=<db name>
DBHOST=localhost
DBPORT=5432
DBUSER=postgres
DBPASSWORD=<password>
DBADMINUSER=postgres
DBADMINPASSWORD=<password>
- Open a new terminal
- Download run-ab-platform.sh for Airbyte 0.58.0
- Run
./run-ab-platform.shto start Airbyte. This is a self-contained application which includes the configuration database - Populate Airbyte connection credentials in the
.envfrom Step 2:
AIRBYTE_SERVER_HOST=localhost
AIRBYTE_SERVER_PORT=8000
AIRBYTE_SERVER_APIVER=v1
AIRBYTE_API_TOKEN= <token> # base64 encryption of username:password. Default username and password is airbyte:password and token will be YWlyYnl0ZTpwYXNzd29yZA==
AIRBYTE_DESTINATION_TYPES="Postgres,BigQuery"
- Start Prefect Proxy and populate connection info in
.env
PREFECT_PROXY_API_URL=
- Set
DEV_SECRETS_DIRin.envunless you want to use Amazon's Secrets Manager
All orgs run on dbt-core 1.10.19. Set up a local venv from the pinned pyproject.toml:
cd ../prefect-proxy/docker/dbt-1.10.19/
uv syncThe uv.lock file is committed for reproducible versions.
Set the DBT client root in .env:
CLIENTDBT_ROOT=/path/to/client/dbt/projects
- The
SIGNUPCODEin.envis for signing up using the frontend. If you are running the frontend, set its URL inFRONTEND_URL
DJANGOSECRET=
-
Create logs folder in
ddpui -
create
whitelist.pyfrom.whitelist.template.pyin ddpui > assets folder -
Run DB migrations
python manage.py migrate -
Seed the DB
python manage.py loaddata seed/*.json -
Create the system user
python manage.py create-system-orguser -
Start the server
uvicorn ddpui.asgi:application --port <PORT_TO_LISTEN_ON>
- Run
python manage.py createorganduser <Org Name> <Email address> --role super-admin - The above command creates a user with super admin role. If we don't provide any role, the default role is of account manager.
We use two separate Celery workers for better task isolation:
- In your virtual environment run:
celery -A ddpui worker -Q default -n ddpui - For windows run:
celery -A ddpui worker -Q default -n ddpui -P solo
- In another terminal with the same virtual environment:
celery -A ddpui worker -Q canvas_dbt -n canvas_dbt --concurrency=2 - For windows run:
celery -A ddpui worker -Q canvas_dbt -n canvas_dbt --concurrency=2 -P solo
- In another terminal with the same virtual environment:
celery -A ddpui worker -Q trial_clone -n trial_clone --autoscale=4,1 - For windows run:
celery -A ddpui worker -Q trial_clone -n trial_clone --autoscale=4,1 -P solo
- To start celery beat run:
celery -A ddpui beat
Note: The Canvas DBT worker handles resource-intensive DBT operations from the canvas, the Trial Clone worker handles trial account creation (autoscales 1-4 processes with load), while the default worker handles other background tasks like notifications and maintenance.
Follow the steps below:
- Install docker
- Install docker-compose
- create
.env.dockerfrom.env.templateinside the Docker folder
- Copy the file in ddpui/assets/ to Docker/mount
If using M1-based MacBook run this before building image
export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker build -f Docker/Dockerfile.main --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t dalgo_backend_main_image:0.1 .This will create the main imagedocker build -f Docker/Dockerfile.dev.deploy --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -t dalgo_backend:0.1 .
docker compose -p dalgo_backend -f Docker/docker-compose.yml --env-file Docker/.env.docker up -ddocker compose -p dalgo_backend -f Docker/docker-compose.yml --env-file Docker/.env.docker down
The platform supports feature flags to control the availability of features at both global and organization-specific levels. Organization-specific flags override global flags.
DATA_QUALITY- Elementary data quality reportsUSAGE_DASHBOARD- Superset usage dashboard for orgEMBED_SUPERSET- Embed superset dashboardsLOG_SUMMARIZATION- Summarize logs using AIAI_DATA_ANALYSIS- Enable data analysis using AIDATA_STATISTICS- Enable detailed data statistics in explore
Global flags apply to all organizations by default:
from ddpui.utils.feature_flags import enable_feature_flag, disable_feature_flag
# Enable a global flag
enable_feature_flag("DATA_QUALITY") # org=None for global
# Disable a global flag
disable_feature_flag("DATA_QUALITY")Organization-specific flags override global flags for that particular org:
from ddpui.models.org import Org
from ddpui.utils.feature_flags import enable_feature_flag, disable_feature_flag
# Get the organization
org = Org.objects.get(slug="org-slug")
# Enable for specific org (overrides global setting)
enable_feature_flag("DATA_QUALITY", org=org)
# Disable for specific org
disable_feature_flag("DATA_QUALITY", org=org)Use the Django management command to manage flags via CLI:
# Enable all available global feature flags
python manage.py manage_feature_flags --enable-all-global
# Enable a specific flag globally
python manage.py manage_feature_flags --enable DATA_QUALITY
# Disable a specific flag globally
python manage.py manage_feature_flags --disable DATA_QUALITY
# Enable for a specific organization
python manage.py manage_feature_flags --enable DATA_QUALITY --org-slug org-slug
# Disable for a specific organization
python manage.py manage_feature_flags --disable DATA_QUALITY --org-slug org-slugFrontend applications can fetch the feature flags for the current organization:
GET /api/organizations/flags
This endpoint returns a JSON object with all feature flags and their status for the authenticated user's organization. The response includes both global flags and any organization-specific overrides.