# kenzierivan/materialaize architecture

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

- Interactive diagram: https://gitdiagram.com/kenzierivan/materialaize
- Repository: https://github.com/kenzierivan/materialaize

## Overview

Materialaize is a web application for generating and evaluating self-healing polymer molecule candidates from a SMILES seed. A user submits a seed in the landing interface; the frontend requests molecule generation, presents candidate structures and metrics, and can request a text explanation. The FastAPI backend loads a ChemGPT model with a LoRA adapter, generates continuations, and computes validity, polymer, motif, diversity, and synthetic-accessibility metrics. The frontend also checks backend health and renders molecular structures. The README documents how to run the two services but does not describe further product behavior; some endpoint and frontend wiring is inferred from the sampled excerpts.

Main entry points: [`materialaize/app/landing.tsx`](https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx) (Landing workflow), [`backend/app.py`](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py) (FastAPI service), [`backend/model/adapter_model.safetensors`](https://github.com/kenzierivan/materialaize/blob/main/backend/model/adapter_model.safetensors) (LoRA adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_landing["Landing workflow<br/>[landing.tsx]"]
  node_results["Candidate results<br/>[landing.tsx]"]
  node_structure["Structure viewer<br/>[landing.tsx]"]
end

subgraph group_backend["Molecule service"]
  node_api["FastAPI service<br/>[app.py]"]
  node_generator["SMILES generator<br/>[app.py]"]
  node_metrics["Candidate metrics<br/>[app.py]"]
  node_health["Health endpoint<br/>[app.py]"]
  node_explain["Explanation endpoint<br/>[app.py]"]
end

subgraph group_integrations["Model and explanation"]
  node_chemgpt["ChemGPT base model"]
  node_lora["LoRA adapter"]
end

node_user(("Molecule designer"))
node_anthropic["Anthropic API"]
node_smilesdrawer["SMILES Drawer"]

node_user -->|"submits seed"| node_landing
node_landing -->|"requests generation"| node_api
node_api -->|"calls"| node_generator
node_generator -->|"generates with"| node_chemgpt
node_generator -->|"loads adapter"| node_lora
node_api -->|"computes metrics"| node_metrics
node_api -->|"returns candidates"| node_results
node_landing -->|"updates view"| node_results
node_landing -->|"checks health"| node_health
node_landing -->|"requests explanation"| node_explain
node_explain -.->|"requests text"| node_anthropic
node_results -->|"renders candidate"| node_structure
node_structure -->|"draws structure"| node_smilesdrawer

click node_landing "https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx"
click node_results "https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx"
click node_structure "https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx"
click node_api "https://github.com/kenzierivan/materialaize/blob/main/backend/app.py"
click node_generator "https://github.com/kenzierivan/materialaize/blob/main/backend/app.py"
click node_metrics "https://github.com/kenzierivan/materialaize/blob/main/backend/app.py"
click node_health "https://github.com/kenzierivan/materialaize/blob/main/backend/app.py"
click node_explain "https://github.com/kenzierivan/materialaize/blob/main/backend/app.py"
click node_lora "https://github.com/kenzierivan/materialaize/blob/main/backend/model/adapter_model.safetensors"

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_landing,node_results,node_structure toneBlue
class node_api,node_generator,node_metrics,node_health,node_explain toneAmber
class node_chemgpt,node_lora,node_anthropic toneMint
class node_user,node_smilesdrawer toneIndigo
```

## Components

### Web interface

- [Landing workflow](https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx): `materialaize/app/landing.tsx`
- [Candidate results](https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx): `materialaize/app/landing.tsx`
- [Structure viewer](https://github.com/kenzierivan/materialaize/blob/main/materialaize/app/landing.tsx): `materialaize/app/landing.tsx`

### Molecule service

- [FastAPI service](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py): `backend/app.py`
- [SMILES generator](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py): `backend/app.py`
- [Candidate metrics](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py): `backend/app.py`
- [Health endpoint](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py): `backend/app.py`
- [Explanation endpoint](https://github.com/kenzierivan/materialaize/blob/main/backend/app.py): `backend/app.py`

### Model and explanation

- **ChemGPT base model**
- [LoRA adapter](https://github.com/kenzierivan/materialaize/blob/main/backend/model/adapter_model.safetensors): `backend/model/adapter_model.safetensors`

### Other components

- **Molecule designer**
- **Anthropic API**
- **SMILES Drawer**

## Connections

- Molecule designer → Landing workflow: submits seed
- Landing workflow → FastAPI service: requests generation
- FastAPI service → SMILES generator: calls
- SMILES generator → ChemGPT base model: generates with
- SMILES generator → LoRA adapter: loads adapter
- FastAPI service → Candidate metrics: computes metrics
- FastAPI service → Candidate results: returns candidates
- Landing workflow → Candidate results: updates view
- Landing workflow → Health endpoint: checks health
- Landing workflow → Explanation endpoint: requests explanation
- Explanation endpoint → Anthropic API: requests text
- Candidate results → Structure viewer: renders candidate
- Structure viewer → SMILES Drawer: draws structure
