GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - CakeDC/cakephp-pgvector-example

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
.ddev
.ddev
 
 
.github
.github
 
 
bin
bin
 
 
config
config
 
 
docs/superpowers
docs/superpowers
 
 
plugins
plugins
 
 
resources
resources
 
 
src
src
 
 
templates
templates
 
 
tests
tests
 
 
webroot
webroot
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.htaccess
.htaccess
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
composer.lock
composer.lock
 
 
index.php
index.php
 
 
phpcs.xml
phpcs.xml
 
 
phpstan.neon
phpstan.neon
 
 
phpunit.xml.dist
phpunit.xml.dist
 
 
psalm.xml
psalm.xml
 
 

Repository files navigation

CakePHP + pgvector: semantic search demo

A small CakePHP 5 application that catalogs real restaurants (pulled from OpenStreetMap) and lets users search them in plain English, e.g. "outdoor seating and vegetarian options", using pgvector for the similarity search.

See this article on the CakeDC website for the full walkthrough: the Postgres schema, the custom Cake\Database\Type that maps a vector column to a PHP float[], the toy embedding generator, and the cosine-distance finder that powers the search.

Requirements

  • DDEV (bundles PHP 8.5 and PostgreSQL 18 with pgvector pre-installed via .ddev/db-build/Dockerfile)

Running it

ddev start
ddev composer install
ddev cake migrations migrate
ddev cake import_restaurants --city=madrid   # or --city=brooklyn

Then visit /restaurants/search?q=outdoor+seating+wine (or whatever your imported city's restaurants mention) on the DDEV-provided URL.

Restaurant data

The catalog is seeded from real, free, open data pulled from OpenStreetMap via its Overpass API, no API key required. Running bin/cake import_restaurants --city=<city> fetches restaurant nodes for that city's bounding box, builds a description from their OpenStreetMap tags, embeds it, and upserts the result by OpenStreetMap's node id. See src/Vector/OverpassClient.php, src/Vector/DescriptionBuilder.php, and src/Command/ImportRestaurantsCommand.php.

The embeddings

src/Vector/EmbeddingGenerator.php builds vectors with a hashed bag-of-words scheme (no external API, no API key) so the demo works out of the box. It's a toy: good enough to show restaurants that share vocabulary landing close together, not a substitute for a trained embedding model. The article on the CakeDC website explains the trade-off and how to swap in a real embedding API.

Configuration

Read and edit the environment specific config/app_local.php and set up the 'Datasources' and any other configuration relevant to your setup. Other environment agnostic settings can be changed in config/app.php.

About

No description, website, or topics provided.

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.