A web application that provides tax information and calculations through a chatbot interface powered by OpenAI's API.
- Interactive chatbot for tax-related questions
- Real-time responses using OpenAI's GPT model
- Responsive design for desktop and mobile
- Server status indicator
- Automatic retry mechanism for rate-limited requests
- Automatic port selection if default port is in use
- Node.js (v14 or higher)
- npm (v6 or higher)
- OpenAI API key
-
Clone the repository:
git clone https://github.com/yourusername/tax-calculator-website.git cd tax-calculator-website
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here PORT=3001
-
Build the React application:
npm run build
Simply run the batch file to start the server:
start-server.bat
This will:
- Kill any existing processes on port 3001
- Start the server with automatic port selection
- Update the frontend to use the selected port
-
Kill any existing server processes (optional):
node kill-server.js
-
Start the server with automatic port selection:
node start-server.js
-
In a separate terminal, start the React development server (optional, for development only):
npm start
This application is configured to work with Vercel deployment:
-
Install the Vercel CLI:
npm install -g vercel
-
Login to Vercel:
vercel login
-
Deploy the application:
vercel
-
Set up environment variables in the Vercel dashboard:
- Go to your project settings
- Add the
OPENAI_API_KEY
environment variable with your OpenAI API key
-
For production deployment:
vercel --prod
If you encounter a "Failed to fetch" error in the chatbot:
- Check if the server is running
- Verify your OpenAI API key is valid and properly formatted
- Look for any error messages in the server console
- Try restarting the server using the batch file
If port 3001 is already in use:
- Use the
start-server.js
script which will automatically find an available port - Or manually change the PORT in your .env file
If you're having issues with the OpenAI API key:
- Make sure the key is correctly formatted in the .env file
- Check that the key is valid and has not expired
- Verify you have sufficient credits in your OpenAI account
If you're having issues with Vercel deployment:
- Check that your OpenAI API key is correctly set in the Vercel environment variables
- Verify that the API routes are properly configured
- Check the Vercel deployment logs for any errors
server.js
- Express server that handles API requests (for local development)src/
- React frontend source codesrc/components/ChatBot.jsx
- Chatbot componentsrc/pages/api/
- API routes for Vercel deploymentstart-server.js
- Script to start the server with automatic port selection (local only)kill-server.js
- Script to kill processes on port 3001 (local only)vercel.json
- Configuration for Vercel deployment
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for providing the API
- React for the frontend framework
- Express for the backend server
- Vercel for hosting