Overview
The PriceSignal frontend is built with:- React 18 - UI framework
- TypeScript - Type safety
- Vite - Fast build tool and dev server
- Apollo Client - GraphQL client for API communication
- Tailwind CSS - Utility-first styling
- Radix UI - Accessible component primitives
Project Structure
The React application is located insrc/react-app/ with the following structure:
Development Scripts
The
npm run dev command uses concurrently to run both dotnet watch for the backend and vite for the frontend, providing a seamless full-stack development experience.Key Dependencies
Core Libraries
- @apollo/client (^3.10.4) - GraphQL client with caching and state management
- react-router-dom (^6.23.1) - Client-side routing
- graphql-ws (^5.16.0) - GraphQL subscriptions over WebSocket
UI Components
- Radix UI - Headless, accessible component primitives:
- Avatar, Dialog, Dropdown Menu, Label, Popover, Select, Slot, Switch, Tabs
- lucide-react (^0.379.0) - Icon library
- klinecharts (^9.8.8) - Cryptocurrency charting library
- recharts (^2.12.7) - Composable charting library
Form Handling
- react-hook-form (^7.51.5) - Performant form management
- @hookform/resolvers (^3.4.2) - Validation resolvers
- zod (^3.23.8) - Schema validation
Styling
- tailwindcss (^3.4.3) - Utility-first CSS framework
- tailwindcss-animate (^1.0.7) - Animation utilities
- class-variance-authority (^0.7.0) - Component variant management
- clsx & tailwind-merge - Conditional class utilities
Authentication
- firebase (^10.12.5) - Firebase SDK for authentication
Development Workflow
Start Development Server
Navigate to the frontend directory and start the dev server:This starts both the ASP.NET Core backend (with hot reload) and Vite dev server.
Access the Application
Open your browser to:
- Frontend:
http://localhost:5173(Vite dev server) - Backend GraphQL:
http://localhost:5000/graphql(or configured port)
Make Changes
Edit files in
src/react-app/src/ and see changes reflected instantly with hot module replacement (HMR).GraphQL Integration
PriceSignal uses GraphQL for all API communication between frontend and backend.Code Generation
The project uses@graphql-codegen/cli to automatically generate TypeScript types from the GraphQL schema:
codegen.ts. This generates:
- Type definitions for queries, mutations, and subscriptions
- React hooks for Apollo Client operations
Apollo Client Setup
Apollo Client is configured to connect to the HotChocolate GraphQL server running on the backend. It supports:- Queries - Fetch data
- Mutations - Modify data
- Subscriptions - Real-time updates via WebSocket
Building for Production
Run Production Build
- Runs TypeScript compiler to check types
- Builds optimized production bundle with Vite
Output Location
Built files are output to
dist/ directory and are served by the ASP.NET Core backend from wwwroot/.Code Quality
Linting
The project uses ESLint with TypeScript support:@typescript-eslint- TypeScript-specific ruleseslint-plugin-react-hooks- React hooks best practiceseslint-plugin-react-refresh- React Fast Refresh compatibility
Formatting
Prettier is configured for code formatting. Format code:TypeScript Configuration
The project uses strict TypeScript settings for maximum type safety. Key compiler options:- Target: ES2020
- Module: ESNext
- Strict mode enabled
- Path aliases configured for clean imports
Common Tasks
Adding a New Component
- Create component in
src/components/ - Use TypeScript for props interface
- Style with Tailwind CSS classes
- Export from index file if needed
Adding a New Route
- Create page component in
src/pages/orsrc/routes/ - Add route to router configuration
- Update navigation if needed
Working with GraphQL
- Write your query/mutation in a
.graphqlfile or as a string - Run
npm run codegento generate types - Import and use the generated hook in your component
Troubleshooting
Port Already in Use
If port 5173 is already in use, Vite will automatically try the next available port. Check the terminal output for the actual URL.GraphQL Type Errors
If you see TypeScript errors related to GraphQL types:- Ensure the backend is running
- Run
npm run codegento regenerate types - Restart the TypeScript server in your IDE
Build Failures
Ifnpm run build fails:
- Check for TypeScript errors:
npx tsc --noEmit - Ensure all dependencies are installed:
npm install - Clear Vite cache:
rm -rf node_modules/.vite
Next Steps
- Backend Development - Learn about the ASP.NET Core backend
- Environment Setup - Initial setup guide