# devilsanket/psychoanalysis architecture

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

- Interactive diagram: https://gitdiagram.com/devilsanket/psychoanalysis
- Repository: https://github.com/devilsanket/psychoanalysis

## Overview

ISF Child Psycho-Analysis Portal is a React/FastAPI application for turning field reports into child observations and supporting ongoing roster review. Its principal workflow is report entry and extraction, profile matching and human review, then saving observations; users can subsequently inspect child histories, AI summaries, tasks, risk indicators, and center-level analytics. The graph reflects documented imports, calls, and the README’s frontend/backend arrangement. Some UI features and router internals are unsampled, so their specific backend connections are omitted rather than inferred.

Main entry points: [`api.py`](https://github.com/devilsanket/psychoanalysis/blob/main/api.py) (FastAPI application), [`db.py`](https://github.com/devilsanket/psychoanalysis/blob/main/db.py) (MongoDB data), [`frontend/src/components/AdminPanel.tsx`](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/AdminPanel.tsx) (Admin panel), [`frontend/src/api.ts`](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Portal UI"]
  node_app["App workflow<br/>[App.tsx]"]
  node_report_input["Report entry<br/>[ReportInput.tsx]"]
  node_review["Profile review<br/>[ReviewProfiles.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_admin_ui["Admin panel<br/>[AdminPanel.tsx]"]
end

subgraph group_backend["API and workflows"]
  node_api["FastAPI application<br/>[api.py]"]
  node_extraction["Report endpoints<br/>[extraction.py]"]
  node_pipeline["Extract and match<br/>[pipeline.py]"]
  node_children["Child profiles<br/>[children.py]"]
  node_ai["AI child analysis<br/>[ai.py]"]
  node_analytics["Analytics endpoints<br/>[analytics.py]"]
  node_admin["Administration endpoints<br/>[admin.py]"]
  node_centers["Center endpoints<br/>[centers.py]"]
  node_common["Shared API models<br/>[common.py]"]
end

subgraph group_data["Persistence"]
  node_database[("MongoDB data<br/>[db.py]")]
end

subgraph group_insights["Roster insights"]
  node_roster_ui["Roster insights<br/>[RosterInsights.tsx]"]
  node_risk_ui["Risk dashboards"]
  node_cracks_ui["Falling-through review"]
  node_center_ui["Center heatmap"]
  node_task_ui["Task analytics<br/>[TaskAnalytics.tsx]"]
  node_stories_ui["Success stories<br/>[SuccessStories.tsx]"]
end

node_user(("Portal user"))
node_llm{{"Gemini / LLM"}}

node_user -->|"uses"| node_app
node_app -->|"renders"| node_report_input
node_app -->|"renders"| node_review
node_report_input -->|"requests extraction"| node_api_client
node_review -->|"saves profiles"| node_api_client
node_api_client -->|"HTTP requests"| node_api
node_api -->|"routes to"| node_extraction
node_api -->|"routes to"| node_children
node_api -->|"routes to"| node_ai
node_api -->|"routes to"| node_analytics
node_api -->|"routes to"| node_admin
node_api -->|"routes to"| node_centers
node_extraction -->|"invokes extraction"| node_pipeline
node_pipeline -->|"reads and writes"| node_database
node_children -->|"reads and writes"| node_database
node_ai -->|"reads and updates"| node_database
node_ai -.->|"generates analysis"| node_llm
node_admin -->|"reads and updates"| node_database
node_analytics -->|"reads analytics"| node_database
node_centers -->|"reads centers"| node_database
node_extraction -->|"uses models"| node_common
node_children -->|"uses models"| node_common
node_ai -->|"uses helpers"| node_common
node_admin_ui -->|"requests admin data"| node_api_client
node_app -->|"renders"| node_admin_ui
node_roster_ui -->|"fetches child data"| node_api_client
node_admin_ui -->|"renders"| node_risk_ui
node_admin_ui -->|"renders"| node_cracks_ui
node_admin_ui -->|"renders"| node_center_ui
node_roster_ui -->|"renders"| node_task_ui
node_roster_ui -->|"renders"| node_stories_ui

click node_app "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/App.tsx"
click node_report_input "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ReportInput.tsx"
click node_review "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ReviewProfiles.tsx"
click node_api_client "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/api.ts"
click node_admin_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/AdminPanel.tsx"
click node_roster_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/RosterInsights.tsx"
click node_risk_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ChildRiskDashboard.tsx"
click node_cracks_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/FallingThroughCracks.tsx"
click node_center_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/BalgruhaHeatMap.tsx"
click node_task_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/TaskAnalytics.tsx"
click node_stories_ui "https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/SuccessStories.tsx"
click node_api "https://github.com/devilsanket/psychoanalysis/blob/main/api.py"
click node_extraction "https://github.com/devilsanket/psychoanalysis/blob/main/routers/extraction.py"
click node_pipeline "https://github.com/devilsanket/psychoanalysis/blob/main/pipeline.py"
click node_children "https://github.com/devilsanket/psychoanalysis/blob/main/routers/children.py"
click node_ai "https://github.com/devilsanket/psychoanalysis/blob/main/routers/ai.py"
click node_analytics "https://github.com/devilsanket/psychoanalysis/blob/main/routers/analytics.py"
click node_admin "https://github.com/devilsanket/psychoanalysis/blob/main/routers/admin.py"
click node_centers "https://github.com/devilsanket/psychoanalysis/blob/main/routers/centers.py"
click node_common "https://github.com/devilsanket/psychoanalysis/blob/main/common.py"
click node_database "https://github.com/devilsanket/psychoanalysis/blob/main/db.py"

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_app,node_report_input,node_review,node_api_client,node_admin_ui,node_user toneBlue
class node_api,node_extraction,node_pipeline,node_children,node_ai,node_analytics,node_admin,node_centers,node_common toneAmber
class node_database toneMint
class node_roster_ui,node_risk_ui,node_cracks_ui,node_center_ui,node_task_ui,node_stories_ui toneRose
class node_llm toneIndigo
```

## Components

### Portal UI

- [App workflow](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Report entry](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ReportInput.tsx): `frontend/src/components/ReportInput.tsx`
- [Profile review](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ReviewProfiles.tsx): `frontend/src/components/ReviewProfiles.tsx`
- [API client](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/api.ts): `frontend/src/api.ts`
- [Admin panel](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/AdminPanel.tsx): `frontend/src/components/AdminPanel.tsx`

### API and workflows

- [FastAPI application](https://github.com/devilsanket/psychoanalysis/blob/main/api.py): `api.py`
- [Report endpoints](https://github.com/devilsanket/psychoanalysis/blob/main/routers/extraction.py): `routers/extraction.py`
- [Extract and match](https://github.com/devilsanket/psychoanalysis/blob/main/pipeline.py): `pipeline.py`
- [Child profiles](https://github.com/devilsanket/psychoanalysis/blob/main/routers/children.py): `routers/children.py`
- [AI child analysis](https://github.com/devilsanket/psychoanalysis/blob/main/routers/ai.py): `routers/ai.py`
- [Analytics endpoints](https://github.com/devilsanket/psychoanalysis/blob/main/routers/analytics.py): `routers/analytics.py`
- [Administration endpoints](https://github.com/devilsanket/psychoanalysis/blob/main/routers/admin.py): `routers/admin.py`
- [Center endpoints](https://github.com/devilsanket/psychoanalysis/blob/main/routers/centers.py): `routers/centers.py`
- [Shared API models](https://github.com/devilsanket/psychoanalysis/blob/main/common.py): `common.py`

### Persistence

- [MongoDB data](https://github.com/devilsanket/psychoanalysis/blob/main/db.py): `db.py`

### Roster insights

- [Roster insights](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/RosterInsights.tsx): `frontend/src/components/RosterInsights.tsx`
- [Risk dashboards](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/ChildRiskDashboard.tsx): `frontend/src/components/ChildRiskDashboard.tsx`
- [Falling-through review](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/FallingThroughCracks.tsx): `frontend/src/components/FallingThroughCracks.tsx`
- [Center heatmap](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/BalgruhaHeatMap.tsx): `frontend/src/components/BalgruhaHeatMap.tsx`
- [Task analytics](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/TaskAnalytics.tsx): `frontend/src/components/TaskAnalytics.tsx`
- [Success stories](https://github.com/devilsanket/psychoanalysis/blob/main/frontend/src/components/SuccessStories.tsx): `frontend/src/components/SuccessStories.tsx`

### Other components

- **Portal user**
- **Gemini / LLM**

## Connections

- Portal user → App workflow: uses (evidence: `frontend/src/App.tsx`)
- App workflow → Report entry: renders (evidence: `frontend/src/App.tsx`)
- App workflow → Profile review: renders (evidence: `frontend/src/App.tsx`)
- Report entry → API client: requests extraction (evidence: `frontend/src/components/ReportInput.tsx`)
- Profile review → API client: saves profiles (evidence: `frontend/src/components/ReviewProfiles.tsx`)
- API client → FastAPI application: HTTP requests (evidence: `README.md`)
- FastAPI application → Report endpoints: routes to (evidence: `api.py`)
- FastAPI application → Child profiles: routes to (evidence: `api.py`)
- FastAPI application → AI child analysis: routes to (evidence: `api.py`)
- FastAPI application → Analytics endpoints: routes to (evidence: `api.py`)
- FastAPI application → Administration endpoints: routes to (evidence: `api.py`)
- FastAPI application → Center endpoints: routes to (evidence: `api.py`)
- Report endpoints → Extract and match: invokes extraction (evidence: `routers/extraction.py`)
- Extract and match → MongoDB data: reads and writes (evidence: `pipeline.py`)
- Child profiles → MongoDB data: reads and writes (evidence: `routers/children.py`)
- AI child analysis → MongoDB data: reads and updates (evidence: `routers/ai.py`)
- AI child analysis → Gemini / LLM: generates analysis
- Administration endpoints → MongoDB data: reads and updates (evidence: `routers/admin.py`)
- Analytics endpoints → MongoDB data: reads analytics (evidence: `routers/analytics.py`)
- Center endpoints → MongoDB data: reads centers (evidence: `routers/centers.py`)
- Report endpoints → Shared API models: uses models (evidence: `routers/extraction.py`)
- Child profiles → Shared API models: uses models (evidence: `routers/children.py`)
- AI child analysis → Shared API models: uses helpers (evidence: `routers/ai.py`)
- Admin panel → API client: requests admin data (evidence: `frontend/src/components/AdminPanel.tsx`)
- App workflow → Admin panel: renders (evidence: `frontend/src/App.tsx`)
- Roster insights → API client: fetches child data (evidence: `frontend/src/components/RosterInsights.tsx`)
- Admin panel → Risk dashboards: renders (evidence: `frontend/src/components/AdminPanel.tsx`)
- Admin panel → Falling-through review: renders (evidence: `frontend/src/components/AdminPanel.tsx`)
- Admin panel → Center heatmap: renders (evidence: `frontend/src/components/AdminPanel.tsx`)
- Roster insights → Task analytics: renders (evidence: `frontend/src/components/RosterInsights.tsx`)
- Roster insights → Success stories: renders (evidence: `frontend/src/components/RosterInsights.tsx`)
