How ibrahim-string/kausal-paths works
Project Type and Purpose
• Kausal Paths is a Django-based web application that provides predictions for the future emissions of cities. It uses historical emissions data and models multiple climate action scenarios.
• The main external interface is a GraphQL API (available at /v1/graphql/), meaning that client applications or dashboards fetch and possibly post data through this layer.
Analyzing the File Structure
• The project is split into multiple Django “apps” (each represented by a directory with models, migrations, views, and tests). Key apps include:
– admin_site: Contains custom administration functionality (with Wagtail hooks and templates for the admin interface).
– datasets: Manages data ingestion and storage (with management commands to load and store data using DVC).
– frameworks: Handles configuration and structure for different emission analysis “frameworks” (including importers and sync commands).
– nodes: Implements business logic, calculations, and node-based operations – including modules for energy saving, cost calculations, and more.
– pages, params, and users: Responsible for content management, application parameters and settings, and user management respectively.
– paths: Acts as the main project configuration, holding settings, URL routing, authentication, GraphQL schemas, and middleware.
• Additionally, there is a separate module (gql_client) for GraphQL query definitions, which supports the API-driven nature of the project.
• Multiple configuration files and Docker-related files indicate that the project supports containerized deployment and automated CI/CD.
Insights from the README
• The README outlines that the project is deployed as a backend service exposing a GraphQL endpoint.
• It describes a development workflow using Python virtual environments, migrations, and running the Django server.
• There is emphasis on local settings (for example, setting up Postgres as the backend database) and the usage of translations (indicating localization).
a. Main Components
• Client / Frontend: Although this is primarily a backend application, the admin interface (admin_site with Wagtail templates) and any external dashboards or clients that use the GraphQL API are important.
• GraphQL API Layer: Mark the endpoint (http://127.0.0.1:8000/v1/graphql/) that connects external requests to the underlying logic.
• Django Application Core: Represent it as a container that comprises multiple Django apps – nodes, datasets, frameworks, pages, params, and users – each responsible for a different aspect of emissions prediction and data management.
• Database: PostgreSQL is indicated via the local_settings.py configuration.
• External / Infrastructure: Include Docker containers (as defined by Dockerfiles and docker-compose configurations) and CI/CD pipelines (GitHub workflows).
b. Relationships and Interactions
• Inside the Django container, illustrate how the GraphQL API layer hands off processing to various apps. For example, a query about historical emissions may be processed by the datasets app which in turn may consult models and trigger computations implemented in nodes.
• The admin site (with Wagtail integration) should be shown as a separate UI module that allows administrative users to manage content, configurations, and review data.
c. Architectural Patterns and Design Principles
• Modular design patterned on Django apps, showing clear boundaries (for example, nodes for business logic, datasets for data management, frameworks for configuration).
• Use of GraphQL as an API abstraction layer that decouples the frontend/client from backend business logic.
• Integration of Docker for containerization and the use of CI/CD (GitHub workflows) for testing and deployment.
d. Technologies, Frameworks, and Libraries
• Django (and possibly Wagtail for the admin interface) is the backbone of the application.
• GraphQL is the chosen API technology, and gql_client supports its operation.
• PostgreSQL (as configured in local_settings.py) is the persistence layer.
• Docker for containerized deployment, along with GitHub Actions (as seen in the .github/workflows directory) for CI/CD.