# amrit-sarker/bdhs2022-contraceptive-use-analysis architecture

> Architecture diagram of the GitHub repository amrit-sarker/bdhs2022-contraceptive-use-analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amrit-sarker/bdhs2022-contraceptive-use-analysis
- Repository: https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis

## Overview

1. **Repository purpose**  
This is a single-purpose statistical analysis project, not an application or service. Its main job is to turn a cleaned BDHS 2022 fertility dataset into a narrated research report about contraceptive use among Bangladeshi women aged 15–49.

2. **Primary artifacts and roles**  
The repo has three layers of the same analysis: the source Quarto document, the raw R script, and the rendered PDF. The `.qmd` file is the main authored analysis narrative, the `.R` file is the executable script version, and the `.pdf` is the compiled report output.

3. **Data boundary**  
`fertility.csv` is the only bundled analysis dataset. It represents a cleaned, derived extract from the BDHS 2022 survey. The original DHS IR file is intentionally not included, so the repo’s data boundary is the cleaned CSV rather than the raw survey source.

4. **Ingestion and preparation**  
The analysis begins by loading `fertility.csv` into R. From there, the data is prepared into variables suitable for descriptive summaries, grouped comparisons, and regression modeling. The repo implies a controlled preprocessing step already happened before this repository, since the dataset is described as cleaned.

5. **Exploratory analysis subsystem**  
A large part of the workflow is EDA: distributions of total children and age at first birth, boxplots by education/wealth/division, and bar charts for contraceptive use. This subsystem is primarily visual and is used to reveal patterns before formal testing.

6. **Statistical testing subsystem**  
The project includes chi-square tests to evaluate associations between contraceptive use and socio-demographic factors such as education, wealth, residence, and division. This is the inferential boundary between simple visualization and statistically supported claims.

7. **Modeling subsystem**  
A logistic regression model is used to estimate the relationship between contraceptive use and predictors like age, education, wealth, residence, and division. This serves as the multivariable layer that checks whether observed bivariate patterns persist when factors are considered together.

8. **Trend analysis subsystem**  
There is a dedicated age-trend analysis that smooths contraceptive use across age, showing a rise into the mid-30s and then decline. This is distinct from the grouped summaries because it emphasizes continuous age behavior rather than categorical comparisons.

9. **Reporting and publication layer**  
The `.qmd` file is the reporting surface that combines prose, code, charts, and statistical output into a coherent narrative. Rendering produces the PDF deliverable, which is the final shareable artifact for readers.

10. **Technology and tooling boundary**  
The project is centered on R and Quarto, with tidyverse-style data work and ggplot2-based visualization. `haven` is listed because the broader workflow likely touches DHS-originated survey data formats, even though the repo ships with a cleaned CSV instead of the original file.

11. **End-to-end data flow**  
The overall flow is: survey-derived data in `fertility.csv` → analysis code in R/Quarto → descriptive plots and statistical tests → logistic regression and age trend interpretation → rendered PDF report. There is no backend, database, or interactive UI; the architecture is a reproducible offline analysis pipeline.

12. **What to draw in an architecture diagram**  
A good diagram would show one input dataset feeding a single analysis/reporting pipeline, then branching into EDA, hypothesis testing, and regression, all recombined into one authored Quarto report and one PDF output. The key boundaries are the external DHS source, the cleaned local CSV, and the rendered publication artifact.

Main entry points: [`bdhs2022-contraceptive-analysis.qmd`](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.qmd) (Quarto report), [`fertility.csv`](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/fertility.csv) (fertility.csv), [`bdhs2022-contraceptive-analysis.R`](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.R) (R script), [`bdhs2022-contraceptive-analysis.pdf`](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.pdf) (PDF report)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data input"]
  node_fertility_csv[("fertility.csv<br/>cleaned dataset<br/>[fertility.csv]")]
end

subgraph group_analysis["Analysis workflow"]
  node_r_script["R script<br/>executable analysis"]
  node_prep["Data prep<br/>variable preparation"]
  node_eda["Exploration<br/>descriptive analysis"]
  node_tests["Chi-square tests<br/>inferential testing"]
  node_model["Logistic model<br/>multivariable regression"]
  node_trend["Age trend<br/>smoothed trend"]
end

subgraph group_reporting["Reporting"]
  node_qmd["Quarto report<br/>narrative analysis"]
  node_pdf["PDF report<br/>rendered output"]
  node_report_build["Report build<br/>quarto render"]
end

node_fertility_csv -->|"load"| node_prep
node_prep -->|"summarize"| node_eda
node_prep -->|"compare"| node_tests
node_prep -->|"fit"| node_model
node_prep -->|"smooth"| node_trend
node_eda -->|"embed"| node_qmd
node_tests -->|"report"| node_qmd
node_model -->|"report"| node_qmd
node_trend -->|"interpret"| node_qmd
node_qmd -->|"render"| node_report_build
node_r_script -.->|"mirror"| node_prep
node_report_build -->|"output"| node_pdf

click node_fertility_csv "https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/fertility.csv"
click node_qmd "https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.qmd"
click node_r_script "https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.R"
click node_pdf "https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.pdf"

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_fertility_csv toneBlue
class node_r_script,node_prep,node_eda,node_tests,node_model,node_trend toneAmber
class node_qmd,node_pdf,node_report_build toneMint
```

## Components

### Data input

Cleaned analysis dataset bundled with the repo.

- [fertility.csv](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/fertility.csv): cleaned dataset · Derived BDHS 2022 fertility extract used as the analysis input. · `fertility.csv`

### Analysis workflow

R/Quarto analysis steps for exploration, testing, modeling, and trend analysis.

- [R script](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.R): executable analysis · Script version of the report logic for reproducing the analysis steps. · `bdhs2022-contraceptive-analysis.R`
- **Data prep**: variable preparation · Loads the cleaned CSV and shapes variables for summaries, comparisons, and modeling.
- **Exploration**: descriptive analysis · Summaries and plots for children, age at first birth, and contraceptive use patterns.
- **Chi-square tests**: inferential testing · Association tests for contraceptive use versus socio-demographic factors.
- **Logistic model**: multivariable regression · Estimates contraceptive use against age, education, wealth, residence, and division.
- **Age trend**: smoothed trend · Continuous age-pattern analysis showing contraceptive use changes across age.

### Reporting

Authored narrative and rendered publication artifacts.

- [Quarto report](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.qmd): narrative analysis · Main authored document combining prose, code, figures, and statistical output. · `bdhs2022-contraceptive-analysis.qmd`
- [PDF report](https://github.com/amrit-sarker/bdhs2022-contraceptive-use-analysis/blob/main/bdhs2022-contraceptive-analysis.pdf): rendered output · Final shareable report generated from the Quarto source. · `bdhs2022-contraceptive-analysis.pdf`
- **Report build**: quarto render · Combines analysis outputs into the final narrative publication.

## Connections

- fertility.csv → Data prep: load · Read the cleaned fertility dataset into R.
- Data prep → Exploration: summarize · Produce descriptive summaries and charts.
- Data prep → Chi-square tests: compare · Cross-tabulate contraceptive use against socio-demographic factors.
- Data prep → Logistic model: fit · Use prepared variables in logistic regression.
- Data prep → Age trend: smooth · Analyze contraceptive use across age as a continuous trend.
- Exploration → Quarto report: embed · Insert figures and descriptive findings into the narrative.
- Chi-square tests → Quarto report: report · Document inferential results and significance claims.
- Logistic model → Quarto report: report · Present multivariable regression results in the report.
- Age trend → Quarto report: interpret · Add age-pattern interpretation to the narrative.
- Quarto report → Report build: render · Quarto compiles the authored source into a publication artifact.
- R script → Data prep: mirror · Executable script mirrors the report's analysis workflow.
- Report build → PDF report: output · Generate the final PDF deliverable.
