# dhrumilshah-216/rubix26_60_remedy architecture

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

- Interactive diagram: https://gitdiagram.com/dhrumilshah-216/rubix26_60_remedy
- Repository: https://github.com/dhrumilshah-216/rubix26_60_remedy

## Overview

#### Purpose and Runtime

This is a Python 3.10 Streamlit prototype for privacy-focused online-exam proctoring. It monitors a student webcam, records explainable risk events rather than cheating verdicts, stores short anomaly evidence, and provides a separate supervisor-facing review interface. Python 3.10 is a material constraint because of MediaPipe compatibility.

Primary entry points:
- `app.py` — Streamlit application entry point, expected student/supervisor UI host.
- `supervisor.py` — supervisor/principal review workflow.
- `requirements.txt` — Python runtime dependencies, including the CV/UI/AI stack.

#### Interface Separation

The architecture intentionally separates two roles:
- Student monitoring should expose only a minimal camera-preview experience and keep alerts, risk scores, and logs hidden.
- Supervisor review reads persisted artifacts and presents session risk summaries, timelines, and evidence playback.

The likely implementation boundary is between live capture/monitoring in `app.py` and post-/near-real-time audit consumption in `supervisor.py`. Both communicate through disk-backed logs and evidence rather than a shared database or in-memory service.

#### Live Monitoring and Vision Detection

The student-side monitoring stage acquires webcam frames and applies OpenCV plus MediaPipe face detection. Detection categories are face absence, multiple faces, approximate looking-away/head orientation, and session-level identity consistency against a login reference image.

Architectural characteristics:
- Detections are expected to require persistence/repetition, preventing isolated transient observations from becoming meaningful risk signals.
- Identity comparison is session-local; no external face database is part of the design.
- The monitoring control loop belongs under the Streamlit process launched from `app.py`.

Relevant path:
- `app.py`

#### Event Contract and Durable Audit Boundary

Suspicious observations are converted into append-only JSONL event records. Each record carries student/session identity, event type/subtype, timestamp and duration, confidence, evidence path, and device/session metadata.

Disk persistence is the primary integration contract: monitoring writes records, while supervisor workflows read them. This supports auditability and avoids relying on volatile process state.

Relevant paths:
- `logs/.gitkeep` — persisted event-log directory.
- `app.py`
- `supervisor.py`

#### Evidence Capture and Privacy Boundary

The system is designed not to continuously record exams. A rolling frame buffer should retain recent context so that a confirmed anomaly can emit a clip containing approximately five seconds before and after the event. Evidence files are persisted separately and referenced by event records.

This is the key privacy boundary: only event-associated clips should cross from live webcam processing into durable storage and supervisor review.

Relevant paths:
- `evidence/.gitkeep` — evidence-video storage directory.
- `logs/.gitkeep` — event-to-evidence references.
- `app.py`

#### Risk Aggregation and Escalation

Individual detections feed an explainable cumulative 0–100 risk score. Pattern-based accumulation and time-based decay distinguish low-level logging from medium UI highlighting and high supervisor alerts. The system’s stated policy is advisory: risk signals and evidence support human decisions; it must not automatically accuse, label, or punish students.

This stage is logically between detection/event creation and the supervisor presentation layer.

Relevant paths:
- `app.py`
- `supervisor.py`

#### Supervisor Review and External AI

The supervisor interface loads stored session events and evidence, renders risk timelines/summaries, and allows manual clip review. AI-generated audit summaries use the OpenAI API, making OpenAI an external service dependency and a boundary where only appropriately scoped audit context should be sent.

The application also includes an alarm media asset, likely for supervisor-side high-risk notification rather than student interruption.

Relevant paths:
- `supervisor.py`
- `assets/alarm.mp3`
- `requirements.txt`

Main entry points: [`logs/.gitkeep`](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/logs/.gitkeep) (JSONL event records), [`supervisor.py`](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py) (Supervisor workflow), [`evidence/.gitkeep`](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/evidence/.gitkeep) (Anomaly clips), [`app.py`](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py) (Rolling frame buffer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student["Student Monitoring"]
  node_app["Streamlit monitor<br/>Python entry point<br/>[app.py]"]
  node_capture["Webcam capture<br/>live frames"]
  node_vision["Vision detection<br/>OpenCV + MediaPipe<br/>[app.py]"]
  node_persistence["Persistence filter<br/>detection policy"]
  node_risk["Risk aggregation<br/>explainable scoring<br/>[app.py]"]
  node_buffer["Rolling frame buffer<br/>privacy buffer<br/>[app.py]"]
end

subgraph group_audit["Audit Storage"]
  node_event["JSONL event records<br/>append-only audit contract<br/>[.gitkeep]"]
  node_evidence[("Anomaly clips<br/>evidence storage<br/>[.gitkeep]")]
end

subgraph group_supervisor["Supervisor Review"]
  node_supervisor_app["Supervisor workflow<br/>Python entry point<br/>[supervisor.py]"]
  node_review["Session review<br/>timeline and playback<br/>[supervisor.py]"]
  node_alerts["High-risk alert<br/>supervisor notification<br/>[alarm.mp3]"]
  node_ai_summary["AI audit summary<br/>OpenAI API integration<br/>[supervisor.py]"]
end

node_openai{{"OpenAI API<br/>external AI service"}}
node_dependencies["Python 3.10 CV/UI stack<br/>runtime dependencies<br/>[requirements.txt]"]

node_dependencies -.->|"provides runtime"| node_app
node_dependencies -.->|"provides runtime"| node_supervisor_app
node_app -->|"runs"| node_capture
node_capture -->|"frames"| node_vision
node_vision -->|"observations"| node_persistence
node_persistence -->|"confirmed signals"| node_risk
node_capture -->|"recent frames"| node_buffer
node_persistence -->|"append audit event"| node_event
node_risk -->|"record score context"| node_event
node_persistence -->|"confirmed anomaly"| node_buffer
node_buffer -->|"emit event clip"| node_evidence
node_evidence -->|"evidence path"| node_event
node_event -->|"read persisted events"| node_supervisor_app
node_evidence -->|"load clips"| node_supervisor_app
node_supervisor_app -->|"renders"| node_review
node_review -->|"high-risk notification"| node_alerts
node_review -->|"scoped audit context"| node_ai_summary
node_ai_summary -->|"generate summary"| node_openai

click node_app "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py"
click node_vision "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py"
click node_risk "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py"
click node_buffer "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py"
click node_event "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/logs/.gitkeep"
click node_evidence "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/evidence/.gitkeep"
click node_supervisor_app "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py"
click node_review "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py"
click node_alerts "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/assets/alarm.mp3"
click node_ai_summary "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py"
click node_dependencies "https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/requirements.txt"

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_capture,node_vision,node_persistence,node_risk,node_buffer toneBlue
class node_event,node_evidence toneAmber
class node_supervisor_app,node_review,node_alerts,node_ai_summary toneMint
class node_openai,node_dependencies toneNeutral
```

## Components

### Student Monitoring

- [Streamlit monitor](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py): Python entry point · Hosts the student-facing camera experience and live control loop. · `app.py`
- **Webcam capture**: live frames
- [Vision detection](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py): OpenCV + MediaPipe · Detects absence, multiple faces, looking away, and session-local identity mismatch. · `app.py`
- **Persistence filter**: detection policy · Requires repeated observations before creating meaningful risk signals.
- [Risk aggregation](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py): explainable scoring · Accumulates and decays advisory 0–100 session risk. · `app.py`
- [Rolling frame buffer](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/app.py): privacy buffer · Retains recent context only until a confirmed anomaly needs evidence. · `app.py`

### Audit Storage

- [JSONL event records](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/logs/.gitkeep): append-only audit contract · Records session, event, timing, confidence, evidence reference, and metadata. · `logs/.gitkeep`
- [Anomaly clips](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/evidence/.gitkeep): evidence storage · Stores event-associated clips rather than continuous exam recording. · `evidence/.gitkeep`

### Supervisor Review

- [Supervisor workflow](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py): Python entry point · Loads persisted sessions for human review. · `supervisor.py`
- [Session review](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py): timeline and playback · Presents risk summaries, event timelines, and manual evidence review. · `supervisor.py`
- [High-risk alert](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/assets/alarm.mp3): supervisor notification · Highlights advisory high-risk sessions without automated punishment. · `assets/alarm.mp3`
- [AI audit summary](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/supervisor.py): OpenAI API integration · Receives appropriately scoped audit context for generated summaries. · `supervisor.py`

### Other components

- **OpenAI API**: external AI service
- [Python 3.10 CV/UI stack](https://github.com/dhrumilshah-216/rubix26_60_remedy/blob/main/requirements.txt): runtime dependencies · MediaPipe compatibility makes Python 3.10 material. · `requirements.txt`

## Connections

- Python 3.10 CV/UI stack → Streamlit monitor: provides runtime
- Python 3.10 CV/UI stack → Supervisor workflow: provides runtime
- Streamlit monitor → Webcam capture: runs
- Webcam capture → Vision detection: frames
- Vision detection → Persistence filter: observations
- Persistence filter → Risk aggregation: confirmed signals
- Webcam capture → Rolling frame buffer: recent frames
- Persistence filter → JSONL event records: append audit event
- Risk aggregation → JSONL event records: record score context
- Persistence filter → Rolling frame buffer: confirmed anomaly
- Rolling frame buffer → Anomaly clips: emit event clip
- Anomaly clips → JSONL event records: evidence path
- JSONL event records → Supervisor workflow: read persisted events
- Anomaly clips → Supervisor workflow: load clips
- Supervisor workflow → Session review: renders
- Session review → High-risk alert: high-risk notification
- Session review → AI audit summary: scoped audit context
- AI audit summary → OpenAI API: generate summary
