How zeuidon/negosy works
Project Type and Purpose
• NegoSy is a full-stack AI-powered e-commerce chatbot system for automated price negotiation.
• Frontend: static HTML/CSS/JS (“nino” theme) plus fine-tune data.
• Backend: Python service (app.py) implementing negotiation logic, sentiment analysis, and LLM integration.
File Structure Analysis
• NegoSy/frontend
• fine_tune_data.json – dataset for training or prompting the LLM.
• nino/ – static web assets (index.html, CSS/JS).
• NegoSy/negotiation
• app.py – main Flask (or similar) application exposing HTTP endpoints.
• messages.py – modules for message parsing, sentiment analysis or business-rule processing.
• README.md – project overview, methodology (query acquisition, dialogue rollout, sentiment analyzer, LLM).
Key Components
a. User Interface (Client Browser)
• Loads index.html, CSS, JS; captures user input.
b. API Layer (Backend Service)
• app.py running Flask/FastAPI.
• Exposes REST/WebSocket endpoints to receive chat messages.
c. Message Processor
• messages.py: pre-processing, tokenization, sentiment analysis.
d. Fine-Tune Data Store
• fine_tune_data.json (could be represented as local file or lightweight database).
e. LLM Integration
• External API call to an LLM provider (OpenAI, local model).
f. Response Generator
• Combines LLM output with business rules, constructs reply.
g. (Optional) Persistence Layer
• If chat logs or negotiation states are stored; even if not present, show a “Chat History” store placeholder.
Component Relationships and Data Flow
1. User types a message in the browser UI →
2. JS triggers HTTP POST/WebSocket to Backend API (app.py) →
3. app.py forwards raw message to Message Processor (messages.py) →
4. Message Processor analyzes sentiment & context; selects tag-words →
5. Processor constructs a prompt using fine_tune_data.json →
6. Prompt sent to External LLM API →
7. LLM returns a generated response →
8. Response post-processing (business logic) →
9. app.py returns final chat reply to Browser →
10. Browser JS displays it to the user.
Architectural Patterns & Design Principles
• Layered architecture: separation of concerns (UI, API, processing, external services).
• Single-responsibility: messages.py handles only NLP-related logic.
• Minimal state: if persisting negotiation states, isolate state management in its own module/component.
Technologies and Frameworks
• Frontend: HTML5, CSS (styles.css), vanilla JS (scripts.js).
• Backend: Python (Flask or FastAPI in app.py).
• NLP: custom sentiment analyzer in messages.py.
• LLM: external API (e.g., OpenAI GPT) accessed via HTTP.
• Data store: JSON file for fine-tune data (can later migrate to a real DB).