# daegyu519/oops architecture

> Architecture diagram of the GitHub repository daegyu519/oops, 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/daegyu519/oops
- Repository: https://github.com/daegyu519/oops

## Overview

OOPS! is a chat app that privately analyzes how a draft may sound before it is sent, while keeping ordinary messaging independent of the analysis engine. The main flow is draft in the mobile app → authenticated engine request → tone analysis → private hint or detailed rewrite suggestion; chat messages and room features use Supabase separately. The README also describes mirror practice, feedback, attachments, presence, and push. Some route and mobile implementations were not sampled, so their internal call links are omitted or shown as documented integrations.

Main entry points: [`engine/app/main.py`](https://github.com/daegyu519/oops/blob/main/engine/app/main.py) (FastAPI engine), [`engine/pipeline.py`](https://github.com/daegyu519/oops/blob/main/engine/pipeline.py) (Analysis pipeline), [`apps/mobile/lib/engine.ts`](https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/engine.ts) (Engine client), [`apps/mobile/app/(tabs)/index.tsx`](https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/index.tsx) (Expo chat app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_app["Expo chat app<br/>[index.tsx]"]
  node_rooms["Rooms and messages<br/>[useRoomMessages.ts]"]
  node_room_features["Room interactions<br/>[index.tsx]"]
  node_mirror_ui["Mirror practice UI<br/>[mirror.tsx]"]
  node_report_ui["Report and stats UI<br/>[report.tsx]"]
  node_engine_client["Engine client<br/>[engine.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
end

subgraph group_engine["Analysis engine"]
  node_engine_api["FastAPI engine<br/>[main.py]"]
  node_api_routes["Analysis routes"]
  node_pipeline["Analysis pipeline<br/>[pipeline.py]"]
  node_gate_aggregate["Gate and aggregation<br/>[gate.py]"]
  node_rewrite["Rewrite suggestions<br/>[rewrite.py]"]
  node_registry["Expert registry<br/>[registry.py]"]
  node_llm_expert["LLM experts<br/>[llm.py]"]
  node_model_router["Model router<br/>[router.py]"]
  node_pii_masking["PII masking<br/>[pii.py]"]
  node_engine_db[("Engine repository<br/>[db.py]")]
  node_mirror_service["Mirror practice<br/>[mirror.py]"]
  node_feedback_route["Feedback processing<br/>[feedback.py]"]
end

subgraph group_platform["Data and delivery"]
  node_supabase[("Supabase services")]
  node_providers["Model providers<br/>[providers.py]"]
  node_push["Web Push<br/>[push.py]"]
end

node_person(("Chat user"))

node_person -->|"uses"| node_mobile_app
node_mobile_app -.->|"opens chat"| node_rooms
node_rooms -.->|"reads and writes"| node_supabase_client
node_supabase_client -->|"uses services"| node_supabase
node_mobile_app -.->|"requests analysis"| node_engine_client
node_engine_client -->|"calls API"| node_engine_api
node_engine_api -->|"registers routes"| node_api_routes
node_api_routes -.->|"runs analysis"| node_pipeline
node_pipeline -->|"scores and aggregates"| node_gate_aggregate
node_pipeline -->|"selects experts"| node_registry
node_pipeline -->|"requests rewrites"| node_rewrite
node_registry -->|"creates experts"| node_llm_expert
node_llm_expert -->|"submits prompts"| node_model_router
node_model_router -->|"masks payloads"| node_pii_masking
node_model_router -.->|"calls providers"| node_providers
node_engine_api -->|"receives message webhooks"| node_supabase
node_engine_api -->|"connects repository"| node_engine_db
node_engine_api -.->|"sends notifications"| node_push
node_engine_api -.->|"serves mirror practice"| node_mirror_service
node_mirror_ui -.->|"requests practice"| node_engine_client
node_report_ui -.->|"requests stats"| node_engine_client
node_room_features -.->|"uses chat services"| node_supabase_client
node_api_routes -->|"includes feedback route"| node_feedback_route
node_feedback_route -.->|"stores patterns"| node_engine_db

click node_mobile_app "https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/index.tsx"
click node_rooms "https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/useRoomMessages.ts"
click node_room_features "https://github.com/daegyu519/oops/blob/main/apps/mobile/app/room/%5Bid%5D/index.tsx"
click node_mirror_ui "https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/mirror.tsx"
click node_report_ui "https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/report.tsx"
click node_engine_client "https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/engine.ts"
click node_supabase_client "https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/supabase.ts"
click node_engine_api "https://github.com/daegyu519/oops/blob/main/engine/app/main.py"
click node_api_routes "https://github.com/daegyu519/oops/tree/main/engine/app/routes"
click node_pipeline "https://github.com/daegyu519/oops/blob/main/engine/pipeline.py"
click node_gate_aggregate "https://github.com/daegyu519/oops/blob/main/engine/layers/gate.py"
click node_rewrite "https://github.com/daegyu519/oops/blob/main/engine/layers/rewrite.py"
click node_registry "https://github.com/daegyu519/oops/blob/main/engine/experts/registry.py"
click node_llm_expert "https://github.com/daegyu519/oops/blob/main/engine/experts/llm.py"
click node_model_router "https://github.com/daegyu519/oops/blob/main/engine/harness/router.py"
click node_pii_masking "https://github.com/daegyu519/oops/blob/main/engine/harness/pii.py"
click node_providers "https://github.com/daegyu519/oops/blob/main/engine/harness/providers.py"
click node_engine_db "https://github.com/daegyu519/oops/blob/main/engine/app/db.py"
click node_push "https://github.com/daegyu519/oops/blob/main/engine/jobs/push.py"
click node_mirror_service "https://github.com/daegyu519/oops/blob/main/engine/mirror.py"
click node_feedback_route "https://github.com/daegyu519/oops/blob/main/engine/app/routes/feedback.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_mobile_app,node_rooms,node_room_features,node_mirror_ui,node_report_ui,node_engine_client,node_supabase_client,node_person toneBlue
class node_engine_api,node_api_routes,node_pipeline,node_gate_aggregate,node_rewrite,node_registry,node_llm_expert,node_model_router,node_pii_masking,node_engine_db,node_mirror_service,node_feedback_route toneAmber
class node_supabase,node_providers,node_push toneMint
```

## Components

### Mobile app

- [Expo chat app](https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/index.tsx): `apps/mobile/app/(tabs)/index.tsx`
- [Rooms and messages](https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/useRoomMessages.ts): `apps/mobile/lib/useRoomMessages.ts`
- [Room interactions](https://github.com/daegyu519/oops/blob/main/apps/mobile/app/room/%5Bid%5D/index.tsx): `apps/mobile/app/room/[id]/index.tsx`
- [Mirror practice UI](https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/mirror.tsx): `apps/mobile/app/(tabs)/mirror.tsx`
- [Report and stats UI](https://github.com/daegyu519/oops/blob/main/apps/mobile/app/(tabs)/report.tsx): `apps/mobile/app/(tabs)/report.tsx`
- [Engine client](https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/engine.ts): `apps/mobile/lib/engine.ts`
- [Supabase client](https://github.com/daegyu519/oops/blob/main/apps/mobile/lib/supabase.ts): `apps/mobile/lib/supabase.ts`

### Analysis engine

- [FastAPI engine](https://github.com/daegyu519/oops/blob/main/engine/app/main.py): `engine/app/main.py`
- [Analysis routes](https://github.com/daegyu519/oops/tree/main/engine/app/routes): `engine/app/routes`
- [Analysis pipeline](https://github.com/daegyu519/oops/blob/main/engine/pipeline.py): `engine/pipeline.py`
- [Gate and aggregation](https://github.com/daegyu519/oops/blob/main/engine/layers/gate.py): `engine/layers/gate.py`
- [Rewrite suggestions](https://github.com/daegyu519/oops/blob/main/engine/layers/rewrite.py): `engine/layers/rewrite.py`
- [Expert registry](https://github.com/daegyu519/oops/blob/main/engine/experts/registry.py): `engine/experts/registry.py`
- [LLM experts](https://github.com/daegyu519/oops/blob/main/engine/experts/llm.py): `engine/experts/llm.py`
- [Model router](https://github.com/daegyu519/oops/blob/main/engine/harness/router.py): `engine/harness/router.py`
- [PII masking](https://github.com/daegyu519/oops/blob/main/engine/harness/pii.py): `engine/harness/pii.py`
- [Engine repository](https://github.com/daegyu519/oops/blob/main/engine/app/db.py): `engine/app/db.py`
- [Mirror practice](https://github.com/daegyu519/oops/blob/main/engine/mirror.py): `engine/mirror.py`
- [Feedback processing](https://github.com/daegyu519/oops/blob/main/engine/app/routes/feedback.py): `engine/app/routes/feedback.py`

### Data and delivery

- **Supabase services**
- [Model providers](https://github.com/daegyu519/oops/blob/main/engine/harness/providers.py): `engine/harness/providers.py`
- [Web Push](https://github.com/daegyu519/oops/blob/main/engine/jobs/push.py): `engine/jobs/push.py`

### Other components

- **Chat user**

## Connections

- Chat user → Expo chat app: uses
- Expo chat app → Rooms and messages: opens chat
- Rooms and messages → Supabase client: reads and writes (evidence: `apps/mobile/lib/useRoomMessages.ts`)
- Supabase client → Supabase services: uses services
- Expo chat app → Engine client: requests analysis
- Engine client → FastAPI engine: calls API
- FastAPI engine → Analysis routes: registers routes (evidence: `engine/app/main.py`)
- Analysis routes → Analysis pipeline: runs analysis
- Analysis pipeline → Gate and aggregation: scores and aggregates (evidence: `engine/pipeline.py`)
- Analysis pipeline → Expert registry: selects experts (evidence: `engine/pipeline.py`)
- Analysis pipeline → Rewrite suggestions: requests rewrites (evidence: `engine/pipeline.py`)
- Expert registry → LLM experts: creates experts (evidence: `engine/experts/registry.py`)
- LLM experts → Model router: submits prompts (evidence: `engine/experts/llm.py`)
- Model router → PII masking: masks payloads (evidence: `engine/harness/router.py`)
- Model router → Model providers: calls providers (evidence: `engine/harness/router.py`)
- FastAPI engine → Supabase services: receives message webhooks
- FastAPI engine → Engine repository: connects repository (evidence: `engine/app/main.py`)
- FastAPI engine → Web Push: sends notifications
- FastAPI engine → Mirror practice: serves mirror practice (evidence: `engine/app/main.py`)
- Mirror practice UI → Engine client: requests practice
- Report and stats UI → Engine client: requests stats
- Room interactions → Supabase client: uses chat services
- Analysis routes → Feedback processing: includes feedback route (evidence: `engine/app/main.py`)
- Feedback processing → Engine repository: stores patterns
