Skip to content

Commit da7e601

Browse files
docs: update Local Development Setup for Vite migration, adjust terminal ports and environment variable prefixes
1 parent b700a81 commit da7e601

1 file changed

Lines changed: 37 additions & 47 deletions

File tree

documents/LocalDevelopmentSetup.md

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This application consists of two separate services that run independently:
2020
**Terminal Organization:**
2121

2222
**Terminal 1**: Backend API - HTTP server on port 8000
23-
**Terminal 2**: Frontend - Development server on port 3000
23+
**Terminal 2**: Frontend - Development server on port 5173
2424

2525
---
2626

@@ -746,15 +746,15 @@ Add the following to `src/App/.env`:
746746

747747
```bash
748748
# API Configuration
749-
REACT_APP_API_BASE_URL=http://127.0.0.1:8000
749+
VITE_API_BASE_URL=http://127.0.0.1:8000
750750

751751
# Optional: Enable debug logging
752-
REACT_APP_DEBUG=true
752+
VITE_DEBUG=true
753753
```
754754

755755
> ⚠️ **Important**:
756-
> - The `REACT_APP_API_BASE_URL` must match the backend API address (default: `http://127.0.0.1:8000`)
757-
> - React apps require `REACT_APP_` prefix for custom environment variables
756+
> - The `VITE_API_BASE_URL` must match the backend API address (default: `http://127.0.0.1:8000`)
757+
> - Vite apps require `VITE_` prefix for custom environment variables
758758
> - After changing `.env`, restart the frontend development server
759759
760760
### 5.3. Install UI Dependencies
@@ -775,11 +775,8 @@ This will install all dependencies listed in `package.json`, including:
775775
- Axios for API calls
776776
- Development tools and testing libraries
777777

778-
> **Note**: The `package.json` includes a proxy configuration. If you see `"proxy": "http://localhost:5000"` in package.json but your backend runs on port 8000, you may need to update it:
779-
> ```json
780-
> "proxy": "http://localhost:8000"
781-
> ```
782-
> Or rely on the `REACT_APP_API_BASE_URL` environment variable instead.
778+
> **Note**: The frontend uses Vite with a dev server proxy configured in `vite.config.ts`. The proxy forwards `/api` and `/history` requests to the backend at `http://localhost:8000`.
779+
> You can also set the `VITE_API_BASE_URL` environment variable in `.env` to configure the backend URL.
783780
784781
#### Troubleshooting npm Installation
785782

@@ -821,73 +818,66 @@ For production builds:
821818
npm run build
822819
```
823820

824-
This creates an optimized production build in the `build/` directory. This step is optional for local development.
821+
This creates an optimized production build in the `dist/` directory. This step is optional for local development.
825822

826823
### 5.5. Start Development Server
827824

828825
```bash
829-
# Start the React development server
830-
npm start
826+
# Start the Vite development server
827+
npm run dev
831828
```
832829

833830
The app will start at:
834831

835832
```
836-
http://localhost:3000
833+
http://localhost:5173
837834
```
838835

839-
The browser should automatically open. If not, manually navigate to `http://localhost:3000`
836+
The browser should automatically open. If not, manually navigate to `http://localhost:5173`
840837

841838
#### Expected Output
842839

843840
When successfully running, you should see output similar to:
844841

845842
```
846-
Compiled successfully!
843+
VITE v6.x.x ready in xxx ms
847844
848-
You can now view the app in the browser.
849-
850-
Local: http://localhost:3000
851-
On Your Network: http://192.168.1.x:3000
852-
853-
Note that the development build is not optimized.
854-
To create a production build, use npm run build.
855-
856-
webpack compiled successfully
845+
➜ Local: http://localhost:5173/
846+
➜ Network: http://192.168.1.x:5173/
847+
➜ press h + enter to show help
857848
```
858849

859-
#### React Development Features
850+
#### Vite Development Features
860851

861852
The development server provides:
862853
- **Hot Module Replacement (HMR)**: Automatically refreshes when you save changes
863854
- **Error Overlay**: Shows compilation errors and runtime errors in the browser
864-
- **API Proxy**: Uses `REACT_APP_API_BASE_URL` from `.env` to connect to backend at `http://127.0.0.1:8000`
855+
- **API Proxy**: Configured in `vite.config.ts` to proxy `/api` and `/history` requests to the backend at `http://localhost:8000`
865856
- **Azure AD Authentication**: Integrated with @azure/msal-react for user authentication
866857

867858
#### Common Frontend Issues
868859

869-
**Port 3000 Already in Use:**
860+
**Port 5173 Already in Use:**
870861
```bash
871862
# Option 1: Use a different port
872-
PORT=3001 npm start # Linux/macOS
873-
$env:PORT=3001; npm start # Windows PowerShell
863+
npx vite --port 3000 # Linux/macOS/Windows
874864

875-
# Option 2: Kill process on port 3000
865+
# Option 2: Kill process on port 5173
876866
# Windows:
877-
netstat -ano | findstr :3000
867+
netstat -ano | findstr :5173
878868
taskkill /PID <process-id> /F
879869

880870
# Linux/macOS:
881-
lsof -i :3000
871+
lsof -i :5173
882872
kill -9 <process-id>
883873
```
884874

885875
**Cannot Connect to Backend API:**
886876
```bash
887877
# 1. Verify backend is running on http://127.0.0.1:8000
888-
# 2. Check REACT_APP_API_BASE_URL in src/App/.env
878+
# 2. Check VITE_API_BASE_URL in src/App/.env
889879
# 3. Check browser console for CORS errors
890-
# 4. Restart frontend after changing .env: Ctrl+C then npm start
880+
# 4. Restart frontend after changing .env: Ctrl+C then npm run dev
891881
```
892882

893883
**Module Not Found or TypeScript Errors:**
@@ -908,7 +898,7 @@ Before using the application, confirm both services are running in separate term
908898
| Terminal | Service | Command | Expected Log Message | Access URL |
909899
|----------|---------|---------|----------------------|------------|
910900
| Terminal 1 | Backend API | `python app.py` | `Uvicorn running on http://127.0.0.1:8000` | http://127.0.0.1:8000 |
911-
| Terminal 2 | Frontend | `npm start` | `webpack compiled successfully` | http://localhost:3000 |
901+
| Terminal 2 | Frontend | `npm run dev` | `VITE ready in xxx ms` | http://localhost:5173 |
912902

913903
### Quick Verification
914904

@@ -925,14 +915,14 @@ curl http://127.0.0.1:8000/health
925915

926916
#### 2. Check Frontend
927917

928-
• Open browser to `http://localhost:3000`
918+
• Open browser to `http://localhost:5173`
929919
• Should see the Conversation Knowledge Mining UI
930920
• Check browser console (F12) for any errors
931921
• Verify no "Cannot connect to backend" errors
932922

933923
#### 3. Test End-to-End Connection
934924

935-
1. Navigate to the main application interface at `http://localhost:3000`
925+
1. Navigate to the main application interface at `http://localhost:5173`
936926
2. Try entering a sample query in the chat interface
937927
3. Verify the frontend successfully communicates with the backend
938928
4. Check Terminal 1 (Backend) for incoming API request logs
@@ -1033,11 +1023,11 @@ python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --t
10331023
# Check environment variables are loaded
10341024
# Linux/macOS:
10351025
env | grep AZURE
1036-
env | grep REACT_APP
1026+
env | grep VITE
10371027

10381028
# Windows PowerShell:
10391029
Get-ChildItem Env:AZURE*
1040-
Get-ChildItem Env:REACT_APP*
1030+
Get-ChildItem Env:VITE*
10411031

10421032
# Validate .env file format (should show key=value pairs)
10431033
# Linux/macOS:
@@ -1162,7 +1152,7 @@ az resource list --resource-group <rg-name> --output table
11621152
#### React App Shows Blank Page
11631153
11641154
1. Check browser console (F12) for JavaScript errors
1165-
2. Verify `REACT_APP_API_BASE_URL` in `src/App/.env`
1155+
2. Verify `VITE_API_BASE_URL` in `src/App/.env`
11661156
3. Clear browser cache or try incognito mode
11671157
4. Verify backend is running and accessible at `http://127.0.0.1:8000`
11681158
@@ -1179,21 +1169,21 @@ fetch('http://127.0.0.1:8000/health')
11791169
# Check CORS configuration
11801170
# Look for CORS errors in browser console (F12 → Console tab)
11811171

1182-
# Verify backend CORS settings allow localhost:3000
1172+
# Verify backend CORS settings allow localhost:5173
11831173
# Check src/api/app.py for CORS middleware configuration
11841174
```
11851175
11861176
**CORS Error Example:**
11871177
```
1188-
Access to fetch at 'http://127.0.0.1:8000/api/...' from origin 'http://localhost:3000'
1178+
Access to fetch at 'http://127.0.0.1:8000/api/...' from origin 'http://localhost:5173'
11891179
has been blocked by CORS policy
11901180
```
11911181
11921182
**Solution:** Verify CORS middleware in `src/api/app.py`:
11931183
```python
11941184
app.add_middleware(
11951185
CORSMiddleware,
1196-
allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"],
1186+
allow_origins=["http://localhost:5173", "http://127.0.0.1:5173"],
11971187
allow_credentials=True,
11981188
allow_methods=["*"],
11991189
allow_headers=["*"],
@@ -1208,10 +1198,10 @@ app.add_middleware(
12081198
# Error: AADSTS900561 - Endpoint only accepts POST
12091199
# Solution: Configure app registration as SPA (Single-Page Application)
12101200
# Azure Portal → App Registrations → Your App → Authentication
1211-
# Add platform: Single-page application with redirect URI http://localhost:3000
1201+
# Add platform: Single-page application with redirect URI http://localhost:5173
12121202

12131203
# Error: AADSTS50011 - Redirect URI mismatch
1214-
# Solution: Add http://localhost:3000 to redirect URIs in app registration
1204+
# Solution: Add http://localhost:5173 to redirect URIs in app registration
12151205
```
12161206
12171207
### Network and Firewall Issues
@@ -1348,7 +1338,7 @@ If issues persist after trying the troubleshooting steps:
13481338
13491339
Once all services are running (as confirmed in Step 6), you can:
13501340
1351-
1. **Explore the Application**: Navigate through the UI at `http://localhost:3000` to explore conversational insights
1341+
1. **Explore the Application**: Navigate through the UI at `http://localhost:5173` to explore conversational insights
13521342
2. **Try Sample Queries**: Follow [SampleQuestions.md](./SampleQuestions.md) for example queries you can ask the system
13531343
3. **Understand the Architecture**: Review [TechnicalArchitecture.md](./TechnicalArchitecture.md) to understand how the system processes conversations
13541344
4. **Customize Your Data**: Follow [CustomizeData.md](./CustomizeData.md) to learn how to import your own conversation data

0 commit comments

Comments
 (0)