# apexstudying-cmd/prepza architecture

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

- Interactive diagram: https://gitdiagram.com/apexstudying-cmd/prepza
- Repository: https://github.com/apexstudying-cmd/prepza

## Overview

Prepza is a student learning platform with document-based AI study materials, subscriptions, organisation services, and encrypted communications. Its principal workflow is a student using the web app to import study material and request generated learning content; the excerpts show document extraction and AI generation capabilities, but not the complete upload-to-generation route wiring. The graph also preserves billing, administration, and communications as major product areas. Several backend links are supported only by the SOURCE INDEX; unsampled subsystems are represented without guessed call chains.

Main entry points: [`app.py`](https://github.com/apexstudying-cmd/prepza/blob/main/app.py) (Flask application), [`frontend/src/main.tsx`](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/main.tsx) (Application entry), [`ai_reusable_generation.py`](https://github.com/apexstudying-cmd/prepza/blob/main/ai_reusable_generation.py) (Reusable artifacts), [`frontend/src/App.tsx`](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Student app"]
  node_web_app["Web application<br/>[App.tsx]"]
  node_app_entry["Application entry<br/>[main.tsx]"]
  node_document_import["Document import"]
  node_generation_ui["Generation screens"]
end

subgraph group_learning["Study generation"]
  node_document_pipeline["Document extraction"]
  node_ai_service["AI generation<br/>[ai_service.py]"]
  node_reusable_generation["Reusable artifacts"]
  node_generation_store["Generation storage"]
  node_object_storage[("Object storage<br/>[object_storage.py]")]
end

subgraph group_commercial["Plans and payments"]
  node_economics["AI entitlements<br/>[ai_economics.py]"]
  node_usage_billing["Usage billing<br/>[usage_billing.py]"]
  node_subscriptions["Student subscriptions"]
  node_discovery_billing["Discovery billing"]
  node_organisation_portal["Organisation portal"]
  node_campaign_payments["Campaign payments"]
end

subgraph group_operations["Administration"]
  node_admin_core["Admin operations"]
  node_admin_org["Organisation admin"]
end

subgraph group_communications["Secure communications"]
  node_chat_routes["Chat routes"]
  node_e2ee_routes["Encrypted chat API"]
  node_e2ee_client["Encrypted chat client<br/>[e2eeFetchBridge.ts]"]
end

node_student(("Student"))
node_backend["Flask application<br/>[app.py]"]

node_student -.->|"uses"| node_app_entry
node_app_entry -->|"mounts"| node_web_app
node_app_entry -->|"installs bridge"| node_e2ee_client
node_document_import -.->|"opens within"| node_web_app
node_generation_ui -.->|"appears within"| node_web_app
node_backend -.->|"imports"| node_document_pipeline
node_document_pipeline -->|"reads document; updates status"| node_backend
node_backend -->|"imports"| node_ai_service
node_backend -->|"imports"| node_economics
node_backend -->|"imports"| node_usage_billing
node_backend -->|"imports"| node_subscriptions
node_backend -->|"imports"| node_discovery_billing
node_backend -->|"imports"| node_organisation_portal
node_backend -->|"imports"| node_campaign_payments
node_backend -->|"imports"| node_admin_core
node_backend -->|"imports"| node_admin_org
node_backend -->|"imports"| node_chat_routes
node_reusable_generation -->|"uses generators"| node_ai_service
node_reusable_generation -->|"checks entitlements"| node_economics
node_backend -->|"imports"| node_reusable_generation
node_backend -->|"imports"| node_object_storage
node_organisation_portal -->|"uses storage"| node_object_storage
node_e2ee_client -.->|"calls API"| node_e2ee_routes
node_backend -.->|"registers routes"| node_e2ee_routes

click node_web_app "https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/App.tsx"
click node_app_entry "https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/main.tsx"
click node_document_import "https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/ExternalDocumentImport.tsx"
click node_generation_ui "https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/generation/GenerationScreens.tsx"
click node_document_pipeline "https://github.com/apexstudying-cmd/prepza/blob/main/document_pipeline.py"
click node_ai_service "https://github.com/apexstudying-cmd/prepza/blob/main/ai_service.py"
click node_reusable_generation "https://github.com/apexstudying-cmd/prepza/blob/main/ai_reusable_generation.py"
click node_generation_store "https://github.com/apexstudying-cmd/prepza/blob/main/ai_generation_store.py"
click node_economics "https://github.com/apexstudying-cmd/prepza/blob/main/ai_economics.py"
click node_usage_billing "https://github.com/apexstudying-cmd/prepza/blob/main/usage_billing.py"
click node_subscriptions "https://github.com/apexstudying-cmd/prepza/blob/main/student_subscription_billing.py"
click node_discovery_billing "https://github.com/apexstudying-cmd/prepza/blob/main/discovery_billing.py"
click node_organisation_portal "https://github.com/apexstudying-cmd/prepza/blob/main/b2b_organisation_portal.py"
click node_campaign_payments "https://github.com/apexstudying-cmd/prepza/blob/main/b2b_campaign_payments.py"
click node_object_storage "https://github.com/apexstudying-cmd/prepza/blob/main/object_storage.py"
click node_admin_core "https://github.com/apexstudying-cmd/prepza/blob/main/admin_reconciled_core_a.py"
click node_admin_org "https://github.com/apexstudying-cmd/prepza/blob/main/admin_reconciled_organisation.py"
click node_chat_routes "https://github.com/apexstudying-cmd/prepza/blob/main/chat_group_routes.py"
click node_e2ee_routes "https://github.com/apexstudying-cmd/prepza/blob/main/e2ee_chat_routes.py"
click node_e2ee_client "https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/crypto/e2eeFetchBridge.ts"
click node_backend "https://github.com/apexstudying-cmd/prepza/blob/main/app.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_web_app,node_app_entry,node_document_import,node_generation_ui toneBlue
class node_document_pipeline,node_ai_service,node_reusable_generation,node_generation_store,node_object_storage toneAmber
class node_economics,node_usage_billing,node_subscriptions,node_discovery_billing,node_organisation_portal,node_campaign_payments toneMint
class node_admin_core,node_admin_org toneRose
class node_chat_routes,node_e2ee_routes,node_e2ee_client,node_student toneIndigo
class node_backend toneTeal
```

## Components

### Student app

- [Web application](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Application entry](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Document import](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/ExternalDocumentImport.tsx): `frontend/src/ExternalDocumentImport.tsx`
- [Generation screens](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/generation/GenerationScreens.tsx): `frontend/src/generation/GenerationScreens.tsx`

### Study generation

- [Document extraction](https://github.com/apexstudying-cmd/prepza/blob/main/document_pipeline.py): `document_pipeline.py`
- [AI generation](https://github.com/apexstudying-cmd/prepza/blob/main/ai_service.py): `ai_service.py`
- [Reusable artifacts](https://github.com/apexstudying-cmd/prepza/blob/main/ai_reusable_generation.py): `ai_reusable_generation.py`
- [Generation storage](https://github.com/apexstudying-cmd/prepza/blob/main/ai_generation_store.py): `ai_generation_store.py`
- [Object storage](https://github.com/apexstudying-cmd/prepza/blob/main/object_storage.py): `object_storage.py`

### Plans and payments

- [AI entitlements](https://github.com/apexstudying-cmd/prepza/blob/main/ai_economics.py): `ai_economics.py`
- [Usage billing](https://github.com/apexstudying-cmd/prepza/blob/main/usage_billing.py): `usage_billing.py`
- [Student subscriptions](https://github.com/apexstudying-cmd/prepza/blob/main/student_subscription_billing.py): `student_subscription_billing.py`
- [Discovery billing](https://github.com/apexstudying-cmd/prepza/blob/main/discovery_billing.py): `discovery_billing.py`
- [Organisation portal](https://github.com/apexstudying-cmd/prepza/blob/main/b2b_organisation_portal.py): `b2b_organisation_portal.py`
- [Campaign payments](https://github.com/apexstudying-cmd/prepza/blob/main/b2b_campaign_payments.py): `b2b_campaign_payments.py`

### Administration

- [Admin operations](https://github.com/apexstudying-cmd/prepza/blob/main/admin_reconciled_core_a.py): `admin_reconciled_core_a.py`
- [Organisation admin](https://github.com/apexstudying-cmd/prepza/blob/main/admin_reconciled_organisation.py): `admin_reconciled_organisation.py`

### Secure communications

- [Chat routes](https://github.com/apexstudying-cmd/prepza/blob/main/chat_group_routes.py): `chat_group_routes.py`
- [Encrypted chat API](https://github.com/apexstudying-cmd/prepza/blob/main/e2ee_chat_routes.py): `e2ee_chat_routes.py`
- [Encrypted chat client](https://github.com/apexstudying-cmd/prepza/blob/main/frontend/src/crypto/e2eeFetchBridge.ts): `frontend/src/crypto/e2eeFetchBridge.ts`

### Other components

- **Student**
- [Flask application](https://github.com/apexstudying-cmd/prepza/blob/main/app.py): `app.py`

## Connections

- Student → Application entry: uses
- Application entry → Web application: mounts (evidence: `frontend/src/main.tsx`)
- Application entry → Encrypted chat client: installs bridge (evidence: `frontend/src/main.tsx`)
- Document import → Web application: opens within
- Generation screens → Web application: appears within
- Flask application → Document extraction: imports (evidence: `app.py`)
- Document extraction → Flask application: reads document; updates status (evidence: `document_pipeline.py`)
- Flask application → AI generation: imports (evidence: `app.py`)
- Flask application → AI entitlements: imports (evidence: `app.py`)
- Flask application → Usage billing: imports (evidence: `app.py`)
- Flask application → Student subscriptions: imports (evidence: `app.py`)
- Flask application → Discovery billing: imports (evidence: `app.py`)
- Flask application → Organisation portal: imports (evidence: `app.py`)
- Flask application → Campaign payments: imports (evidence: `app.py`)
- Flask application → Admin operations: imports (evidence: `app.py`)
- Flask application → Organisation admin: imports (evidence: `app.py`)
- Flask application → Chat routes: imports (evidence: `chat_group_routes.py`)
- Reusable artifacts → AI generation: uses generators (evidence: `ai_reusable_generation.py`)
- Reusable artifacts → AI entitlements: checks entitlements (evidence: `ai_reusable_generation.py`)
- Flask application → Reusable artifacts: imports (evidence: `app.py`)
- Flask application → Object storage: imports (evidence: `app.py`)
- Organisation portal → Object storage: uses storage (evidence: `b2b_organisation_portal.py`)
- Encrypted chat client → Encrypted chat API: calls API
- Flask application → Encrypted chat API: registers routes (evidence: `app.py`)
