A full-stack application with a FastAPI backend and Next.js frontend for chat-based interactions.
.
├── backend/ # Python FastAPI server
│ ├── index.py # Main FastAPI application
│ ├── requirements.txt
│ └── venv/ # Python virtual environment (created during setup)
└── frontend/ # Next.js React application
├── src/ # Source files
├── public/ # Static assets
└── package.json # Node.js dependencies
Make sure you have the following installed on your system:
- Python 3.10+ - Download Python
- Node.js 18+ - Download Node.js
- npm (comes with Node.js)
This project consists of two separate servers that need to run simultaneously:
- Backend server (FastAPI) on port 8000
- Frontend server (Next.js) on port 3000
- Navigate to the backend directory:
cd backend- Create a Python virtual environment:
python3 -m venv venv- Activate the virtual environment:
# On Linux/Mac:
source venv/bin/activate
# On Windows:
venv\Scripts\activate- Install Python dependencies:
pip install -r requirements.txt- Start the backend server:
uvicorn index:app --reload --host 0.0.0.0 --port 8000The backend server will be running at http://localhost:8000
You can verify it's working by visiting: http://localhost:8000/healthchecker
- Open a new terminal window and navigate to the frontend directory:
cd frontend- Install pnpm (if not already installed) and dependencies:
# Install dependencies using npx pnpm
npx pnpm install- Start the frontend development server:
npx pnpm run next-devThe frontend server will be running at http://localhost:3000
The backend provides the following REST API endpoints:
GET /healthchecker- Health check endpointPOST /session/create- Create a new chat sessionPOST /chat/{session_id}- Send a message to a specific sessionGET /chat/{session_id}/history- Get chat history for a session
The backend uses:
- FastAPI - Modern Python web framework
- Uvicorn - ASGI server
- Pydantic - Data validation
- CORS middleware - Enabled for all origins
To make changes to the backend, edit backend/index.py. The server will automatically reload when you save changes (thanks to the --reload flag).
The frontend uses:
- Next.js 15 - React framework
- React 19 - UI library
- Tailwind CSS 4 - Styling
- Framer Motion - Animations
- pnpm - Package manager
Frontend files are located in frontend/src/. The development server will hot-reload when you make changes.
- If you get
ModuleNotFoundError, make sure your virtual environment is activated - If port 8000 is already in use, either stop the other service or change the port in the uvicorn command
- If you get dependency errors, try removing
node_modulesandpnpm-lock.yaml, then runnpx pnpm installagain - If port 3000 is already in use, Next.js will automatically try port 3001
- On Linux/Mac, you may need to use
sudoor configure permissions for global npm packages - We recommend using
npx pnpminstead of installing pnpm globally to avoid permission issues
- Explore the codebase in
backend/index.pyandfrontend/src/ - Try making API calls to the backend using the frontend
- Customize the chat functionality to fit your needs