This repository contains the frontend React application for my ByteGenie FullStack Developer Test. The UI allows users to interact with the API using natural language queries and displays the results in a user-friendly format.
Watch the Demo on Youtube.
- React 18
- JavaScript
- Tailwind CSS
- Native fetch API for network requests
- Bun as the JavaScript runtime and package manager
- Vite as the build tool
- Bun: Make sure you have Bun installed. If not, you can install it by following the instructions on the official Bun website.
-
Clone the repository:
git clone https://github.com/Huvinesh-Rajendran-12/bytegenie-frontend.git cd bytegenie-frontend
-
Install dependencies:
bun install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:REACT_APP_BACKEND_PYTHON_API=http://127.0.0.1:8000/query
-
Run the development server:
bun run start
The application should now be running on http://localhost:3000
(or another port if 3000 is occupied).
To create a production build:
bun run build
The built files will be in the dist
directory.
To preview the production build locally:
bun run preview
The UI provides the following key functionalities:
- Natural language query input
- Real-time query processing feedback, such as the different stages of query processing handled by the model.
- Formatted display of query results, using tables, list etc.
- User-friendly error handling and suggestions
The UI interacts with the backend API using a single endpoint:
/query
- POST request to submit natural language queries and receive results
The application uses the native fetch API to make this request, allowing for efficient and straightforward network communication.
- Find me companies that are attending finance related events.
- List the email address for the people working in Singapore.
- Find me the average revenue of companies in the Financial sector.
- Find me the sponsors for events occurring in the next 6 months.
- Find me the partners for events occurring in the next 6 months.
- Find me events that will occur in the year 2025.
- Find me the events that are being attended by technology companies.
- List the people working in Singapore for more than a year.
- List the email address for the people working in Singapore for more than a year.
- Find me the number of companies attending events occurring in 2025 up until March.
- Find me the number of events occurring in 2025 up until May.
During the development of the front-end, I faced the following challenges:
- Implementing real-time updates for long-running queries using fetch API
- Handling streaming responses from the backend, the streaming responses had to be in the correct format to be displayed in the frontend.
- Managing state for ongoing queries and results without additional state management libraries
- Displaying structured data results in a user-friendly manner
- Ensuring responsive design for various screen sizes
If I had more time, I would improve the front-end in the following ways:
- Implement data visualization options (e.g., charts, graphs) for applicable query results
- Add a query history feature for easy access to previous searches
- Develop an autocomplete system for query input based on common patterns
- Implement user authentication for personalized experiences
- Implement error boundary components for better error handling
- Add unit and integration tests for all components
- Optimize the build process further using Bun's capabilities
- Explore advanced features of the fetch API, such as AbortController for cancellable requests
Bun offers several advantages over traditional Node.js setups:
- Faster installation times for dependencies
- Improved performance for JavaScript execution
- Built-in testing capabilities
- Native support for
.env
files
To leverage these benefits, I've adjusted the scripts in package.json
to use Bun. If you encounter any issues related to Bun, please refer to the official Bun documentation.