A Django web application that recommends books based on your MBTI personality type. Take a 12-question personality quiz, and the app uses AI (Groq/LLaMA) to determine your MBTI type, then recommends books from Google Books API based on your personality.
What it does: Users complete a personality quiz with 12 questions about their preferences, work style, and social behavior. The app analyzes their responses using AI to determine their MBTI personality type, then recommends books tailored to their personality.
Core value proposition: A fun, personalized book discovery experience that combines personality psychology with literary recommendations.
Target users:
- Book lovers curious about personality types
- Readers seeking personalized book recommendations
- MBTI enthusiasts looking for a practical application
Aesthetic direction: Warm, cozy, bookish feel with a coffee-shop vibe.
Color palette:
- Primary:
#986c48ff(warm brown) - Background:
#fff6ebff(cream/warm white) - Text: Standard dark colors for readability
Typography:
- Primary: Segoe UI, Arial, sans-serif
- Clean, readable 1.1-1.3rem sizes
Visual assets:
- Bootstrap 5.3 for responsive UI components
- Google Books API thumbnails for book covers
- Card-based layout with subtle shadows
- User lands on quiz page with 12 questions
- Each question presents 3 options (A, B, C)
- Radio buttons for single selection per question
- Submit button sends all answers to server
- Loading state while AI processes answers
- AI (Groq/LLaMA) analyzes answers and returns MBTI type
- MBTI type maps to a genre
- Google Books API fetches 6 books in that genre
- Results display with:
- Book cover (blurred background effect)
- Title and author
- Description with "Read more" toggle
- Link to web reader
- Option to retake quiz
- API failures display friendly error page with retry option
- Form validation requires all questions answered
- Graceful handling of missing book data
Stack:
- Backend: Django 5.x
- AI: Groq API (LLaMA 3 8B model)
- Book Data: Google Books API
- Frontend: HTML5, Bootstrap 5.3, vanilla JS
- Deployment: Gunicorn + Whitenoise
Key endpoints:
GET /- Quiz pagePOST /recommend-books/- Process quiz and show results
Data flow:
- User submits quiz form with 12 answers
- Server builds prompt with Q&A pairs
- Groq API returns MBTI type
- MBTI maps to genre
- Google Books API fetches books by genre
- Results rendered with book data
| MBTI | Genre |
|---|---|
| INFP | Poetry |
| INTP | Science Fiction |
| INFP | Fantasy |
| ENTP | Debate Essays |
| ISFJ | Historical Fiction |
| INFJ | Mystery |
| ENFP | Adventure |
| ISTJ | Biography |
| ESTJ | Business |
| ENTJ | Leadership |
| ESFJ | Romance |
| ESFP | Travel |
| ISFP | Art |
| ESTP | Sports |
| ENFJ | Self-help |
| INTJ | Strategy |
| ISTP | Technology |
- Python 3.12+
- Groq API key (free at https://console.groq.com)
-
Clone and navigate to project:
cd Mini_Project_Sem4 -
Create virtual environment:
python -m venv env source env/bin/activate # Linux/Mac env\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment:
cp .env.example .env # Edit .env and add your GROQ_API_KEY -
Run migrations:
python manage.py migrate
-
Start development server:
python manage.py runserver
-
Open in browser: Navigate to
http://localhost:8000
- Create account at https://render.com
- Connect your GitHub repository
- Create a Web Service:
- Build Command:
pip install -r requirements.txt - Start Command:
gunicorn config.wsgi:application --bind 0.0.0.0:$PORT
- Build Command:
- Add environment variables:
GROQ_API_KEY: Your Groq API keyDJANGO_SECRET_KEY: Generate a secure keyDEBUG:FalseALLOWED_HOSTS: Your domain
- Create account at https://railway.app
- New Project → Deploy from GitHub
- Add environment variables (same as Render)
- Railway auto-detects Django
- Create account at https://pythonanywhere.com
- Open Bash console
- Clone repository
- Set up virtualenv and install requirements
- Configure WSGI file
- Reload web app
| Variable | Required | Default | Description |
|---|---|---|---|
GROQ_API_KEY |
Yes | - | Groq API key for MBTI detection |
DJANGO_SECRET_KEY |
No | dev key | Django secret key |
DEBUG |
No | True | Debug mode |
ALLOWED_HOSTS |
No | localhost | Comma-separated allowed hosts |
CSRF_TRUSTED_ORIGINS |
No | - | CSRF trusted origins |
- Groq API: Free tier includes rate limits. Consider caching or queuing for high traffic.
- Google Books API: 1000 requests/day for free tier.
"Error with Groq API"
- Verify your API key is correct
- Check your Groq API quota
"Error fetching books"
- Google Books API may be rate limited
- Check internet connectivity
Static files not loading
- Run
python manage.py collectstatic - Check STATIC_ROOT configuration
Mini_Project_Sem4/
├── config/ # Django project settings
│ ├── settings.py # Main settings file
│ ├── urls.py # Root URL configuration
│ ├── wsgi.py # WSGI application
│ └── asgi.py # ASGI application
├── core/ # Main application
│ ├── templates/ # HTML templates
│ │ ├── quiz.html # Quiz page
│ │ ├── results.html # Results page
│ │ └── error.html # Error page
│ ├── views.py # View logic
│ ├── urls.py # App URLs
│ ├── models.py # Database models
│ └── apps.py # App configuration
├── static/ # Static files (if any)
├── manage.py # Django CLI
├── requirements.txt # Python dependencies
├── .env # Environment variables (not in git)
├── .env.example # Environment template
├── .gitignore # Git ignore file
├── Procfile # Deployment config
├── runtime.txt # Python version
└── README.md # This file
MIT License - Feel free to use and modify for your projects.
- MBTI to Genre mapping inspired by personality-book correlations
- Powered by Groq LLaMA 3 and Google Books API
- Built with Django and Bootstrap