A React-based frontend application built with Vite, TypeScript, and Material-UI.
- React 18
- TypeScript
- Vite
- Material-UI (MUI)
- TailwindCSS
- React Router
- React Flow
- Node.js (LTS version recommended)
- npm (comes with Node.js)
The following environment variables are required for the application:
VITE_API_URL: The base URL for the API endpointsVITE_WS_URL: WebSocket URL for real-time features
Create a .env file in the root directory with these variables:
VITE_API_URL=http://localhost:8000
VITE_WS_URL=ws://localhost:8000More details check here - Vite Env Variables and Modes
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The application will be available at http://localhost:3000
To build the application for production:
npm run buildThe build output will be in the dist directory.
-
Using npm:
npm run prod
The application will be available at
http://localhost:3000 -
Using Docker:
# Build the Docker image docker build -t genai-frontend . # Run the container docker run -p 3000:3000 genai-frontend
The application will be available at
http://localhost:3000Note: The
-p 3000:3000flag maps the container's port 3000 to your host machine's port 3000. You can change the host port by modifying the first number (e.g.,-p 8080:3000to access viahttp://localhost:8080).
Run the test suite:
npm testThe application uses different ports in various environments. Here's how to change them:
The development server port is configured in vite.config.ts:
server: {
port: 3000,
open: true,
}For more details, see Vite Server Options
The production server port is configured in two places:
- In
Dockerfile:
EXPOSE 3000
CMD [ "serve", "-s", "dist", "-l", "3000" ]- When running with Docker, you can map to a different host port:
# Map container port 3000 to host port 8080
docker run -p 8080:3000 genai-frontendFor more details about serve configuration, see serve-handler options
npm run dev: Start development servernpm run build: Build for productionnpm run preview: Preview production buildnpm run prod: Build and preview production buildnpm run lint: Run ESLintnpm test: Run Jest tests
src/: Source code directorycomponents/: Reusable React componentspages/: Page componentsservices/: API and service functionstypes/: TypeScript type definitionsutils/: Utility functionsApp.tsx: Main application componentmain.tsx: Application entry point