This project consists of a FastAPI backend and a Next.js frontend that communicates with the backend.
.
├── backend/ # FastAPI backend
│ ├── app/
│ │ └── main.py # Main FastAPI application
│ └── requirements.txt # Python dependencies
└── frontend/ # Next.js frontend
├── pages/
│ └── index.js # Main page
├── public/ # Static files
└── package.json # Node.js dependencies
- Python 3.8+
- Node.js 16+
- npm or yarn
-
Navigate to the backend directory:
cd backend -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the FastAPI server:
uvicorn app.main:app --reload --port 8000
The backend will be available at
http://localhost:8000
-
Navigate to the frontend directory:
cd frontend -
Install dependencies:
npm install # or yarn -
Configure the backend URL (if different from default):
- Open
.env.local - Update
NEXT_PUBLIC_API_URLwith your backend URL - Example:
NEXT_PUBLIC_API_URL=https://your-backend-url.com
- Open
-
Run the development server:
npm run dev # or yarn devThe frontend will be available at
http://localhost:3000
To change the backend URL that the frontend connects to:
- Open the
.env.localfile in the frontend directory - Update the
NEXT_PUBLIC_API_URLvariable with your new backend URL - Save the file
- Restart the Next.js development server for changes to take effect
Example:
NEXT_PUBLIC_API_URL=https://your-new-backend-url.com
npm run build
# or
yarn buildAND
npm run start
# or
yarn startThe frontend will be available at http://localhost:3000
- Ensure both backend and frontend servers are running
- Open the frontend in your browser (default: http://localhost:3000)
- If everything is working correctly, you should see:
- A status message indicating the backend is connected
- The message from the backend: "You've successfully integrated the backend!"
- The current backend URL being used
-
GET /api/health: Health check endpoint- Returns:
{"status": "healthy", "message": "Backend is running successfully"}
- Returns:
-
GET /api/message: Get the integration message- Returns:
{"message": "You've successfully integrated the backend!"}
- Returns: