Advanced Real-Time Sales Analytics System
Objective:
Build a system to manage and analyze sales data in real-time. The task will involve
leveraging AI systems like OpenAI's ChatGPT or Gemini for assistance and generating
recommendations, while other parts of the system must be written manually. The project
must include a real-time reporting feature and integration with external APIs.
Task Details:
Backend Requirements:
- APIs to Manage Orders and Analytics:
β POST /orders: Add a new order to the database with fields: product ID,
quantity, price, and date.
β GET /analytics: Return real-time sales insights, including:
β Total revenue.
β Top products by sales.
β Revenue changes in the last 1 minute.
β Count of orders in the last 1 minute.
- Real-Time Reporting:
β Implement WebSocket support for the frontend to subscribe to updates for:
β New orders.
β Updated analytics.
β Publish updates in real-time when new orders are added.
- AI Integration (via API like ChatGPT/Gemini):
β Provide an endpoint:
β GET /recommendations:
β Sends recent sales data to the AI system.
β Receives product promotion suggestions or strategic actions.
β Example AI prompt:
β "Given this sales data, which products should we promote for higher
revenue?"
- External API Integration:
β Integrate with a weather API (e.g., OpenWeather) to adjust recommendations:
β Promote cold drinks on hot days or hot drinks on cold days.
β Add logic to suggest dynamic pricing based on weather or seasonality.
- Manual Implementation Requirements:
β All database queries, real-time logic, and API integrations must be written
manually (no ORM or prebuilt frameworks).
β Use a lightweight database like SQLite for simplicity.
Evaluation Criteria:
- Code Quality and Structure (30 points):
β Clean, organized, and readable code.
β Proper separation of concerns (e.g., frontend, backend, data handling, real-time
updates).
- Real-Time Functionality (25 points):
β Successful implementation of real-time reporting using WebSockets.
β Updates are accurate and reflect live data changes.
- AI Integration (20 points):
β Correct integration with ChatGPT/Gemini to generate actionable recommendations.
β Appropriate and logical prompts for AI.
β Effective use of AI-generated insights in the frontend.
- External API Integration (15 points):
β Successful integration with a weather API or similar service.
β Accurate and relevant use of external data in recommendations.
- Documentation and Testing (10 points):
β Clear documentation (README) explaining:
β Which parts were assisted by AI.
β Manual implementation details.
β How to run and test the project.
β At least one test case for APIs or real-time functionality.
AI-Assisted vs. Manual Implementation:
Backend (30% AI, 70% Manual):
β AI-Assisted:
β Generate API prompts for ChatGPT/Gemini to suggest product promotions.
β Structure API endpoints and generate boilerplate code.
β Manual:
β Write all database logic, WebSocket publishing, and external API integration.
β Ensure real-time updates and error handling are implemented.
Project Timeline:
β Duration: 2 days.
β Day 1: Set up the backend structure, create basic APIs, and implement
WebSocket functionality.
β Day 2: Build the frontend, integrate AI and external APIs, and test the
real-time updates.
Key Notes for Candidates:
- Clearly document which parts of the code were generated or assisted by AI.
- Avoid using prebuilt libraries for tasks that can be implemented manually (e.g.,
charting, data fetching).
- Focus on clean, modular, and scalable code.
- Prioritize real-time functionality and smooth integration between frontend and
backend.