This folder contains the React web application for the ShopAssistant project. The frontend provides a modern, interactive user interface for registration, login, and chatting with the AI-powered shopping assistant.
-
Install Node.js and npm
- Download and install Node.js (includes npm) from nodejs.org.
- Verify installation:
node -v npm -v
-
Install dependencies
- Open a terminal in this
frontendfolder:npm install
- Open a terminal in this
-
Start the development server
- Run:
npm start
- The app will open in your browser at http://localhost:3000
- Run:
-
Connect to the backend
- Make sure your FastAPI backend is running (see backend README for instructions).
- The frontend expects the backend API (e.g.,
/chat/message) to be available. You may need to set up a proxy (see below).
App.jsx— Main entry point, handles authentication and routing.SignInRegister.jsx— Handles user registration and login.ShopAssistant.jsx— Chat interface for interacting with the assistant.
- Component: A reusable UI building block (e.g.,
App,SignInRegister,ShopAssistant). - State: Data managed by a component (e.g., user info, chat messages).
- Props: Data passed from parent to child components.
- Hooks: Functions like
useStateanduseEffectfor managing state and side effects. - JSX: A syntax extension for writing HTML-like code in JavaScript.
Learn more:
If your backend runs on a different port (e.g., 8000), add a proxy field to your package.json:
"proxy": "http://localhost:8000"This lets you call /chat/message from the frontend without CORS issues.
npm start— Start the dev servernpm run build— Build for productionnpm test— Run tests (if any)
- Build small features and experiment with components and state.
- Use the React DevTools browser extension for debugging.
- Read the React documentation and try the interactive examples.
- Don’t worry about memorizing everything—focus on understanding how components, state, and props work together.
Happy coding! If you get stuck, check the docs above or ask for help.