- Overview
- Features
- Demo Accounts
- Installation Guide
- Project Structure
- Tech Stack
- Configuration
- Authentication
- Order Management
- Payment System
- AI Chatbot
- Troubleshooting
- Developer Documentation
- Development Workflow
- Future Roadmap
CarHub is a comprehensive automotive platform built with Flask that combines a beautiful UI with powerful functionality. The application offers a complete solution for car dealerships with features like user authentication, inventory management, order processing, payment integration, and AI-powered customer support.
β Premium UI/UX with Video Backgrounds β User Authentication with Email & Google OAuth β Complete Database Integration β AI-Powered Chatbot Assistant β Order Management & Invoicing β Payment Processing β Admin Panel β 3D Car Models
- Multi-method Authentication: Email/password and Google OAuth
- User Registration: Email validation and verification
- Password Management: Secure reset via email
- Profile Management: User dashboards and settings
- Dynamic Video Backgrounds: Luxury car videos on key pages
- 3D Car Models: Interactive 3D models for vehicle exploration
- Responsive Design: Mobile-friendly on all pages
- Space-themed Design: Modern dark UI with premium feel
- Vehicle Showcase: Comprehensive car listings with filters
- Detailed Views: Complete vehicle specifications
- 3D Models: Interactive 3D vehicle exploration
- Video Gallery: High-quality car videos
- Shopping Cart: Add and manage vehicle selections
- Order Tracking: Real-time order status updates
- PDF Invoices: Generate and download professional invoices
- Order History: Complete purchase records
- Cancellation System: Order cancellation with fee calculation
- Multiple Payment Methods: Credit card, financing options
- Secure Processing: PCI-compliant payment forms
- Payment Confirmation: Success page with order details
- Financial Applications: Vehicle financing options
- Smart Chatbot: OpenAI-powered virtual assistant
- Vehicle Recommendations: Personalized car suggestions
- FAQ Handling: Instant answers to common questions
- Context-aware: Remembers conversation history
- User-specific Responses: Personalized for logged-in users
- User Management: View and edit user accounts
- Order Oversight: Monitor all transactions
- Inventory Control: Manage vehicle listings
- Activity Logs: Track user and system actions
- Email: admin@carhub.com
- Password: admin123
- Email: test@example.com
- Password: password123
- Username: testuser
Before starting, ensure you have the following installed:
- Python 3.9+ (recommended 3.11+)
- pip (Python package manager)
- Git
- A text editor or IDE (VSCode recommended)
# Clone the repository
git clone https://github.com/yourusername/carhub.git
# Navigate to the project directory
cd carhubIt's recommended to use a virtual environment to avoid package conflicts.
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
venv\Scripts\activate# Create a virtual environment
python -m venv venv
# Activate the virtual environment
source venv/bin/activate# Install required packages
pip install -r requirements.txt- Create a
.envfile in the project root:
cp .env.example .env- Edit the
.envfile with your configuration:
# Security
SECRET_KEY=your_generated_secret_key
# Email Configuration (Optional - for password reset emails)
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_DEFAULT_SENDER=your-email@gmail.com
# Google OAuth Configuration (Optional)
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret
# OpenAI Configuration (Required for Chatbot)
OPENAI_API_KEY=your-openai-api-keypython -c "import secrets; print(secrets.token_hex(32))"Copy the output to your .env file as the SECRET_KEY.
The application will automatically create the database on first run, but you can initialize it explicitly:
python app.pypython app.pyThe application will be available at: http://127.0.0.1:5000
You can use the provided test accounts, or create a new admin account:
# Start Python interactive shell
python
# In the Python shell:
from app import app, db, User
from werkzeug.security import generate_password_hash
with app.app_context():
admin = User(
username='admin',
email='your-admin-email@example.com',
password_hash=generate_password_hash('your-secure-password'),
role='admin',
is_verified=True
)
db.session.add(admin)
db.session.commit()
print("Admin account created successfully!")
# Exit the Python shell
exit()carhub1/
βββ app.py # Main Flask application
βββ chatbot.py # AI chatbot implementation
βββ google_auth.py # Google OAuth integration
βββ requirements.txt # Python dependencies
βββ .env # Environment variables (create from .env.example)
βββ instance/
β βββ carhub.db # SQLite database (auto-created)
βββ static/ # Static assets
β βββ style.css # Main stylesheet
β βββ theme.css # Theme styling
β βββ *.glb # 3D car models
β βββ *.mp4 # Video backgrounds
β βββ logo.png # Site logo
βββ templates/ # HTML templates
βββ base.html # Base template with navigation
βββ index.html # Homepage
βββ login.html # Authentication pages
βββ cars.html # Vehicle catalog
βββ ... # Other page templates
- Backend: Flask, SQLAlchemy
- Frontend: HTML5, CSS3, JavaScript
- Database: SQLite
- Authentication: Flask-Login, Google OAuth
- Email: Flask-Mail
- Forms: Flask-WTF
- AI Integration: OpenAI API
- 3D Rendering: Three.js
- PDF Generation: ReportLab
For password reset functionality, configure your email settings in .env:
MAIL_SERVER=smtp.gmail.com
MAIL_PORT=587
MAIL_USE_TLS=True
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_DEFAULT_SENDER=your-email@gmail.comFor Gmail, use an App Password (requires 2FA enabled).
- Create a project in Google Cloud Console
- Enable Google Identity API
- Create OAuth credentials (Web application)
- Add authorized origins and redirect URIs:
- Add credentials to
.env:
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
For AI chatbot functionality:
OPENAI_API_KEY=your-openai-api-keyGet your API key from OpenAI Platform.
The application offers dual authentication methods:
- User registration with email validation
- Secure password storage (Werkzeug hashing)
- Password reset via email
- Remember-me functionality
- One-click sign in with Google
- Automatic account creation for new users
- Profile picture integration
- Email verification through Google
- User selects a vehicle
- Completes payment form
- Order is created with "pending" status
- Upon payment, status changes to "completed"
- User can view order in dashboard
- PDF invoice can be downloaded
- Available for pending orders
- 20% cancellation fee (minimum $500)
- Cancellation logged in activity records
- Status updated to "cancelled"
- Credit/Debit Card
- Financing Application
- Secure form with validation
- Order creation and status tracking
- Success confirmation page
- Email notification (when configured)
- Advanced AI: OpenAI-powered conversational assistant
- Floating Interface: Available on all pages
- Knowledge Base: Complete CarHub information
- Personalization: User-specific responses
- Car Recommendations: Suggests vehicles based on preferences
- Quick Actions: Common query shortcuts
The chatbot can run in two modes:
Works immediately with predefined responses
Requires OpenAI API key in .env file
- Ensure
.envcontains valid SECRET_KEY - For Google OAuth, verify credentials and authorized domains
- Check email configuration for password reset functionality
- For Gmail, use App Password (not regular password)
- Enable 2FA on your Google account
- Verify SMTP settings for your email provider
- Verify API key format and validity
- Check for sufficient credits in OpenAI account
- Test the chatbot functionality directly through the interface
- Ensure instance directory exists and is writable
- If database errors occur, try deleting the database file and restarting:
rm instance/carhub.db python app.py
- Verify that all packages are installed:
pip install -r requirements.txt
- Check Python version compatibility
- Verify credentials and authorized domains
- Check for typos in client ID and secret
If you encounter issues:
- Check the Flask terminal output for errors
- Look in the browser console for frontend issues
- Verify all environment variables are set correctly
- Consult the CarHub development team
-
Flask Web Application (
app.py)- Main application entry point
- Route definitions and handlers
- User authentication logic
- Database models
- Form validation
-
AI Chatbot (
chatbot.py)- OpenAI integration
- Knowledge base management
- Conversational logic
- Car recommendation engine
-
Authentication (
google_auth.py)- Google OAuth integration
- User account management
-
Database (
instance/carhub.db)- SQLite database with SQLAlchemy ORM
- User, Car, Order, and other models
-
Templates (
templates/)- HTML templates with Jinja2 templating
- Modular components
-
Static Assets (
static/)- CSS styling
- JavaScript functionality
- Media files (videos, 3D models)
- id (Primary Key)
- username
- email (Unique)
- password_hash
- google_id (Optional)
- profile_picture (Optional)
- is_verified (Boolean)
- role (admin/user)
- Other profile fields
- id (Primary Key)
- name
- brand
- model
- year
- price
- category
- description
- image_path
- model_path (3D model)
- video_path
- id (Primary Key)
- user_id (Foreign Key)
- car_id (Foreign Key)
- status (pending/completed/cancelled)
- price
- payment_method
- created_at
- cancellation_fee (Optional)
- FinanceApplication
- UserActivity
- Parts
- Reviews
/- Homepage/cars- Car listing/about- About page/services- Services page/contact- Contact page/inventory- Inventory page
/login- User login/sign_up- User registration/logout- User logout/forgot_password- Password recovery/reset_password/<token>- Password reset/auth/google- Google OAuth
/car-details/<car_name>- Detailed car view/part-details/<part_id>- Detailed part view/product-details/<product_id>- Product details
/profile- User profile/dashboard- User dashboard/edit_profile- Edit user profile/my_orders- User orders
/buy/<car_name>- Initiate purchase/payment- Payment processing/payment-success/<int:order_id>- Payment confirmation/finance- Financing application/finance-success/<int:application_id>- Finance approval/download-invoice/<int:order_id>- Invoice PDF generation
/admin_panel- Admin dashboard/admin_users- User management/admin_orders- Order management/admin_activities- Activity logs
/api/chat- Chatbot conversation/api/chat/recommendations- Car recommendations/api/chat/car-details/<car_name>- Car information
- Password hashing with Werkzeug
- Login session management with Flask-Login
- Password reset via secure tokens
- Google OAuth integration with google-auth
- Flask-Mail integration
- HTML email templates
- Token-based verification
- Error handling
- Multi-step checkout flow
- Status tracking
- Cancellation logic with fee calculation
- PDF invoice generation with ReportLab
- OpenAI API integration
- Context-aware conversations
- Fallback responses when API unavailable
- User-specific personalization
- Three.js integration
- GLB model format
- Camera controls and lighting
- Mobile optimization
- Password hashing
- CSRF protection
- Secure session cookies
- OAuth token validation
- Input validation and sanitization
- SQL injection prevention via ORM
- XSS protection
- Sensitive data encryption
- Role-based permissions
- Route protection with login_required
- User ownership validation
- Base styling (
style.css) - Theme components (
theme.css) - Responsive design
- Dark mode support
- Form validation
- 3D model viewer
- Chatbot interface
- Theme toggling
- Video backgrounds
- 3D models
- Responsive images
- Lazy loading
- Clone repository
- Install dependencies
- Configure environment variables
- Initialize database
- Start development server
# Run all tests
python -m unittest discover
# Run specific test file
python -m unittest tests/test_authentication.pyFollow PEP 8 guidelines for Python code. Consider using linters:
# Install flake8
pip install flake8
# Run flake8
flake8 .- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes
- Test thoroughly
- Submit a pull request
- Payment gateway integration
- Multi-language support
- Enhanced admin analytics
- Mobile app integration
- Migration to PostgreSQL
- API rate limiting
- Front-end framework integration
- Containerization with Docker
- Image optimization pipeline
- Server-side rendering
- Database indexing
- Query optimization
Β© 2025 CarHub. All rights reserved.
Your CarHub application now includes a complete authentication system with database connectivity, featuring:
β User Registration & Login System β Password Reset via Email β Database Integration with SQLAlchemy β Enhanced Homepage with Customer Reviews β Video Background Sections β Secure Form Validation
- Sign Up: New user registration with email validation
- Login: Secure user authentication with session management
- Forgot Password: Email-based password reset functionality
- Password Security: Hashed passwords using Werkzeug
- SQLite Database: Lightweight database for user management
- User Model: Complete user schema with authentication fields
- Session Management: Secure user sessions across pages
- Customer Reviews Section: Real customer testimonials with ratings
- Video Backgrounds: Dynamic video sections for different services
- Responsive Design: Mobile-friendly layout
- Modern UI: Space-themed color scheme with smooth animations
- Secure Checkout: Complete payment processing workflow
- Multiple Payment Methods: Credit Card, PayPal, Bank Transfer
- Order Tracking: Order history and status tracking
- Payment Validation: Client and server-side validation
- Transaction Records: Detailed payment records and receipts
All required packages are installed:
pip install -r requirements.txtpython app.pyThe application will be available at: http://127.0.0.1:5000
To enable password reset emails, update these settings in app.py:
# Email configuration (lines 21-27 in app.py)
app.config['MAIL_SERVER'] = 'smtp.gmail.com' # Your SMTP server
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'your-email@gmail.com' # Your email
app.config['MAIL_PASSWORD'] = 'your-app-password' # Your app password
app.config['MAIL_DEFAULT_SENDER'] = 'your-email@gmail.com'- Database file:
carhub.db(created automatically) - User data is stored securely with hashed passwords
To test the payment system, you can run the payment flow test script:
python scripts/test_payment_flow.pyTesting with different payment methods:
- Credit Card: Use any of these test card numbers for successful payments:
- Visa: 4532015112830366
- Mastercard: 5425233430109903
- Amex: 371449635398431
- Any card ending with "0000" will be rejected for testing purposes
- PayPal: Simply select PayPal as the payment method
- Bank Transfer: Select Bank Transfer option for simulated transfers
carhub1/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ instance/
β βββ carhub.db # SQLite database (auto-created)
βββ scripts/ # Helper scripts
β βββ test_payment_flow.py # Payment testing script
βββ static/ # CSS, images, videos
β βββ style.css
β βββ logo.png
β βββ *.mp4 videos, .glb 3D models
βββ templates/ # HTML templates
βββ base.html # Base template with navigation
βββ index.html # Enhanced homepage
βββ login.html # User login page
βββ sign_up.html # User registration
βββ forgot_password.html
βββ reset_password.html
βββ cars.html # Car listing page
βββ car_details.html # Individual car page
βββ payment.html # Payment processing page
βββ payment_success.html # Payment confirmation
βββ my_orders.html # Order history page
- Registration: Users create accounts with email/password
- Login: Secure authentication with session storage
- Password Reset: Token-based email verification system
- Session Management: Automatic login/logout handling
- Customer Reviews: Grid layout with star ratings and avatars
- Statistics: Customer satisfaction metrics
- Video Sections: Background videos for different services
- Responsive Design: Works on all device sizes
- Password Hashing: Secure password storage
- CSRF Protection: Form security with Flask-WTF
- Input Validation: Server-side form validation
- Session Security: Secure session management
- Checkout Flow: Seamless flow from car selection to payment confirmation
- Payment Methods: Support for multiple payment methods
- Client-Side Validation: Real-time form validation with JavaScript
- Server-Side Processing: Secure payment processing with transaction IDs
- Card Validation: Implementation of Luhn algorithm for card number validation
- Order Management: Full order lifecycle from creation to completion
- Payment Success Page: Detailed confirmation with order information
- Visit the homepage: http://127.0.0.1:5000
- Create an account: Click "Sign Up" and register
- Login: Use your credentials to log in
- Test password reset: Try the "Forgot Password" feature
- Explore features: Browse the enhanced homepage sections
- Customize Email Settings: Add your SMTP configuration for password reset
- Add More Features: Expand the car inventory system
- Deploy: Consider deploying to a cloud platform
- Database Backup: Implement regular database backups
The application is fully functional with:
- Database connectivity β
- User authentication β
- Password reset system β
- Enhanced UI/UX β
- Mobile responsiveness β
Your CarHub application is ready for use and further development!