How ahmadkamrans/ai-classifier-with-embedding-based-semantic-search works
Project type and purpose
– This is a small full-stack MVP that exposes REST endpoints via Express.js to classify patient symptoms using the OpenAI GPT-4o API, stores the results in a Supabase (PostgreSQL) database, and provides both a static front-end (index.html + index.js) for manual testing and integration points for analytics (Metabase).
File structure
– Top level
• .env – environment variables for OpenAI and Supabase
• index.html + index.js – static client page that calls your REST API
• schema.sql – database schema for symptom_reports table
• pictures/ – screenshots for documentation
• README.md – project overview and instructions
– No separate “frontend” or “backend” folders, but their responsibilities are clearly separated by file purpose.
README for additional insights
– Backend stack: Node.js + Express.js
– Database: Supabase (hosted PostgreSQL)
– AI service: OpenAI GPT-4o API
– Analytics: Metabase connected to Supabase
– Testing: Postman for API endpoints
– SQL schema provided for reproducibility
a. Main components
• User (Browser/Postman)
• Static Frontend (index.html + index.js)
• REST API Server (Express.js)
• OpenAI GPT-4o Service (external API)
• Supabase PostgreSQL Database
• Metabase Analytics Dashboard (external BI tool)
b. Relationships & interactions
1. User → Frontend: enters or posts symptom data
2. Frontend → Express API: HTTP POST /submit (symptom_description)
3. Express API → OpenAI GPT-4o: classification request
4. OpenAI → Express API: returns triage_level label
5. Express API → Supabase DB: INSERT symptom_report record
6. User/Postman → Express API: GET /reports (retrieve stored records)
7. Metabase → Supabase DB: polling/queries for dashboards
c. Architectural patterns & design principles
– Layered architecture: Presentation (static HTML/JS), API layer (Express), Data layer (PostgreSQL)
– External service integration for AI classification
– Stateless REST endpoints (no in-memory session state)
– Single-page static client for quick testing/demo (no SPA framework)
d. Key technologies & libraries
– Node.js & Express.js for REST server
– openai npm package for GPT-4o integration
– @supabase/supabase-js or PostgreSQL client for DB operations
– Metabase for analytics (reads directly from Supabase)
– Postman for manual endpoint testing
Detail without overcomplicating
– Optionally show environment variable store (.env) feeding both the API and the database client
– Reflect the SQL schema as part of the DB component or note the table name “symptom_reports”