Project ClientZero/clientzero-be Public

ClientZore BackEnd

8 branches
clientzero-be
README

clientzero-be

ClientZero helps startups find their first clients: co-founders, businesses, other startups and beta testers. This is the backend: Django, DRF, Celery, PostgreSQL 16 + pgvector, with RabbitMQ, Valkey and an S3 bucket from CodePinion. See docs/PRODUCT.md for the product design.

Status: early. The data models for people, companies, links, contact points and locations exist, are tested and have migrations, and Swagger is wired up. The login, profile, company, member and invitation APIs exist, and emails run as Celery tasks. Matching, embeddings and the rest do not yet.

Technology

AreaWhat we use
Language and frameworkPython 3.12 or newer, Django 6.1, Django REST framework
API contractdrf-spectacular (OpenAPI, committed as docs/openapi.json)
Authdjangorestframework-simplejwt: short-lived access token, refresh token in an httpOnly cookie
DatabasePostgreSQL 16 with pgvector (psycopg 3)
Background workCelery 5.6 on RabbitMQ; chains, groups and chords for workflows; no Airflow
Cache and resultsValkey (Redis protocol)
FilesS3-compatible bucket via django-storages and boto3; WhiteNoise as the local fallback
Matching (planned)sentence-transformers all-MiniLM-L6-v2, 384-d vectors in pgvector
Outside services (planned)an email provider, an SMS provider (Africa's Talking), and Claude and GPT for document reading, only from Celery tasks
Tests and qualitypytest, pytest-django, pytest-env, moto; black, isort, flake8; gitleaks in CI
Hosting and CICodePinion (Hosted Apps, its own workflow files in .codepinion/workflows/)

The frontend is a separate repository, clientzero-fe.

What exists

AppHolds
accountsUser (email login, optional phone, verification times), UserProfile
companiesCompany, CompanyMembership (owner, co-founder, member), CompanyInvitation
contactsWebLink (websites and social profiles), ContactPoint (extra emails, phones)
locationsPlace (GeoNames lookup), Location
social_accountsLinkedProvider: Google, GitHub and CodePinion sign-in (docs/OAUTH.md)
workflowsWorkflowRun: the durable record of each Celery workflow run

See docs/DATA_MODEL.md for the rules each model enforces.

Local setup

python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements-dev.txt
cp .env.example .env            # then edit: secret key, DATABASE_URL, BROKER_URL, VALKEY_URL
docker run -d --name clientzero-test-db -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=clientzero -p 5433:5432 pgvector/pgvector:pg16
make check                      # black, isort, flake8, pytest

Tests use DATABASE_URL, or fall back to the container above (port 5433). They run Celery tasks inline and need no broker, cache or bucket.

Running it

python manage.py migrate
python manage.py runserver                                      # the API
celery -A config worker -Q default,emails,embeddings -l info    # background work

Emails (sign-up verification, password reset, invitations) are sent by the worker and print in its terminal until an email provider is chosen. Logging and error handling are in docs/LOGGING.md. Setting up RabbitMQ and Valkey, the everyday Celery commands, writing tasks and workflows, and troubleshooting are in docs/CELERY.md. Every setting is listed in .env.example.

All tests live in tests/, mirroring the source tree. See docs/ for architecture and decisions.

API documentation

With the server running: Swagger UI at /api/docs/, ReDoc at /api/redoc/, and the OpenAPI schema at /api/schema/. The committed contract is docs/openapi.json; a test fails if it is out of date (see docs/ARCHITECTURE.md).

Loading places

Place search (the location question in the company setup) needs the places loaded. One command downloads the GeoNames list of cities and loads it, locally and on the deployed app alike:

python manage.py import_cities                       # cities with 15,000+ people
python manage.py import_cities --dataset cities1000  # more towns (cities5000, cities1000)

It is safe to run again; existing places are updated and nothing is deleted. To load a file you already have, or a whole country, use python manage.py import_geonames path/to/file.txt [--min-population N] (files are at https://download.geonames.org/export/dump/).

License and contributing

Licensed under the GNU AGPL-3.0. Contributions are welcome from anyone; see CONTRIBUTING.md (commits are signed off under the DCO). The ClientZero name and logo are not licensed for reuse; see TRADEMARK.md.

Sprints and tasks

Work is tracked on CodePinion. Install the CodePinion skill to manage sprints, tasks and goals; see CONTRIBUTING.md.

About

ClientZore BackEnd

8 branches
AGPL-3.0-only
Updated 1 day ago
Contributors

Languages

Python100%
Makefile0%

Clone

https://api.codepinion.co.ke/git/project-clientzero/clientzero-be.git
git clone https://api.codepinion.co.ke/git/project-clientzero/clientzero-be.git