AI-powered study assistant for converting lectures to text
# StudyAI
StudyAI is an Arabic-first assistant with one focused workflow:
```text
Upload → Full transcript → Full summary → Questions
```
It is designed so multi-hour audio/video lectures do not depend on one browser request and are never
silently treated as complete when a segment is missing.
## Architecture
```text
Browser (chunked upload + status polling)
│
▼
Flask blueprints ──► SQLite (users, uploads, jobs, segments, results)
│
▼
Redis / RQ ──► dedicated worker
│
├─► FFprobe validation
├─► FFmpeg video/audio → mono 16 kHz FLAC
├─► 30-minute segments with 5-second overlap
├─► Gemini transcription, one recoverable segment at a time
├─► strict ordered completeness check and overlap removal
└─► token-aware full summary and full-coverage questions
```
Flask, Jinja, vanilla JavaScript, and SQLite remain intentionally: the product is a focused modular
monolith and does not need a SPA, ORM, or microservices. Redis stores delivery state; SQLite is the
durable source of truth. RQ is smaller than Celery and supplies `SpawnWorker` for Windows.
## Reliability guarantees
- Browser lifetime and processing lifetime are independent.
- Uploads use server-generated 128-bit IDs and configurable chunks (8 MB by default).
- Public YouTube links and direct audio/video URLs can enter the same transcription,
summary, and question pipeline. Playlists, private videos, and private-network URLs are rejected.
- Duplicate identical chunks are idempotent; conflicting duplicates are rejected.
- The default maximum lecture upload is 5 GB with disk-space reserve checks.
- Video is converted to speech-focused lossless FLAC rather than sent to Gemini as video.
- Completed segment transcripts survive retries and worker restarts.
- A transcript can be assembled only when indexes are exactly `0..N-1`, all successful and non-empty.
- Summary/questions use the complete transcript when it fits; otherwise every segment contributes to a
hierarchical reduction chosen with Gemini token counting. No …