A professional, secure AI-powered chatbot web application built with Django and integrated with Groq's free LLM API.
- Secure Authentication: User registration and login with password validation
- AI-Powered Chat: Real-time conversations with advanced language models
- Session Management: Create and manage multiple conversation sessions
- Conversation History: All messages are persisted and retrievable
- User Profile: Track usage statistics and account information
- Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Input Validation: Comprehensive security measures including CSRF protection
- Professional UI: Modern, clean interface with Bootstrap 5
- Python 3.13 or higher
- PostgreSQL (optional - SQLite is used by default)
- Modern web browser
- Internet connection (for LLM API access)
git clone <repository-url>
cd assignmentpython -m venv .venvWindows:
.venv\Scripts\activatemacOS/Linux:
source .venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
# Database Configuration
DB_NAME=chatbot_db
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
# Django Secret Key
SECRET_KEY=your-secret-key-here
# Debug Mode
DEBUG=True
# LLM API Configuration (Using Groq - Free Tier)
LLM_API_KEY=your_groq_api_key_here
LLM_API_URL=https://api.groq.com/openai/v1/chat/completions
LLM_MODEL=llama-3.1-70b-versatileGet your free Groq API key:
- Visit https://console.groq.com/
- Sign up for a free account
- Generate an API key
- Add it to your
.envfile
python manage.py makemigrations
python manage.py migratepython manage.py createsuperuserpython manage.py runserverVisit http://127.0.0.1:8000/ in your browser.
- Click "Sign Up" on the login page
- Enter username, email, and password
- Click "Create Account"
- Log in with your credentials
- Type your message in the input box
- Press Enter or click the send button
- Wait for the AI response
- New Conversation: Click the "+" button in the sidebar
- Switch Conversations: Click on any conversation in the sidebar
- Delete Conversation: Click the trash icon next to a conversation
assignment/
βββ chatbot/ # Main Django app
β βββ migrations/ # Database migrations
β βββ static/chatbot/ # Static files (CSS, JS)
β βββ templates/chatbot/ # HTML templates
β βββ admin.py # Admin configuration
β βββ forms.py # Form definitions with validation
β βββ models.py # Database models
β βββ views.py # View functions
β βββ urls.py # URL routing
β βββ llm_service.py # LLM API integration
βββ chatbot_project/ # Project settings
β βββ settings.py # Django settings
β βββ urls.py # Main URL configuration
β βββ wsgi.py # WSGI configuration
βββ Documentation/ # Project documentation (DOCX)
β βββ 1_Project_Proposal.docx
β βββ 2_Software_Requirements_Specification.docx
β βββ 3_Project_Plan.docx
β βββ 4_System_Design_Document.docx
β βββ 5_Test_Plan_and_Summary.docx
β βββ 6_Project_Closing_Report.docx
βββ User_Materials/ # User documentation
β βββ User_Manual.docx
βββ Process_Artifacts/ # Process documents
β βββ Mid_Project_Status_Reports.docx
β βββ Final_Presentation_Outline.docx
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (create this)
βββ README.md # This file
- Password hashing with PBKDF2-SHA256
- CSRF protection on all forms
- Session-based authentication
- Input validation and sanitization
- SQL injection prevention via Django ORM
- XSS protection through template auto-escaping
- Authorization checks on all protected resources
The application includes comprehensive testing:
- Authentication tests
- Chat functionality tests
- Session management tests
- Security tests
- Input validation tests
All test cases are documented in Documentation/5_Test_Plan_and_Summary.docx
Complete project documentation is available in the Documentation/ folder:
- Project Proposal: Project overview and objectives
- SRS: Detailed functional and non-functional requirements
- Project Plan: Work breakdown structure and schedule
- System Design Document: Architecture and design details
- Test Plan and Summary: Testing strategy and results
- Project Closing Report: Final project summary
Additional documentation:
- User Manual: Comprehensive guide for end users
- Status Reports: Mid-project progress reports
- Presentation Outline: Final presentation structure
- Backend: Django 6.0 (Python 3.13)
- Database: SQLite (default) / PostgreSQL
- Frontend: HTML5, CSS3, JavaScript, jQuery
- UI Framework: Bootstrap 5
- LLM API: Groq (Free Tier - LLaMA 3.1 70B)
- Authentication: Django built-in auth system
- Install PostgreSQL
- Create database:
CREATE DATABASE chatbot_db;-
Update
.envfile with PostgreSQL credentials -
Update
settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('DB_NAME'),
'USER': os.getenv('DB_USER'),
'PASSWORD': os.getenv('DB_PASSWORD'),
'HOST': os.getenv('DB_HOST'),
'PORT': os.getenv('DB_PORT'),
}
}Access the Django admin panel at http://127.0.0.1:8000/admin/
Features:
- User management
- Conversation monitoring
- Message history viewing
- System statistics
- Ensure your Groq API key is correctly set in
.env - Check API rate limits if responses fail
- Run
python manage.py migrateif you see database errors - Delete
db.sqlite3and re-run migrations for a fresh start
python manage.py collectstaticThis is an academic project for educational purposes.
[Your Name/Team Name]
For questions or support, please contact [your-email@example.com]
- Voice input/output capabilities
- Multi-language support
- Conversation export functionality
- Mobile applications (iOS/Android)
- Advanced analytics dashboard
- Integration with additional LLM providers
# Setup
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
# Configure .env file with your API key
# Initialize database
python manage.py migrate
# Run server
python manage.py runserver
# Generate documentation (if needed)
python generate_docs_part1.py
python generate_docs_part2.py
python generate_docs_part3.pyNote: This application uses a free-tier LLM API. For production use, consider upgrading to a paid plan or implementing additional caching mechanisms to manage API rate limits effectively.