# allenpaulgloria/legal_study_ai architecture

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

- Interactive diagram: https://gitdiagram.com/allenpaulgloria/legal_study_ai
- Repository: https://github.com/allenpaulgloria/legal_study_ai

## Overview

Legal Study AI · PH is a Flutter app for studying Philippine jurisprudence. The principal workflow is offline case search, case reading with grounded digest/ALAC assistance, and Socratic recitation; separate capabilities sync public legal sources and manage BYOK, model, theme, and local-cache settings. The README documents these subsystem relationships. Dart implementation excerpts were not provided, so edges reflect documented behavior rather than inspected call sites.

Main entry points: [`lib/screens/case_detail_screen.dart`](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/case_detail_screen.dart) (Case Reader), [`lib/screens/settings_screen.dart`](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/settings_screen.dart) (Study Settings), [`lib/screens/home_search_screen.dart`](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/home_search_screen.dart) (Case Search), [`lib/screens/socratic_quiz_screen.dart`](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/socratic_quiz_screen.dart) (Socratic Recitation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Study App"]
  node_app_entry["Flutter App<br/>[main.dart]"]
  node_search_screen["Case Search"]
  node_case_reader["Case Reader"]
  node_quiz_screen["Socratic Recitation"]
  node_app_state["App Providers<br/>[app_providers.dart]"]
end

subgraph group_legaldata["Jurisprudence Data"]
  node_case_model["Case Model<br/>[legal_case.dart]"]
  node_hybrid_search["Hybrid Search"]
  node_case_sync["Jurisprudence Sync"]
  node_local_archive[("Offline Case Archive")]
end

subgraph group_learning["AI Learning"]
  node_legal_ai["Grounded Legal AI"]
end

subgraph group_configuration["Configuration"]
  node_settings_screen["Study Settings"]
  node_settings_service["Local Settings"]
  node_theme["Material Theme<br/>[app_theme.dart]"]
end

node_learner(("Learner"))
node_public_sources["Public Legal Sources"]
node_gemini["Gemini API"]

node_learner -->|"searches cases"| node_search_screen
node_search_screen -->|"runs hybrid search"| node_hybrid_search
node_learner -->|"studies case"| node_case_reader
node_case_reader -->|"retrieves authorities"| node_hybrid_search
node_case_reader -->|"generates digest"| node_legal_ai
node_legal_ai -->|"requests generation"| node_gemini
node_case_reader -->|"caches digest"| node_local_archive
node_learner -->|"practices recitation"| node_quiz_screen
node_quiz_screen -->|"powers recitation"| node_gemini
node_case_sync -->|"fetches legal data"| node_public_sources
node_learner -->|"configures study"| node_settings_screen
node_settings_screen -->|"stores preferences"| node_settings_service
node_settings_screen -->|"manages cache"| node_local_archive
node_settings_screen -->|"selects appearance"| node_theme

click node_app_entry "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/main.dart"
click node_search_screen "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/home_search_screen.dart"
click node_case_reader "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/case_detail_screen.dart"
click node_quiz_screen "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/socratic_quiz_screen.dart"
click node_case_model "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/models/legal_case.dart"
click node_hybrid_search "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/hybrid_search_service.dart"
click node_case_sync "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/sc_data_service.dart"
click node_local_archive "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/sc_data_service.dart"
click node_legal_ai "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/gemini_legal_service.dart"
click node_settings_screen "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/settings_screen.dart"
click node_settings_service "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/settings_service.dart"
click node_theme "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/theme/app_theme.dart"
click node_app_state "https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/providers/app_providers.dart"

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_entry,node_search_screen,node_case_reader,node_quiz_screen,node_app_state toneBlue
class node_case_model,node_hybrid_search,node_case_sync,node_local_archive toneAmber
class node_legal_ai,node_gemini toneMint
class node_settings_screen,node_settings_service,node_theme toneRose
class node_learner,node_public_sources toneIndigo
```

## Components

### Study App

- [Flutter App](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/main.dart): `lib/main.dart`
- [Case Search](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/home_search_screen.dart): `lib/screens/home_search_screen.dart`
- [Case Reader](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/case_detail_screen.dart): `lib/screens/case_detail_screen.dart`
- [Socratic Recitation](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/socratic_quiz_screen.dart): `lib/screens/socratic_quiz_screen.dart`
- [App Providers](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/providers/app_providers.dart): `lib/providers/app_providers.dart`

### Jurisprudence Data

- [Case Model](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/models/legal_case.dart): `lib/models/legal_case.dart`
- [Hybrid Search](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/hybrid_search_service.dart): `lib/services/hybrid_search_service.dart`
- [Jurisprudence Sync](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/sc_data_service.dart): `lib/services/sc_data_service.dart`
- [Offline Case Archive](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/sc_data_service.dart): `lib/services/sc_data_service.dart`

### AI Learning

- [Grounded Legal AI](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/gemini_legal_service.dart): `lib/services/gemini_legal_service.dart`

### Configuration

- [Study Settings](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/screens/settings_screen.dart): `lib/screens/settings_screen.dart`
- [Local Settings](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/services/settings_service.dart): `lib/services/settings_service.dart`
- [Material Theme](https://github.com/allenpaulgloria/legal_study_ai/blob/main/lib/theme/app_theme.dart): `lib/theme/app_theme.dart`

### Other components

- **Learner**
- **Public Legal Sources**
- **Gemini API**

## Connections

- Learner → Case Search: searches cases (evidence: `README.md`)
- Case Search → Hybrid Search: runs hybrid search (evidence: `README.md`)
- Learner → Case Reader: studies case (evidence: `README.md`)
- Case Reader → Hybrid Search: retrieves authorities (evidence: `README.md`)
- Case Reader → Grounded Legal AI: generates digest (evidence: `README.md`)
- Grounded Legal AI → Gemini API: requests generation (evidence: `README.md`)
- Case Reader → Offline Case Archive: caches digest (evidence: `README.md`)
- Learner → Socratic Recitation: practices recitation (evidence: `README.md`)
- Socratic Recitation → Gemini API: powers recitation (evidence: `README.md`)
- Jurisprudence Sync → Public Legal Sources: fetches legal data (evidence: `README.md`)
- Learner → Study Settings: configures study (evidence: `README.md`)
- Study Settings → Local Settings: stores preferences (evidence: `README.md`)
- Study Settings → Offline Case Archive: manages cache (evidence: `README.md`)
- Study Settings → Material Theme: selects appearance (evidence: `README.md`)
