How creativecommons/cc-legal-tools-app works
Main Components
• Docker Setup / Orchestration:
• Docker Compose file (docker-compose.yml) orchestrates at least two containers:
○ “app” container: Runs the Django application (which processes requests, manages the Models in legal_tools and renders templates).
○ “static” container: Serves the generated static HTML and RDF/XML pages (output from the publishing process).
• Django Application:
• Core backend code exists in the “cc_legal_tools” and “legal_tools” directories. This includes:
○ Settings are stored in cc_legal_tools/settings (with different environments such as dev, local).
○ The main Django app aspects including URL routing (urls.py), WSGI configuration (wsgi.py) and model definitions (models.py in legal_tools).
• Management commands and scripts (found in “legal_tools/management” and “i18n/management”) that handle data loading, publishing, and translation tasks.
• Data Repository and Integration:
• The README instructs that this repository be used together with the cc-legal-tools-data repo.
• The publishing command (./manage.py publish -v2) outputs static files into the “docs/” directory inside the cc-legal-tools-data repository.
• Database and Models:
• The primary models (LegalCode and Tool) represent the legal tool metadata.
• Internationalization and Static Content:
• Files under “i18n” (e.g., translation scripts, templates, and commands) facilitate multi-language support.
• Template files in the “templates” directory and static resources (CSS, JS, images, RDF files) in cc_legal_tools/static provide front-end presentation and legal text/metadata.
Relationships and Data Flow
• Requests enter the system via the “app” container. The Django application processes these requests by:
• Reading settings from the configuration files.
• Accessing the database via Django’s ORM and retrieving legal tool data (using models in legal_tools).
• Rendering HTML responses with templates (found in the templates/ directory) and including internationalized legal texts.
• The publishing process (initiated via a management command) generates static versions of the legal tools (HTML pages and RDF/XML metadata) and writes them into the “docs/” directory in the companion data repository.
• The “static” container serves these pre-generated files to end-users as static content (usually used on the live website).
Architectural Patterns and Design Principles
• Separation of concerns is clearly applied by splitting dynamic application logic (Django backend) from static content serving.
• Modular design:
• The “legal_tools” module holds all core business logic, models, and views related to legal texts.
• The “cc_legal_tools” module handles project-wide settings and static file management.
• The “i18n” module is responsible for translation functionalities.
• Containerization via Docker ensures consistent deployment and environment parity.
Relevant Technologies
• Python 3.11, Django 4.2 (as specified by the Pipfile, Dockerfile, and workflows).
• Docker and Docker Compose for container orchestration.
• Git for version control and integration with GitHub.
• Pre-commit hooks, flake8, Black, isort, and other development tooling for code quality.
• Transifex for managing translations (linked via the i18n functionality).