The AI Procurement Data Analyst frontend is a React-based application that allows users to interact with procurement data through natural language queries. It connects to a FastAPI backend and leverages AI to provide data insights with visualizations and tables. This guide focuses exclusively on setting up and running the frontend.
Ensure you have the following installed:
- Node.js 16+
- npm or yarn
The frontend requires an .env file for configuration. Create a .env file in the frontend directory with the following:
VITE_BACKEND_URL=http://localhost:8000Replace http://localhost:8000 with your FastAPI server's URL if different.
git clone https://github.com/samlak/ai-data-analyst
cd ai-data-analyst/frontendnpm installnpm run devOpen your browser and navigate to http://localhost:5173.
frontend/
├── src/
│ ├── components/ # React components
│ │ ├── ChatMessage.tsx # Input field for natural language queries
│ │ ├── ChatMessage.tsx # Display chat messages and data analysis results
│ │ ├── ImageViewer.tsx # Chart rendering component
│ │ └── SuggestedQuestions.tsx # Suggested questions for users
│ ├── App.tsx # Main application component
├── index.html # Base HTML file
└── package.json # Dependency and project configuration
-
Query Submission:
- Users submit a natural language question through the input field.
- The query is sent to the backend at the
VITE_BACKEND_URL.
-
Data Analysis:
- Backend processes the query and returns analysis results.
- Responses include data in tabular form and visualizations as image URLs.
-
Result Display:
- The frontend renders tables and charts dynamically.
- Users can download visualizations or explore data interactively.
-
ChatMessage- Allows users to type and submit questions.
- Sends queries to the backend using the
VITE_BACKEND_URL.
-
ImageViewer- Renders visualizations from backend-provided image URLs.
- Includes download functionality for charts.
-
SuggestedQuestions- Offers example questions to guide user interactions.
- "What are the top procurement categories by spending?"
- "Show the monthly trend of IT equipment purchases."
- Tabular data appears in a table.
- Visualizations (e.g., bar or line charts) are displayed for relevant queries.
- Click the download button under any chart to save it as a PNG.
-
Modify Components:
- Add or update components in the
src/components/directory to extend functionality.
- Add or update components in the
-
Styling:
- Adjust styles in
index.cssor create new stylesheets for custom designs.
- Adjust styles in
-
API URL:
- Update the
VITE_BACKEND_URLin.envif the backend URL changes.
- Update the