# ferdesmello/drake-metaculus architecture

> Architecture diagram of the GitHub repository ferdesmello/drake-metaculus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ferdesmello/drake-metaculus
- Repository: https://github.com/ferdesmello/drake-metaculus

## Overview

1. **Repository shape**
   - This is a small, single-purpose **Python analysis project** centered on one script, `drake_metaculus.py`.
   - The repo is organized around **data inputs** and **generated figures**, not around multiple services or a package/module hierarchy.

2. **Primary computation goal**
   - The script computes a **distribution for the Drake equation output** `N`, rather than a single estimate.
   - Each Drake parameter is modeled as a probability distribution derived from Metaculus forecasts, and those distributions are combined to produce the final distribution of possible detectable civilizations.

3. **Input data subsystem**
   - The `data/` directory contains **seven parameter-specific folders**, one for each Drake equation term:
     `R_s`, `f_p`, `n_e`, `f_l`, `f_i`, `f_c`, and `L`.
   - Each folder contains:
     - `question_data.csv` for question-level metadata / target definition.
     - `forecast_data.csv` for forecast distributions over time.
     - a local `README.md` documenting that parameter’s source question.
   - This is the repo’s main data boundary: the script consumes these CSVs as the offline source of truth.

4. **External data acquisition boundary**
   - The script supports three modes via a `data_type` switch:
     - **0**: use local CSVs from `data/`
     - **1**: pull the user’s own forecast data from Metaculus API
     - **2**: pull aggregated forecast data from Metaculus API
   - So the architecture has a clear split between **offline reproducible analysis** and **online API-backed ingestion**.
   - Metaculus is the only external service that materially affects the pipeline.

5. **Forecast parsing layer**
   - The README indicates the script parses Metaculus forecast outputs into **PDFs and CDFs** for each parameter.
   - This parsing is a notable architectural boundary because the code is sensitive to Metaculus response format changes; the README explicitly notes multiple breakages from API format changes.
   - In other words, the ingestion/parsing layer is brittle and tightly coupled to Metaculus output structure.

6. **Parameter-level modeling**
   - Each of the seven Drake variables is treated as its own probabilistic input rather than a fixed constant.
   - The repo’s structure mirrors this one-parameter-per-folder design, which suggests the pipeline likely processes each parameter independently before combining them.
   - This modularity is important for diagramming: each parameter is a separate input stream feeding the final aggregation step.

7. **Aggregation / simulation core**
   - The central analytical step is combining the seven parameter distributions to compute the resulting distribution of `N`.
   - Conceptually, this is the main transformation boundary:  
     **Metaculus forecast distributions → derived parameter distributions → final Drake equation distribution**.
   - The README emphasizes that the output is itself a distribution, so the code likely performs numerical sampling or distribution convolution-style computation rather than direct algebraic evaluation.

8. **Visualization/output subsystem**
   - The `figures/` directory holds generated plots, including the final distribution graphic referenced in the README.
   - These figures are the primary output artifact of the repo, intended for inspection rather than downstream machine consumption.
   - No database, web UI, or persistent backend is present; outputs are static files.

9. **Execution model**
   - The whole pipeline is run by executing `drake_metaculus.py`.
   - The runtime appears to be a **single-process batch analysis job** that takes about a minute on the author’s machine.
   - That makes the architecture straightforward: one script orchestrates ingestion, parsing, computation, and plotting end-to-end.

10. **Operational implications**
   - The repo is optimized for **reproducible research / exploratory computation**, not for serving or interactive use.
   - The most important operational dependency is the availability and format stability of Metaculus data.
   - The local CSV mode acts as a reproducible fallback when API access is unavailable.

11. **What to show in an architecture diagram**
   - A good diagram would have:
     - seven parameter-specific data sources in `data/`
     - optional Metaculus API ingestion on the side
     - one central Python analysis step
     - a final visualization/output node writing into `figures/`
   - The key flow is **forecast data in → parsed distributions → combined Drake equation output → saved plots**.

Main entry points: [`drake_metaculus.py`](https://github.com/ferdesmello/drake-metaculus/blob/main/drake_metaculus.py) (drake_metaculus.py), [`data/Drake's_Equation_First_Parameter_R_s`](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_First_Parameter_R_s) (R_s data), [`data/Drake's_Equation_Second_Parameter_f_p`](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Second_Parameter_f_p) (f_p data), [`data/Drake's_Equation_Third_Parameter_n_e`](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Third_Parameter_n_e) (n_e data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_external["External"]
  node_metaculus_api(("Metaculus API<br/>external service"))
end

subgraph group_data["Data"]
  node_rs_data[("R_s data<br/>parameter dataset")]
  node_fp_data[("f_p data<br/>parameter dataset")]
  node_ne_data[("n_e data<br/>parameter dataset")]
  node_fl_data[("f_l data<br/>parameter dataset")]
  node_fi_data[("f_i data<br/>parameter dataset")]
  node_fc_data[("f_c data<br/>parameter dataset")]
  node_l_data[("L data<br/>parameter dataset")]
end

subgraph group_analysis["Analysis"]
  node_drake_metaculus_py["drake_metaculus.py<br/>batch analysis script<br/>[drake_metaculus.py]"]
  node_forecast_parser["Forecast parser<br/>ingestion layer"]
  node_parameter_models["Parameter models<br/>distribution builder"]
  node_drake_aggregator{{"Drake aggregator<br/>simulation core"}}
  node_final_distribution(("N distribution<br/>analysis result"))
end

subgraph group_output["Output"]
  node_figure_writer["Figure writer<br/>plotting step"]
  node_figures_dir[("figures/<br/>generated artifacts")]
end

node_metaculus_api -.->|"API forecasts"| node_forecast_parser
node_rs_data -->|"CSV inputs"| node_forecast_parser
node_fp_data -->|"CSV inputs"| node_forecast_parser
node_ne_data -->|"CSV inputs"| node_forecast_parser
node_fl_data -->|"CSV inputs"| node_forecast_parser
node_fi_data -->|"CSV inputs"| node_forecast_parser
node_fc_data -->|"CSV inputs"| node_forecast_parser
node_l_data -->|"CSV inputs"| node_forecast_parser
node_drake_metaculus_py -->|"orchestrates"| node_forecast_parser
node_forecast_parser -->|"PDF/CDFs"| node_parameter_models
node_parameter_models -->|"7 distributions"| node_drake_aggregator
node_drake_metaculus_py -->|"batch compute"| node_drake_aggregator
node_drake_aggregator -->|"N"| node_final_distribution
node_final_distribution -->|"plot input"| node_figure_writer
node_drake_metaculus_py -->|"renders"| node_figure_writer
node_figure_writer -->|"saved plots"| node_figures_dir

click node_drake_metaculus_py "https://github.com/ferdesmello/drake-metaculus/blob/main/drake_metaculus.py"
click node_rs_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_First_Parameter_R_s"
click node_fp_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Second_Parameter_f_p"
click node_ne_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Third_Parameter_n_e"
click node_fl_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Fourth_Parameter_f_l"
click node_fi_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Fifth_Parameter_f_i"
click node_fc_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Sixth_Parameter_f_c"
click node_l_data "https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Seventh_Parameter_L"
click node_figures_dir "https://github.com/ferdesmello/drake-metaculus/tree/main/figures"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_metaculus_api toneBlue
class node_rs_data,node_fp_data,node_ne_data,node_fl_data,node_fi_data,node_fc_data,node_l_data toneAmber
class node_drake_metaculus_py,node_forecast_parser,node_parameter_models,node_drake_aggregator,node_final_distribution toneMint
class node_figure_writer,node_figures_dir toneRose
```

## Components

### External

Metaculus is the only upstream service boundary.

- **Metaculus API**: external service · Online source for personal or aggregated forecast data.

### Data

Offline parameter forecasts and question metadata for each Drake term.

- [R_s data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_First_Parameter_R_s): parameter dataset · First Drake parameter inputs and metadata. · `data/Drake's_Equation_First_Parameter_R_s`
- [f_p data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Second_Parameter_f_p): parameter dataset · Second Drake parameter inputs and metadata. · `data/Drake's_Equation_Second_Parameter_f_p`
- [n_e data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Third_Parameter_n_e): parameter dataset · Third Drake parameter inputs and metadata. · `data/Drake's_Equation_Third_Parameter_n_e`
- [f_l data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Fourth_Parameter_f_l): parameter dataset · Fourth Drake parameter inputs and metadata. · `data/Drake's_Equation_Fourth_Parameter_f_l`
- [f_i data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Fifth_Parameter_f_i): parameter dataset · Fifth Drake parameter inputs and metadata. · `data/Drake's_Equation_Fifth_Parameter_f_i`
- [f_c data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Sixth_Parameter_f_c): parameter dataset · Sixth Drake parameter inputs and metadata. · `data/Drake's_Equation_Sixth_Parameter_f_c`
- [L data](https://github.com/ferdesmello/drake-metaculus/tree/main/data/Drake's_Equation_Seventh_Parameter_L): parameter dataset · Seventh Drake parameter inputs and metadata. · `data/Drake's_Equation_Seventh_Parameter_L`

### Analysis

Single-script batch pipeline that parses, models, aggregates, and plots.

- [drake_metaculus.py](https://github.com/ferdesmello/drake-metaculus/blob/main/drake_metaculus.py): batch analysis script · Single entrypoint that runs the full pipeline. · `drake_metaculus.py`
- **Forecast parser**: ingestion layer · Converts Metaculus outputs and local CSVs into usable PDFs/CDFs.
- **Parameter models**: distribution builder · Builds one probability distribution per Drake variable.
- **Drake aggregator**: simulation core · Combines the seven parameter distributions into the final N distribution.
- **N distribution**: analysis result · Derived distribution over detectable civilizations.

### Output

Generated static figures from the final Drake distribution.

- **Figure writer**: plotting step · Renders the final distribution and related plots.
- [figures/](https://github.com/ferdesmello/drake-metaculus/tree/main/figures): generated artifacts · Static output directory for saved plots. · `figures`

## Connections

- Metaculus API → Forecast parser: API forecasts · Feeds online forecast data when data_type selects Metaculus.
- R_s data → Forecast parser: CSV inputs · Offline source of truth for the first Drake parameter.
- f_p data → Forecast parser: CSV inputs · Offline source of truth for the second Drake parameter.
- n_e data → Forecast parser: CSV inputs · Offline source of truth for the third Drake parameter.
- f_l data → Forecast parser: CSV inputs · Offline source of truth for the fourth Drake parameter.
- f_i data → Forecast parser: CSV inputs · Offline source of truth for the fifth Drake parameter.
- f_c data → Forecast parser: CSV inputs · Offline source of truth for the sixth Drake parameter.
- L data → Forecast parser: CSV inputs · Offline source of truth for the seventh Drake parameter.
- drake_metaculus.py → Forecast parser: orchestrates · Single script selects the ingestion mode and runs parsing.
- Forecast parser → Parameter models: PDF/CDFs · Parses Metaculus response structure into parameter distributions.
- Parameter models → Drake aggregator: 7 distributions · Seven independent Drake terms feed the combined calculation.
- drake_metaculus.py → Drake aggregator: batch compute · Executes the central analytical step end to end.
- Drake aggregator → N distribution: N · Produces the final distribution for the Drake equation output.
- N distribution → Figure writer: plot input · The computed distribution is visualized as static figures.
- drake_metaculus.py → Figure writer: renders · Script finishes by generating plots from the computed result.
- Figure writer → figures/: saved plots · Generated figures are written to the figures directory.
