Database Schema
The application uses the following PostgreSQL tables:
- users: Stores user accounts and profiles.
- topics: Main table for each subject the user is learning.
- study_steps: Steps within a study plan (one-to-many from topics).
- quizzes: Quizzes generated for a topic.
- flashcards: Flashcards for vocabulary terms.
- chat_sessions: Stores the conversational history for "Chat Mode" (one-to-one with topics). Note: "Chapter Mode" side-chats are stored directly in
study_steps.chat_history.
Database Setup (Docker)
This application uses a PostgreSQL database running in a Docker container.
1. Start the Database
Run the following command to start the database service:
docker compose up -d db
This starts a PostgreSQL instance on localhost:5433.
2. Initialize the Database
Run the following script to create the necessary tables in the database. This is necessary when setting up the project for the first time, or if you have reset your Docker database volume.
python scripts/create_tables.py
3. Inspecting the Database (Optional)
To manually inspect the database content:
docker compose exec db psql -U postgres -d personal_guru