Repository navigation
Data and Logging
Every request is logged to a SQLite database after the response is sent. Sources: app/database/models.py, app/database/db.py, app/services/interaction_logger.py.
The log stores full user queries, generated answers and session IDs in plaintext, in nutripepper.db (gitignored). There is no retention limit, anonymisation or deletion tool. If the robot is used by children or in a public setting, decide on a retention policy and tell users before deploying. Never commit the database or paste rows from it into issues.
erDiagram
interactions ||--o| query_details : has
interactions ||--o| learn_details : has
interactions ||--o{ retrieved_chunks : has
interactions {
string id PK
string session_id
enum endpoint
datetime created_at
float latency_ms
bool is_conversational
}
query_details {
string interaction_id FK
text original_query
text processed_query
text generated_response
bool citations_present
int citation_count
float grounding_score
string grounding_label
bool has_contradiction
int claims_checked
int claims_supported
}
learn_details {
string interaction_id FK
text concept
string lesson_mode
text sources_used
int total_beats
text beat_types
text lesson_json
text lesson_text
text quiz_hints
text description
}
retrieved_chunks {
string interaction_id FK
int chunk_index
string source
string authority
string domain
text text_preview
}
Notes: IDs are UUID strings. endpoint is query or learn. retrieved_chunks.text_preview keeps the first 500 characters. sources_used, beat_types and quiz_hints are comma-joined strings. latency_ms covers the pipeline call only: it excludes background verification and the HTTP layer.
- Tables are created at startup (
create_all). - Writes happen in a background task after the response. A failed write is logged and the user still gets the response.
- SQLite runs in WAL mode with
synchronous=NORMALand a 30 second busy timeout, so overlapping writers wait instead of failing withdatabase is locked. While the app runs you will seenutripepper.db-walandnutripepper.db-shmnext to the database; copy all three files together if you move it. - Change the location with
DATABASE_URL(the default path is relative to the working directory).
Alembic scripts exist in alembic/versions/ (revisions ab0ece7a381a -> f1a75e759958 -> 61126318d2a0), but they do not work on a new database:
- On an empty database,
alembic upgrade headfails withno such table: learn_details. - On a database the app created, it fails with
duplicate column name: lesson_mode.
The app creates the current schema itself. The scripts only upgrade databases created by older versions. For a new database, start the app once, then mark it as current:
alembic stamp head
alembic current # should show 61126318d2a0 (head)Tested on a temporary database. alembic/env.py uses DATABASE_URL and a synchronous SQLite driver.
-- how grounded were /query answers?
SELECT grounding_label, COUNT(*) FROM query_details GROUP BY grounding_label;
-- latency by endpoint
SELECT endpoint, COUNT(*), ROUND(AVG(latency_ms)) AS mean_ms
FROM interactions GROUP BY endpoint;
-- answers where a contradiction was detected
SELECT original_query, grounding_score FROM query_details WHERE has_contradiction = 1;Open the database read-only, for example sqlite3 -readonly nutripepper.db.
Documentation last verified against the code on 2026-11-05. Evaluation figures are historical, see Evaluation. Educational tool, not medical advice.
Use it
How it works
- Architecture
- Retrieval Pipeline
- LLM Layer
- Prompts and Lessons
- Grounding Verification
- Knowledge Base
- Data and Logging
Quality
Develop