Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sector Classifier

API-first Rails app that classifies free-text questions into industries per project/tenant. Includes:

  • Projects with rate limits and API keys.
  • Shared industry catalog and per-project associations.
  • Classification endpoint with logging.
  • Admin JSON endpoints secured with optional HTTP basic auth (set ADMIN_USER / ADMIN_PASSWORD).

Setup

git clone <repo>
cd sector-classifier
DISABLE_SPRING=1 BUNDLE_USER_HOME=./.bundle bundle install
DISABLE_SPRING=1 BUNDLE_USER_HOME=./.bundle rails db:create db:migrate db:seed
DISABLE_SPRING=1 BUNDLE_USER_HOME=./.bundle rails server

Postgres config is in config/database.yml (env vars: PGUSER, PGPASSWORD, PGHOST, PGPORT).

API

  • Health: GET /api/v1/health
  • Classify: POST /api/v1/classify with header X-Api-Key and body { "text": "I need a hotel booking system" }
    • Returns matched industry { id, name, code, description, score }
    • Logs every call in classification_requests.

Admin JSON (optional HTTP Basic with ADMIN_USER/ADMIN_PASSWORD)

  • Projects: GET/POST/PATCH/DELETE /admin/projects
  • API keys: GET/POST/PATCH/DELETE /admin/projects/:project_id/api_keys
  • Industries catalog: GET/POST/PATCH/DELETE /admin/industries
  • Project industries: GET/POST/DELETE /admin/projects/:project_id/industries

Seed data

  • Project: Leadhub (status: active)
  • Industries: Construction, Healthcare, IT, Hospitality, Real Estate
  • Default API key attached to Leadhub (token printed in DB, generated automatically)

Bulk import & embeddings

  • Fast import (CSV or JSON) to a project: DISABLE_SPRING=1 BUNDLE_USER_HOME=./.bundle rails import:industries[PROJECT_ID,/absolute/path/to/file.csv]
    • The file must have name,code,description.
    • Imports also link the industries to the given project; names must be unique per project (case-insensitive).
  • Rebuild embeddings (all or per project): DISABLE_SPRING=1 BUNDLE_USER_HOME=./.bundle rails embeddings:rebuild[PROJECT_ID]

Import file formats (share with clients)

  • CSV headers: name,code,description,external_id,search_terms,category
    • external_id recommended if you want to round-trip the source ID.
    • search_terms can be JSON array or plain text; stored as array.
    • Example:
      name,code,description,external_id,search_terms,category
      "Hotel Services","HOTEL","Hotel and accommodation","49213","[""hotel"",""lodging""]","Hospitality"
      "AI Consulting","AI","AI & data projects","AI-001","[""machine learning"",""ml""]","Technology"
      
  • JSON array; camelCase accepted:
    [
      {
        "name": "Hotel Services",
        "code": "HOTEL",
        "description": "Hotel and accommodation",
        "industryId": "49213",
        "searchTerms": ["hotel", "lodging"],
        "category": "Hospitality"
      },
      {
        "name": "AI Consulting",
        "code": "AI",
        "description": "AI & data projects",
        "industryId": "AI-001",
        "searchTerms": ["machine learning", "ml"],
        "category": "Technology"
      }
    ]

API response shape

  • POST /api/v1/classify and POST /api/v1/semantic_search return industry fields: id, name, code, description, external_id, category, search_terms (plus score).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages