Skip to content

lubaid-01/Prepare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Prepare β€” AI-Powered Educational Platform

Prepare is a full-stack educational SaaS platform that helps students learn smarter through AI-generated practice exams, conversational AI tutoring, and session-based note management β€” all in one place.


✨ Features

πŸ§ͺ AI Exam Generator

  • Enter any topic (or upload a PDF) and get 10 auto-generated MCQ questions powered by Google Gemini
  • 2-minute countdown timer with color warnings
  • Visual question navigation panel (unanswered β†’ marked β†’ answered)
  • Instant score + detailed answer explanations on submission

πŸ’¬ Conversational AI Tutor

  • Chat with an AI that explains topics interactively with examples
  • Real-time streaming responses β€” no waiting for full replies
  • Full chat history saved and accessible from your dashboard
  • Markdown rendering for clean, structured answers

πŸ“ Notes Manager

  • Create, edit, and delete notes directly within a chat session
  • Notes are auto-saved on page leave
  • Organized per user and per session
  • Soft-delete support (notes are recoverable)

πŸ‘€ User Management

  • Email verification on signup (account inactive until verified)
  • Secure password reset via tokenized email links
  • Daily usage quotas β€” 3 exam generations and 10 chat interactions per day (auto-reset every 24 hours)

πŸ› οΈ Tech Stack

Layer Technology
Backend Django 5.2.5 (Python)
Relational DB PostgreSQL via Neon, Render
Document DB MongoDB Atlas (via MongoEngine ODM)
AI Google Gemini 2.5 Flash API
Frontend Django Templates + Tailwind CSS
JS Vanilla JavaScript + Fetch API
Markdown Marked.js
Email Gmail SMTP
Static Files Whitenoise
Containerization Docker

πŸ—οΈ Architecture Overview

Prepare uses a dual-database architecture:

  • PostgreSQL β€” handles structured, relational data: users, sessions, usage quotas
  • MongoDB β€” handles flexible document storage: chats, exams, notes
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Client                    β”‚
β”‚     (Django Templates + Tailwind + JS)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               Django Backend                β”‚
β”‚  Auth β”‚ Exam Module β”‚ Chat Module β”‚ Notes   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚             β”‚              β”‚
  PostgreSQL      MongoDB       Gemini API
  (Users,        (Exams,        (AI responses,
   Sessions,      Chats,         Question gen,
   Quotas)        Notes)         Streaming)

πŸ” Data Flow

Exam Flow

User Input (Topic + Optional PDF)
        ↓
  opt1_view β†’ File upload to temp folder
        ↓
  Gemini API β†’ Parse JSON questions
        ↓
  Store in MongoDB β†’ Set session['exam_id']
        ↓
  exam_view β†’ User answers questions
        ↓
  update_exam β†’ Save responses + calculate score

Chat Flow

create_chat β†’ New MongoDB chat document
        ↓
  start_chat β†’ Set session['chat_id']
        ↓
  ask_view β†’ Stream response from Gemini
        ↓
  save_chat_history β†’ Store in ChatHistory
        ↓
  Frontend renders Markdown response
        ↓
  create_note β†’ Attach notes to session

πŸ“‘ API Endpoints

Endpoint Method Description
/api/get-gen-ques/ GET Fetch generated exam questions
/api/update-exam/ POST Save user answers & score
/api/create_chat/ POST Create a new chat session
/api/ask/ POST Send message (streaming response)
/api/get-chats/ GET List all user chats
/api/get-chathis/ GET Fetch chat message history
/api/create-note/ POST Create a new note
/api/get-noteslist/ GET List all notes
/api/update-note/ POST Update note content
/api/delete-note/ DELETE Delete a note (soft delete)

βš™οΈ Getting Started

Prerequisites

  • Python 3.x
  • Node.js (for Tailwind CSS compilation)
  • MongoDB Atlas account
  • PostgreSQL database (Neon recommended)
  • Google Gemini API key
  • Gmail account (for SMTP)

1. Clone the repository

git clone https://github.com/lubaid-01/Prepare.git
cd prepare

2. Create and activate a virtual environment

python -m venv venv
source venv/bin/activate      # macOS/Linux
venv\Scripts\activate         # Windows

3. Install dependencies

pip install -r requirements.txt

4. Set up environment variables

Create a .env file in the project root:

DJANGO_SECRET_KEY=your_secret_key
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1

DATABASE_URL=your_postgresql_connection_string
MONGO_URI=your_mongodb_atlas_connection_string

GEMINI_API_KEY=your_google_gemini_api_key

EMAIL_HOST_USER=your_gmail_address
GMAIL_PASSWORD=your_gmail_app_password

5. Apply migrations

python manage.py migrate

6. Compile Tailwind CSS

npm install
npx tailwindcss -i ./static/css/input.css -o ./static/css/output.css --watch

7. Run the development server

python manage.py runserver

Visit http://127.0.0.1:8000 in your browser.


🐳 Docker Setup

docker build -t prepare .
docker run -p 8000:8000 --env-file .env prepare

πŸ” Security

  • CSRF protection on all POST requests
  • @login_required enforced on all protected endpoints
  • Users remain inactive until email is verified
  • Token-based password reset
  • Secrets managed via .env (never committed to version control)

πŸ“ Project Structure

prepare/
β”œβ”€β”€ project/
β”‚   β”œβ”€β”€ core/               # Main app (exam, chat, notes)
β”‚   β”‚   β”œβ”€β”€ views.py        # All core view logic
β”‚   β”‚   └── templates/core/ # HTML templates
β”‚   β”œβ”€β”€ accounts/           # Auth, registration, verification
β”‚   β”œβ”€β”€ static/
β”‚   β”‚   └── js/
β”‚   β”‚       β”œβ”€β”€ exam.js     # Timer, navigation, submission
β”‚   β”‚       β”œβ”€β”€ opt2.js     # Streaming chat, notes panel
β”‚   β”‚       └── profile.js  # Dashboard: history, results
β”‚   └── settings.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ requirements.txt
└── .env.example

🚦 Usage Limits

Feature Daily Limit Reset
Exam Generation 3 per day Every 24 hours
Chat Interactions 10 per day Every 24 hours

🀝 Contributing

Contributions are welcome! Please open an issue first to discuss any changes you'd like to make, then submit a pull request.


πŸ“„ License

This project is licensed under the MIT License.


Built with ❀️ using Django, MongoDB, and Google Gemini.

About

This is main project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors