This project has two main components:
- Frontend (React): Located in the
bob-chat-bot
directory. - Backend (FastAPI): Located in the
bob-generative-api
directory.
Ensure you have the following installed:
- Python 3.11+
- Node.js and npm (or yarn)
cd bob-generative-api
Create a virtual environment:
python -m venv envbob
Activate the virtual environment:
-
Windows:
envbob\Scripts\activate
-
macOS/Linux:
source venv/bin/activate
Install the required Python packages:
pip install -r requirements.txt
Create .env
using sample and ensure it contains the necessary environment variables for your application.
Start the FastAPI server:
uvicorn app.main:app --host 127.0.0.1 --port 8000
Verify the backend is running by visiting http://127.0.0.1:8000
and checking the API documentation at http://127.0.0.1:8000/docs
.
cd ../bob-chat-bot
Install the required packages using npm or yarn:
-
Using npm:
npm install
-
Using yarn:
yarn install
Start the development server:
-
Using npm:
npm start
-
Using yarn:
yarn start
The React app should now be accessible at http://localhost:3000
.
The FastAPI backend is set up to allow requests from http://localhost:3000
. Ensure this matches your React app's URL.
Make sure .env
in the backend directory is correctly configured with all necessary environment variables. You might also need to configure environment variables for the frontend if your application requires them.
- CORS Issues: If you encounter CORS errors, double-check the
allow_origins
list inmain.py
to ensure it matches your frontend URL. - Port Conflicts: Ensure the backend and frontend are running on different ports (8000 for backend, 3000 for frontend).
- Dependency Issues: Make sure all dependencies in
requirements.txt
andpackage.json
are correctly installed.
You should now have both the FastAPI backend and React frontend set up and running. You can develop and test your application with these instructions. If you encounter any issues, refer to the documentation for FastAPI, React, or the respective libraries you're using.