Development Backend Server
Relevant source files
The following files were used as context for generating this wiki page:
The Development Backend Server serves as a specialized utility for the MarketSage (Market Oracle) platform, providing lightweight API services focused on initial analysis and integration testing. Its primary role is to support "AI-Powered Scam Detection" and "Seller Profile" retrieval during the development phase of the financial analytics and investment insights platform.
The server operates within a tech stack designed for financial analytics, utilizing Node.js and Express to handle asynchronous requests from the frontend application. It bridges the gap between raw marketplace data (e.g., from Temu, AliExpress) and the intelligent processing engines like the SmartShoppingAssistant and UnifiedBrowserManager.
Sources: WHATAMI.txt:1-20, development/frontend/index.html:1-30, development/backend/routes/scamDetection.js:1-10
Core API Architecture
The backend is structured around modular Express routes. In its development state, it provides a centralized entry point for scam probability calculations and metadata retrieval.
Scam Detection Endpoint
The /scam-detection route processes textual input from product listings to calculate a risk score based on predefined heuristic markers.
mermaid
sequenceDiagram
participant FE as Frontend UI
participant BE as Backend Server
participant UBM as UnifiedBrowserManager
participant AI as SmartShoppingAssistant
FE->>BE: POST /scam-detection (text)
BE->>UBM: Request context validation
UBM->>AI: Process NLP Query
AI-->>UBM: Detailed Risk Assessment
UBM-->>BE: Unified Browse Result
BE-->>FE: Final Scam Probability
The `UnifiedBrowserManager` applies "Scam Detection Filters" based on user preferences (e.g., hide, warn, or highlight) which the backend must respect when serving profile or detection data.
Sources: [src/common/models/unifiedClient/UnifiedBrowserManager.ts:60-110](https://github.com/VpkDevs/MarketSage/blob/HEAD/src/common/models/unifiedClient/UnifiedBrowserManager.ts#L60-L110)
### Natural Language Processing (NLP)
The `SmartShoppingAssistant` provides the underlying logic for advanced inquiries that the backend serves, including:
- **Safety Checks**: Validating if a seller or product is legitimate/authentic.
- **Price Inquiries**: Analyzing market trends and budget adherence.
- **Shipping Inquiries**: Determining delivery urgency and timelines.
Sources: [src/core/ai/SmartShoppingAssistant.ts:100-150](https://github.com/VpkDevs/MarketSage/blob/HEAD/src/core/ai/SmartShoppingAssistant.ts#L100-L150)
## Risk and Heuristic Markers
The backend utilizes a list of high-risk keywords to identify potential fraudulent activity in listings.
| Keyword | Category | Significance |
| :--- | :--- | :--- |
| `scam`, `fraud`, `fake` | Direct | Immediate identification of counterfeit or deceptive items. |
| `offer`, `money`, `prize` | Financial | Common bait-and-switch or phishing indicators. |
| `guarantee`, `win` | Psychological | False promises used to bypass user skepticism. |
| `urgent`, `risk` | Social | High-pressure tactics to force quick decisions. |
Sources: [development/backend/routes/scamDetection.js:4-15](https://github.com/VpkDevs/MarketSage/blob/HEAD/development/backend/routes/scamDetection.js#L4-L15)
## System Dependencies and Configuration
The server environment is configured via the root `package.json`, which defines the necessary modules for both the backend and its related analysis engines.
- **Axios**: Used for inter-service communication and fetching marketplace data.
- **Crypto-js**: Ensures secure ID generation and data integrity during analysis.
- **Tensorflow/tfjs**: Provides the framework for the `SmartShoppingAssistant` to perform more complex risk scoring beyond keyword matching.
Sources: [package.json:25-40](https://github.com/VpkDevs/MarketSage/blob/HEAD/package.json#L25-L40), [src/core/ai/SmartShoppingAssistant.ts:1-20](https://github.com/VpkDevs/MarketSage/blob/HEAD/src/core/ai/SmartShoppingAssistant.ts#L1-L20)
## Conclusion
The Development Backend Server provides the essential API infrastructure for MarketSage's real-time security features. By implementing keyword-based scam detection and preparing for integration with the platform's unified browser and AI assistant, it facilitates the project's goal of providing intelligent investment insights and safe market analysis.
Sources: [WHATAMI.txt:5-10](https://github.com/VpkDevs/MarketSage/blob/HEAD/WHATAMI.txt#L5-L10), [development/backend/routes/scamDetection.js:42-45](https://github.com/VpkDevs/MarketSage/blob/HEAD/development/backend/routes/scamDetection.js#L42-L45)