2.1 KiB
2.1 KiB
Developer's Introduction
Overview
ContentDB is a Python Flask webservice, with a PostgreSQL database.
To avoid blocking web requests, background jobs run as Celery tasks.
Locations
The App
The app directory contains the Python Flask application.
blueprintscontains all the Python code behind each endpoint. A blueprint is a Flask construct to hold a set of endpoints.templatescontains all the HTML templates used to generate responses. Each directory in here matches a director in blueprints.modelscontains all the Database table classes. ContentDB uses SQLAlchemy to interact with PostgreSQL.flatpagescontains all the markdown user documentation, including/help.publiccontains files that should be added to the web server unedited. Examples include CSS libraries, images, and JS scripts.scsscontains the stylesheet files, that are compiled into CSS.taskscontains the background tasks executed by Celery.logicis a collection of reusable functions. For example, shared code to create a release or edit a package is here.testscontains the Unit Tests and UI tests.utilscontain generic Python utilities, for example common code to manage Flask requests.
There are also a number of Python files in the app directory. The most important one is querybuilder.py,
which is used to generate SQLAlachemy queries for packages and topics.
Supporting directories
migrationscontains code to manage database updates.translationscontains user-maintained translations / locales.utilscontains bash scripts to aid development and deployment.
How to find stuff
Generally, you want to start by finding the endpoint and then seeing the code it calls.
Endpoints are sensibly organised in app/blueprints.
You can also use a file search. For example, to find the package edit endpoint, search for .route("/packages/<author>/<name>/edit/").