An intelligent car financing and leasing recommendation platform that uses OpenAI's API with web search to provide personalized Toyota vehicle recommendations based on your financial profile and lifestyle needs.
- AI-Powered Analysis: Uses OpenAI's GPT-4o with web search to find the best Toyota vehicles for your budget
- Real-Time Data: Fetches current pricing, APR rates, and lease terms from toyota.com and kbb.com
- Three Tier System: Get personalized recommendations across Budget, Balanced, and Premium categories
- Dynamic Finance Calculator: Adjust down payment and loan term with real-time monthly payment updates
- Lease Calculator: Customize lease terms and annual mileage with instant payment adjustments
- Live Calculations: Uses actual loan amortization formulas for accurate estimates
- 10-Question Assessment: Comprehensive financial and lifestyle analysis
- Smart Recommendations: Based on:
- Income and expenses
- Credit score range
- Ownership horizon
- Annual mileage
- Passenger needs
- Commute profile
- Modern Design: Clean, Toyota-branded interface with smooth animations
- Responsive: Works seamlessly on desktop, tablet, and mobile
- Interactive Sliders: Real-time adjustment of financial parameters
- Image Carousel: Multiple views for each recommended vehicle
- React 18.3 - UI library
- TypeScript - Type safety
- Vite - Fast build tool
- Tailwind CSS - Utility-first styling
- Framer Motion - Smooth animations
- Radix UI - Accessible component primitives
- React Router - Client-side routing
- Node.js 20+ - Runtime environment
- Express.js - Web framework
- TypeScript - Type safety
- OpenAI API - AI recommendations with web search
- CORS - Cross-origin resource sharing
- dotenv - Environment variable management
Before you begin, ensure you have the following installed:
- Node.js (v20 or higher) - Download
- npm (comes with Node.js)
- OpenAI API Key - Get one here
git clone https://github.com/yourusername/Toyota-Financing.git
cd Toyota-Financingcd frontend
npm installcd ../backend
npm installCreate a .env file in the backend directory:
cd backend
touch .envAdd your OpenAI API key to .env:
OPENAI_API_KEY=your-actual-openai-api-key-here
⚠️ Important: Never commit your.envfile to version control. It's already in.gitignore.
You'll need two terminal windows - one for frontend, one for backend.
cd backend
npm run devThe backend will start on http://localhost:3000
cd frontend
npm run devThe frontend will start on http://localhost:5173
cd frontend
npm run buildcd backend
npm run buildToyota-Financing/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── App.tsx # Main application component
│ │ ├── main.tsx # Application entry point
│ │ ├── index.css # Global styles
│ │ └── components/ # Reusable UI components
│ │ └── ui/ # Radix UI components
│ ├── public/ # Static assets
│ ├── package.json # Frontend dependencies
│ └── vite.config.ts # Vite configuration
│
├── backend/ # Express backend server
│ ├── src/
│ │ └── index.ts # Main server file with OpenAI integration
│ ├── package.json # Backend dependencies
│ ├── tsconfig.json # TypeScript configuration
│ └── .env # Environment variables (create this!)
│
├── .gitignore # Git ignore rules
└── README.md # This file
User fills questionnaire → Backend sends to OpenAI → AI searches web for data →
Returns 3 vehicle recommendations → Frontend displays with interactive calculators
- Uses OpenAI Responses API with
gpt-4omodel - Web Search Tool: Searches toyota.com and kbb.com for real-time data
- Structured Output: Returns JSON with vehicle specs, pricing, and financing terms
payment = (loanAmount × monthlyRate × (1 + monthlyRate)^months) /
((1 + monthlyRate)^months - 1)adjustedPayment = basePayment × mileageMultiplier × termMultiplier- Mileage: +3% per 2,500 miles over 12,000/year base
- Term: ±1-1.5% per 6 months from 36-month base
Generates personalized vehicle recommendations based on user financial profile.
Request Body:
{
"gross_monthly_income": 4000,
"other_monthly_income": 2000,
"fixed_monthly_expenses": 1000,
"liquid_savings": 10000,
"credit_score": "580-669 (Fair)",
"ownership_horizon": "5-6 years",
"annual_mileage": "10,000-15,000",
"passenger_needs": "2-3 people",
"commute_profile": "City driving",
"down_payment": 100
}Response:
{
"Budget": {
"year": 2025,
"make": "Toyota",
"model": "Corolla",
"trim": "LE",
"price": 23460,
"mileage": "35 MPG combined",
"seats": 5,
"headline_feature": "Compact efficiency",
"finance": {
"apr_percent": 5.99,
"term_months": 60,
"estimated_monthly_payment": 451
},
"lease": {
"term_months": 36,
"estimated_monthly_payment": 269,
"annual_mileage_limit": 10000,
"lease_score": 75
}
},
"Balanced": { /* ... */ },
"Premium": { /* ... */ },
"Affordability": { /* ... */ },
"Recommendation": { /* ... */ }
}OpenAIError: Missing credentials. Please pass an apiKey...Solution: Ensure .env file exists in backend/ directory with valid OPENAI_API_KEY
Solution: Use tsx instead of ts-node:
npm run dev # This uses tsxSolution: Kill the process using port 3000:
# macOS/Linux
lsof -ti:3000 | xargs kill -9
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /FSolution:
- Check backend terminal for error messages
- Verify backend is running on port 3000
- Ensure OpenAI API key is valid
Solution: Backend already has CORS enabled. If issues persist:
- Clear browser cache
- Restart both frontend and backend servers
Solution:
- Check that you're using
gpt-4o(notgpt-4.1or other invalid models) - Verify your OpenAI account has API access enabled
Solution:
- Wait a few moments and try again
- Check your OpenAI usage limits at platform.openai.com
- Credit Score Impact: Better credit scores result in lower APR recommendations
- Down Payment: Higher down payments significantly reduce monthly payments
- Lease vs Finance: Leasing typically offers lower monthly payments but no ownership
- Mileage Consideration: High annual mileage makes financing more economical than leasing
- Term Length: Longer terms = lower monthly payments but more total interest
- Never commit
.envfiles to version control - API keys should be kept secret and rotated regularly
- Backend validation sanitizes all user inputs
- HTTPS recommended for production deployments
| Variable | Description | Required | Example |
|---|---|---|---|
OPENAI_API_KEY |
Your OpenAI API key | Yes | sk-proj-... |
PORT |
Backend server port | No | 3000 (default) |
- Build:
npm run build - Deploy
dist/directory - Set environment variable for API URL if needed
- Ensure
package.jsonhasstartscript - Set
OPENAI_API_KEYenvironment variable - Deploy from GitHub or via CLI
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Amogh Sood
- OpenAI - AI recommendations with web search
- Toyota - Vehicle data source
- Kelley Blue Book - Pricing and specifications
- Radix UI - Accessible component primitives
- Framer Motion - Animation library
If you encounter any issues or have questions:
- Check the Troubleshooting section
- Review existing GitHub issues
- Create a new issue with detailed information
Made with ❤️ for Toyota enthusiasts