An Express.js server application that integrates with external ICE service and Neon SQL database to discover and vet hot-selling 3D printable products.
DiscoveryFunnel helps identify viable 3D printing products by:
- Fetching hot-selling product trends using the ICE AI service
- Retrieving scraped product data from a Neon SQL database
- Vetting product viability through AI analysis
- Cross-referencing results to recommend the best 3D printable products
- API Key Authentication: Secure all endpoints with API key validation
- ICE Service Integration: AI-powered market trend analysis and product vetting
- Neon Database Integration: Efficient product data retrieval
- Health Monitoring: Service status and connection health checks
- Comprehensive Error Handling: Robust error responses and logging
- Testing Suite: Unit tests for all major components
- Clone the repository:
git clone https://github.com/QBlockTech/DiscoveryFunnel.git
cd DiscoveryFunnel- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env file with your actual values- Start the server:
# Development mode
npm run dev
# Production mode
npm startCreate a .env file based on .env.example:
# Server Configuration
PORT=3000
NODE_ENV=development
# API Authentication
API_KEY=your-secure-api-key-here
# ICE Service Configuration
ICE_API_KEY=your-ice-service-api-key
ICE_BASE_URL=https://api.ice-service.com
# Neon Database Configuration
NEON_DATABASE_URL=postgresql://username:password@hostname:port/databaseAI prompts used by the ICE service are configured in config/prompts.js. This file contains:
- hotSellingProducts: Prompt for identifying trending 3D printable product categories
- productViability: Template prompt for analyzing product market viability (uses
{productList}placeholder)
You can customize these prompts to adjust the AI analysis behavior:
// config/prompts.js
const prompts = {
hotSellingProducts: `Your custom prompt for trend analysis...`,
productViability: `Your custom prompt for viability analysis...
{productList}
Your analysis instructions...`
};Check server health status (no authentication required).
Response:
{
"status": "healthy",
"timestamp": "2024-01-01T00:00:00.000Z",
"uptime": 123.456,
"version": "1.0.0"
}All discovery endpoints require authentication via x-api-key header.
Trigger the complete product discovery workflow.
Headers:
x-api-key: your-api-key
Content-Type: application/json
Response:
{
"success": true,
"timestamp": "2024-01-01T00:00:00.000Z",
"summary": {
"hotCategories": 10,
"totalProducts": 150,
"vettedProducts": 150,
"finalRecommendations": 20
},
"hotSellingCategories": [
{
"category": "3D Printing Tools",
"demand_score": 8,
"reason": "High demand for custom tools"
}
],
"recommendations": [
{
"id": 1,
"name": "Custom Phone Case",
"description": "Personalized phone protection",
"price": 15.99,
"category": "accessories",
"ranking": 1,
"compositeScore": 8.5,
"viability": {
"demand_score": 9,
"feasibility_score": 8,
"competition_score": 6,
"profit_score": 8,
"overall_score": 8,
"recommendation": "Highly recommended"
}
}
]
}Get products from a specific category.
Headers:
x-api-key: your-api-key
Parameters:
category(string): Product category to filter by
Response:
{
"success": true,
"category": "accessories",
"count": 25,
"products": [
{
"id": 1,
"name": "Custom Phone Case",
"description": "Personalized phone protection",
"price": 15.99,
"category": "accessories",
"source_url": "https://example.com/product/1",
"scraped_at": "2024-01-01T00:00:00.000Z"
}
]
}Check the status of all connected services.
Headers:
x-api-key: your-api-key
Response:
{
"success": true,
"services": {
"database": true,
"ice": true
},
"timestamp": "2024-01-01T00:00:00.000Z"
}The application expects a products table in your Neon database with the following structure:
CREATE TABLE products (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
price DECIMAL(10,2),
category VARCHAR(100),
source_url TEXT,
scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);Run the test suite:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage# Start development server with auto-reload
npm run dev
# Run linting
npm run lint
# Fix linting issues
npm run lint:fixThe API returns consistent error responses:
{
"error": "Error Type",
"message": "Detailed error message",
"timestamp": "2024-01-01T00:00:00.000Z"
}Common HTTP status codes:
200: Success401: Authentication required403: Invalid API key404: Resource not found500: Internal server error503: Service unavailable
All API endpoints (except /health) require authentication using an API key. Include the API key in one of the following headers:
x-api-key: your-api-keyAuthorization: your-api-keyAuthorization: Bearer your-api-key
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License.