8000 GitHub - ahmadfaraz629/supercar-assistant
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ahmadfaraz629/supercar-assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperCar Virtual Sales Assistant

Overview

This is a modern web application that implements a chat interface for interacting with an AI sales assistant named Lex. The assistant helps customers with car dealership inquiries, providing information about weather, dealership locations, and appointment scheduling.

Tech Stack

  • Frontend Framework: Next.js 14 with App Router
  • Language: TypeScript
  • State Management: Redux Toolkit with RTK Query
  • Styling: Tailwind CSS
  • UI Components: Custom-built components with Tailwind
  • API Integration: Server-Sent Events (SSE)
  • Development: Docker and Docker Compose
  • Code Quality: ESLint and Prettier

The test evaluates your ability to:

  1. Consume a Server-Sent Events (SSE) API
  2. Handle different types of streaming events
  3. Create custom UI components for different tool outputs
  4. Implement a responsive and user-friendly chat interface
  5. Work with Docker for development

Project Structure

The repository is organized into two main directories:

  • backend/: A FastAPI application that serves the AI agent
  • frontend/: Next.js application implementing the chat interface

Frontend Structure

frontend/
├── src/
│   ├── app/          # Next.js app router pages
│   ├── components/   # Reusable UI components
│   ├── store/        # Redux store configuration
│   ├── styles/       # Global styles and Tailwind
│   └── types/        # TypeScript type definitions
├── public/           # Static assets
└── Dockerfile        # Frontend container configuration

Project Requirements (Original)

This section outlines the original requirements and features that were expected to be implemented:

  1. Chat Interface Requirements

    • Real-time message streaming capability
    • Chat history management
    • Support for Markdown formatting
    • Loading states and error handling
  2. Tool Integration Requirements

    • Weather information display
    • Dealership address lookup
    • Interactive appointment scheduling
    • Visual feedback for tool usage
  3. Design Requirements

    • Mobile-first approach
    • Adaptive layout
    • Touch-friendly interface

Implemented Features and Improvements

This section details the actual implementations and enhancements made to the project:

  1. Enhanced Chat Interface

    • Implemented real-time message streaming using SSE
    • Built persistent chat history with Redux Toolkit
    • Added robust Markdown rendering with syntax highlighting
    • Implemented comprehensive error handling with user-friendly notifications
    • Added typing indicators and message status updates
  2. Advanced Tool Integration

    • Created modular tool components with TypeScript
    • Implemented real-time weather information display with animations
    • Built interactive dealership map integration
    • Developed dynamic appointment scheduling system with availability checking
    • Added loading and success states for tool interactions
  3. Responsive Design Implementation

    • Developed fully responsive layout using Tailwind CSS
    • Implemented smooth transitions and animations
    • Added touch gestures for mobile interactions
    • Optimized UI for various screen sizes and orientations
  4. Performance Optimizations

    • Implemented efficient SSE connection management with automatic reconnection
    • Optimized component re-renders using React.memo and useMemo
    • Added code-splitting and lazy loading for better initial load time
    • Implemented proper cleanup of SSE connections and event listeners

Backend API

The backend provides a single endpoint:

  • POST /query: Accepts a user query and session ID, returns an SSE stream of responses

SSE Event Types

The backend streams different types of events:

  1. chunk: Text chunks from the AI assistant
  2. tool_use: When the AI decides to use a tool (function call)
  3. tool_output: The result of a tool execution
  4. end: Signals the end of the response stream

Available Tools

The AI assistant can use the following tools:

  1. get_weather: Provides weather information for a city
  2. get_dealership_address: Returns the address of a dealership
  3. check_appointment_availability: Checks available appointment slots
  4. schedule_appointment: Books an appointment for a test drive

Requirements

Functional Requirements

  1. Create a chat interface where users can send messages to the AI assistant
  2. Maintain a session ID for conversation history
  3. Display AI responses in real-time as they stream in
  4. Create custom UI components for each tool output:
    • Weather information
    • Dealership address
    • Appointment availability (time slots)
    • Appointment confirmation
  5. Show visual indicators when tools are being used
  6. Handle the complete conversation flow

Technical Requirements

  1. Use a modern JavaScript framework (Next, React, Vue, Angular, etc.)
  2. Implement an SSE client to consume the streaming API
  3. Create reusable components
  4. Implement responsive design
  5. Use Docker for development
  6. Write clean, maintainable code with appropriate comments

Getting Started

Running the Backend

You have two options to run the backend:

Option 1: Using Docker

cd backend
docker build -t SuperCar-assistant-backend .
docker run -p 8000:8000 SuperCar-assistant-backend

Option 2: Using Docker Compose

cd infrastructure
docker-compose up backend

Setting Up Your Frontend

  1. Create your frontend application in the frontend/ directory
  2. Create a Dockerfile similar to the example provided
  3. Configure your application to connect to the backend API at http://localhost:8000

Running with Docker Compose

Once your frontend is ready, you can run the entire stack:

cd infrastructure
docker-compose up

Evaluation Criteria

Your solution will be evaluated based on:

  1. Functionality: Does it meet all the requirements?
  2. Code Quality: Is the code clean, well-organized, and maintainable?
  3. UI/UX Design: Is the interface intuitive and responsive?
  4. Component Design: Are the custom components for tool outputs well-designed?
  5. Error Handling: Does it gracefully handle errors and edge cases?
  6. Performance: Is the application responsive and efficient?

Submission

Please submit your solution as a Git repository with:

  1. Your complete frontend code
  2. A README explaining how to run your solution
  3. Any additional documentation you think is relevant

Tips

  • Focus on creating a smooth, intuitive user experience
  • Pay special attention to how you handle the different event types
  • Create visually distinct components for different tool outputs
  • Consider the user flow and how to make the conversation feel natural
  • Test your solution thoroughly with different conversation scenarios

Good luck!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0