Readability.Lib
Long stories, cut into two-minute reads with generated imagery.
People who grew up on short video rarely finish a novel. Readability.Lib does not argue with that habit; it works inside it. A story is broken into one- to two-minute passages, each paired with an illustration generated for that exact scene and small interactive beats that keep the reader moving.
The Django backend runs the whole pipeline: Gemini 1.5 writes, summarises and narrates the interactive stories, OpenAI translates, Stable Diffusion XL on Hugging Face draws each scene, and Google Cloud Text-to-Speech and Speech-to-Text make every page something you can listen to or talk to. PDFs go in too, and come out as illustrated, paged reading.
Around the reading sits a small social layer — comments, ratings, profiles and Fernet-encrypted direct messages — and an RPG mode where up to four players share one AI narrator.
It was selected as Engineering Project of the Year at Beykoz University in 2024.
- 2024
- Design, backend, AI pipeline
- Python, Django 4.2, Gemini 1.5, OpenAI, Stable Diffusion XL, Google Cloud TTS / STT, SQLite
- Engineering Project of the Year, Beykoz University
- HTML56.0%
- Python42.6%
- JavaScript1.1%
- CSS0.3%
From the repository
- 6
- 40+
- 5
- 8
Technical architecture
A server-rendered Django 4.2 monolith. Each concern is its own app, and every model call goes out from the view layer to a hosted API — the server never runs a large model itself.
Client
- Django templates
- Vanilla JS
- MediaRecorder
- Polling
Server-rendered pages; small scripts record voice, poll for new chat messages and advance multiplayer turns.
Django apps
- accounts
- pages
- form
- chat
- userProfile
- settings
pages owns stories, PDFs and interactive games; chat owns encrypted messaging; accounts owns OTP sign-up.
AI services
- Gemini 1.5 Flash / Pro
- GPT-3.5 Turbo
- SDXL via Hugging Face
- Cloud Text-to-Speech
- Cloud Speech-to-Text
Gemini writes, summarises and runs the RPG narrator; OpenAI translates; SDXL draws each scene; Google Cloud reads aloud and transcribes.
Storage
- SQLite
- Media files
- Brevo SMTP
SQLite for history and content, the media folder for generated art, Brevo relays the verification e-mails.
From a prompt to a two-minute read
The main generation path, as the pages app implements it.
Brief
Reader picks a category, a word budget and a model — or speaks the idea, transcribed by Speech-to-Text, or uploads an image.
Write
Gemini 1.5 Flash or GPT-3.5 drafts the story inside the word budget; image prompts go through Gemini's file API.
Illustrate
A scene description is sent to Stable Diffusion XL on Hugging Face Inference; the image is saved next to the story.
Listen
Cloud Text-to-Speech reads it in the reader's chosen language and voice, stored per user in LanguageSetting.
Data model
The interactive side is the interesting part of the schema: a game template, a play-through per user, and the narrator's turns hanging off it.
InteractiveGame
- name
- instructions
- music
- image
- numberOfPlayer
Interactive
- user → User
- gameOf → InteractiveGame
- name
InteractiveContent
- partOf → Interactive
- content
- image
Pdf / Page
- user → User
- content
- image
- Page.partOf → Pdf
Messages
- sender, receiver → User
- partOf → Chat
- content (bytes)
- key (bytes)
LanguageSetting
- user ⇄ User
- Reading / Translate / Transcribe
- Generative language
- Reader_gender
Relationships · 11
- User 1 ─< N Story
- Story 1 ─< N Comment
- Story 1 ─< N Rating
- User 1 ── 1 Profile
- User 1 ── 1 LanguageSetting
- InteractiveGame 1 ─< N Interactive
- Interactive 1 ─< N InteractiveContent
- Interactive 1 ─< N Interactive_Story
- Pdf 1 ─< N Page
- Chat 1 ─< N Messages
- User 1 ─< N Messages (sender, receiver)
Engineering decisions
Every message has its own key
Chat content is encrypted with Fernet and stored as bytes; a fresh key is generated per message rather than one key for the whole table.
Multiplayer without WebSockets
Rooms for two to four players are coordinated by short polling endpoints — check room, check player response, check new content — so it runs on plain WSGI.
Accessibility as a setting, not a page
Reading, translation, transcription and generation languages are separate per-user settings, so a Turkish reader can hear an English story in Turkish.
PDFs become pages
pdfminer extracts the text, which is split into Page rows and summarised by Gemini, so a dull document reads like the stories do.
Engineering checklist
The questions a reviewer asks, answered from the code — including the ones where the honest answer is no.
- Database designIn place
- 19 Django models across six apps, about 30 foreign-key and one-to-one relations, and 50 migrations of history. Interactive games are split into template, play-through and turns so a game can be replayed per user without copying it.
- Authentication & authorizationPartly
- Django sessions and its password validators (12-character minimum), plus an e-mail OTP: an email_verification_required decorator blocks every feature until the address is confirmed. The OTP itself sits in a module-level variable — listed as a TODO in the README.
- API & data securityPartly
- CSRF middleware is on, but twelve AJAX views are marked csrf_exempt, and some write views (such as story visibility) do not check that the story belongs to the caller.
- PerformancePartly
- The slow part is the model calls, not Django. One Gemini request returns both the story and its image prompt, split on a marker, which saves a round trip per story; files sent to Gemini are hashed so the same image is not uploaded twice.
- Errors & loggingPartly
- get_object_or_404 for missing records and JSON 400s for bad payloads; no logging framework — diagnostics were print statements.
- TestsNot yet
- The six tests.py files are Django's empty stubs. It was verified by hand for the jury demo.
- Deployment & CI/CDNot yet
- Run locally with runserver and SQLite for the award presentation; DEBUG is on and there is no CI pipeline.
What I would change now
- Keys and SMTP credentials belong in environment variables; a 2024 student repo kept them in settings and views.
- A 1,000-line views.py wants splitting into services: one module per provider, behind one interface.
- Polling worked for the demo; Django Channels would make multiplayer turns instant and cheaper.
Plan a trip, find a travel mate, keep everything in one place.