Add optional AI-powered lookup for cars not in the local database

When a search has no local match, a "Mit KI suchen" button now calls a
PHP backend (api/lookup.php) that asks the Claude API for plausible
cargo-bay dimensions. The API key stays server-side (config.php, gitignored,
see config.example.php) and is never exposed to the browser. The existing
category-based estimate picker remains as a free fallback if the AI call
fails or isn't configured.
This commit is contained in:
Maaxxs 2026-08-31 09:50:53 +02:00
parent a6f6adcaba
commit 0446dbf7d0
8 changed files with 1316 additions and 4 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
api/config.php
api/vendor/

12
api/composer.json Normal file
View file

@ -0,0 +1,12 @@
{
"require": {
"anthropic-ai/sdk": "^0.44.0",
"symfony/http-client": "^7.4",
"nyholm/psr7": "^1.8"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}

968
api/composer.lock generated Normal file
View file

@ -0,0 +1,968 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "65317a26fbcfb6d557de08fb8b473982",
"packages": [
{
"name": "anthropic-ai/sdk",
"version": "v0.44.0",
"source": {
"type": "git",
"url": "https://github.com/anthropics/anthropic-sdk-php.git",
"reference": "f63c00d80f180e1c3acd6cf8835df5b1baa625a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/anthropics/anthropic-sdk-php/zipball/f63c00d80f180e1c3acd6cf8835df5b1baa625a1",
"reference": "f63c00d80f180e1c3acd6cf8835df5b1baa625a1",
"shasum": ""
},
"require": {
"php": "^8.1",
"php-http/discovery": "^1",
"psr/http-client": "^1",
"psr/http-client-implementation": "^1",
"psr/http-factory-implementation": "^1",
"psr/http-message": "^1|^2",
"standard-webhooks/standard-webhooks": "^1"
},
"require-dev": {
"aws/aws-sdk-php": "^3.368",
"friendsofphp/php-cs-fixer": "^3",
"google/auth": "^1.49",
"guzzlehttp/guzzle": "^7",
"mcp/sdk": "^0.7.1",
"nyholm/psr7": "^1",
"pestphp/pest": "^3",
"php-http/mock-client": "^1",
"phpstan/extension-installer": "^1",
"phpstan/phpstan": "2.2.1",
"phpstan/phpstan-phpunit": "^2",
"phpunit/phpunit": "^11",
"symfony/http-client": "^7"
},
"suggest": {
"aws/aws-sdk-php": "Allows using the AWS Bedrock, AWS gateway, and Bedrock Mantle SDKs",
"google/auth": "Allows using the Google Vertex and Google Cloud gateway SDKs",
"mcp/sdk": "Required to use the BetaMcp helpers for integrating MCP servers with the Anthropic SDK"
},
"type": "library",
"autoload": {
"files": [
"src/Version.php"
],
"psr-4": {
"Anthropic\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Anthropic PHP SDK",
"support": {
"issues": "https://github.com/anthropics/anthropic-sdk-php/issues",
"source": "https://github.com/anthropics/anthropic-sdk-php/tree/v0.44.0"
},
"time": "2026-08-26T17:59:57+00:00"
},
{
"name": "nyholm/psr7",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/Nyholm/psr7.git",
"reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/a71f2b11690f4b24d099d6b16690a90ae14fc6f3",
"reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0"
},
"provide": {
"php-http/message-factory-implementation": "1.0",
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"http-interop/http-factory-tests": "^0.9",
"php-http/message-factory": "^1.0",
"php-http/psr7-integration-tests": "^1.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.4",
"symfony/error-handler": "^4.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8-dev"
}
},
"autoload": {
"psr-4": {
"Nyholm\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com"
},
{
"name": "Martijn van der Ven",
"email": "martijn@vanderven.se"
}
],
"description": "A fast PHP7 implementation of PSR-7",
"homepage": "https://tnyholm.se",
"keywords": [
"psr-17",
"psr-7"
],
"support": {
"issues": "https://github.com/Nyholm/psr7/issues",
"source": "https://github.com/Nyholm/psr7/tree/1.8.2"
},
"funding": [
{
"url": "https://github.com/Zegnat",
"type": "github"
},
{
"url": "https://github.com/nyholm",
"type": "github"
}
],
"time": "2024-09-09T07:06:30+00:00"
},
{
"name": "php-http/discovery",
"version": "1.20.0",
"source": {
"type": "git",
"url": "https://github.com/php-http/discovery.git",
"reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d",
"reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0|^2.0",
"php": "^7.1 || ^8.0"
},
"conflict": {
"nyholm/psr7": "<1.0",
"zendframework/zend-diactoros": "*"
},
"provide": {
"php-http/async-client-implementation": "*",
"php-http/client-implementation": "*",
"psr/http-client-implementation": "*",
"psr/http-factory-implementation": "*",
"psr/http-message-implementation": "*"
},
"require-dev": {
"composer/composer": "^1.0.2|^2.0",
"graham-campbell/phpspec-skip-example-extension": "^5.0",
"php-http/httplug": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0",
"phpspec/phpspec": "^5.1 || ^6.1 || ^7.3",
"sebastian/comparator": "^3.0.5 || ^4.0.8",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0.1"
},
"type": "composer-plugin",
"extra": {
"class": "Http\\Discovery\\Composer\\Plugin",
"plugin-optional": true
},
"autoload": {
"psr-4": {
"Http\\Discovery\\": "src/"
},
"exclude-from-classmap": [
"src/Composer/Plugin.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations",
"homepage": "http://php-http.org",
"keywords": [
"adapter",
"client",
"discovery",
"factory",
"http",
"message",
"psr17",
"psr7"
],
"support": {
"issues": "https://github.com/php-http/discovery/issues",
"source": "https://github.com/php-http/discovery/tree/1.20.0"
},
"time": "2024-10-02T11:20:13+00:00"
},
{
"name": "psr/container",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
"shasum": ""
},
"require": {
"php": ">=7.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
"homepage": "https://github.com/php-fig/container",
"keywords": [
"PSR-11",
"container",
"container-interface",
"container-interop",
"psr"
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/2.0.2"
},
"time": "2021-11-05T16:47:00+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client"
},
"time": "2023-09-23T14:17:50+00:00"
},
{
"name": "psr/http-factory",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory"
},
"time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/log",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"shasum": ""
},
"require": {
"php": ">=8.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.2"
},
"time": "2024-09-11T13:17:53+00:00"
},
{
"name": "standard-webhooks/standard-webhooks",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/standard-webhooks/standard-webhooks.git",
"reference": "a1773d7ffc577d730e2bf4d4bd740a82a42aa904"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/standard-webhooks/standard-webhooks/zipball/a1773d7ffc577d730e2bf4d4bd740a82a42aa904",
"reference": "a1773d7ffc577d730e2bf4d4bd740a82a42aa904",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0 || ^10.0"
},
"type": "library",
"autoload": {
"psr-4": {
"StandardWebhooks\\": "libraries/php/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Standard Webhooks - Open source tools and guidelines for sending webhooks easily, securely, and reliably",
"homepage": "https://www.standardwebhooks.com",
"keywords": [
"hmac",
"signature",
"standard-webhooks",
"verification",
"webhooks"
],
"support": {
"issues": "https://github.com/standard-webhooks/standard-webhooks/issues",
"source": "https://github.com/standard-webhooks/standard-webhooks/tree/v1.0.2"
},
"time": "2026-02-18T19:02:27+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.7.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/f3202fa1b5097b0af062dc978b32ecf63404e31d",
"reference": "f3202fa1b5097b0af062dc978b32ecf63404e31d",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.7.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-06-05T06:23:12+00:00"
},
{
"name": "symfony/http-client",
"version": "v7.4.18",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client.git",
"reference": "68d81f78d127984ff2e741f0e0d9cb1078f8f3ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client/zipball/68d81f78d127984ff2e741f0e0d9cb1078f8f3ea",
"reference": "68d81f78d127984ff2e741f0e0d9cb1078f8f3ea",
"shasum": ""
},
"require": {
"php": ">=8.2",
"psr/log": "^1|^2|^3",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/http-client-contracts": "~3.4.4|^3.5.2",
"symfony/polyfill-php83": "^1.29",
"symfony/service-contracts": "^2.5|^3"
},
"conflict": {
"amphp/amp": "<2.5",
"amphp/socket": "<1.1",
"php-http/discovery": "<1.15",
"symfony/http-foundation": "<6.4"
},
"provide": {
"php-http/async-client-implementation": "*",
"php-http/client-implementation": "*",
"psr/http-client-implementation": "1.0",
"symfony/http-client-implementation": "3.0"
},
"require-dev": {
"amphp/http-client": "^4.2.1|^5.0",
"amphp/http-tunnel": "^1.0|^2.0",
"guzzlehttp/promises": "^1.4|^2.0",
"nyholm/psr7": "^1.0",
"php-http/httplug": "^1.0|^2.0",
"psr/http-client": "^1.0",
"symfony/amphp-http-client-meta": "^1.0|^2.0",
"symfony/cache": "^6.4|^7.0|^8.0",
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
"symfony/http-kernel": "^6.4|^7.0|^8.0",
"symfony/messenger": "^6.4|^7.0|^8.0",
"symfony/process": "^6.4|^7.0|^8.0",
"symfony/rate-limiter": "^6.4|^7.0|^8.0",
"symfony/stopwatch": "^6.4|^7.0|^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\HttpClient\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides powerful methods to fetch HTTP resources synchronously or asynchronously",
"homepage": "https://symfony.com",
"keywords": [
"http"
],
"support": {
"source": "https://github.com/symfony/http-client/tree/v7.4.18"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-08-30T13:49:59+00:00"
},
{
"name": "symfony/http-client-contracts",
"version": "v3.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-client-contracts.git",
"reference": "35be0019e2c2c9fba80f9dc033290a5240f7b44f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-client-contracts/zipball/35be0019e2c2c9fba80f9dc033290a5240f7b44f",
"reference": "35be0019e2c2c9fba80f9dc033290a5240f7b44f",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\HttpClient\\": ""
},
"exclude-from-classmap": [
"/Test/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to HTTP clients",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/http-client-contracts/tree/v3.7.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-08-04T08:41:16+00:00"
},
{
"name": "symfony/polyfill-php83",
"version": "v1.41.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php83.git",
"reference": "5ea99087fb99c273a9b9236ed4c31e78b16103c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/5ea99087fb99c273a9b9236ed4c31e78b16103c6",
"reference": "5ea99087fb99c273a9b9236ed4c31e78b16103c6",
"shasum": ""
},
"require": {
"php": ">=7.2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php83\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php83/tree/v1.41.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-07-01T12:47:55+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.7.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/15e6a07ec2a2c75ceb1b21dd98105ee8456d2257",
"reference": "15e6a07ec2a2c75ceb1b21dd98105ee8456d2257",
"shasum": ""
},
"require": {
"php": ">=8.1",
"psr/container": "^1.1|^2.0",
"symfony/deprecation-contracts": "^2.5|^3"
},
"conflict": {
"ext-psr": "<1.1|>=2"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.7-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\Service\\": ""
},
"exclude-from-classmap": [
"/Test/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Generic abstractions related to writing services",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.7.3"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://github.com/nicolas-grekas",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2026-07-27T15:39:01+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {},
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

5
api/config.example.php Normal file
View file

@ -0,0 +1,5 @@
<?php
// Diese Datei zu config.php kopieren und den echten API-Key eintragen.
// config.php ist per .gitignore ausgeschlossen und wird nie ins Repo übernommen.
$ANTHROPIC_API_KEY = 'sk-ant-...';

103
api/lookup.php Normal file
View file

@ -0,0 +1,103 @@
<?php
// Serverseitiger Endpunkt: nimmt eine frei getippte Automarke/Modell entgegen und lässt
// Claude plausible Kofferraum-Kenndaten dafür schätzen. Der API-Key bleibt ausschließlich
// auf dem Server (aus config.php oder der Umgebungsvariable ANTHROPIC_API_KEY) und wird
// nie an den Browser ausgeliefert.
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['error' => 'Nur POST erlaubt.']);
exit;
}
$apiKey = getenv('ANTHROPIC_API_KEY') ?: null;
$configFile = __DIR__ . '/config.php';
if (!$apiKey && file_exists($configFile)) {
require $configFile;
$apiKey = $ANTHROPIC_API_KEY ?? null;
}
if (!$apiKey) {
http_response_code(500);
echo json_encode([
'error' => 'Kein Anthropic API-Key konfiguriert. api/config.example.php nach api/config.php kopieren und Key eintragen.',
]);
exit;
}
$body = json_decode(file_get_contents('php://input'), true);
$query = trim((string)($body['query'] ?? ''));
if ($query === '' || mb_strlen($query) > 80) {
http_response_code(400);
echo json_encode(['error' => 'Ungültige Anfrage.']);
exit;
}
require __DIR__ . '/vendor/autoload.php';
use Anthropic\Client;
$client = new Client(apiKey: $apiKey);
$systemPrompt = <<<SYS
Du lieferst Kenndaten für ein 3D-Vorschau-Tool eines Auto-HiFi-Shops, das aus Marke/Modell
eine stark vereinfachte, parametrische Kofferraum-Näherung generiert.
Antworte AUSSCHLIESSLICH mit einem einzelnen JSON-Objekt, keine Erklärung, kein Markdown, keine Code-Fences.
Wenn du das Fahrzeug erkennst, exakt dieses Format:
{"found":true,"brand":"...","model":"...","bodyType":"Kombi|Kompaktklasse|Limousine|Kompakt-SUV|Mittelklasse-SUV|Van|Kleinwagen|Sportwagen|...","cargoLiters":000,"cargoLitersMax":000,"length_mm":000,"widthFloor_mm":000,"widthShoulder_mm":000,"height_mm":000,"sillHeight_mm":000,"underFloorDepth_mm":000}
Wenn du das Fahrzeug nicht plausibel zuordnen kannst:
{"found":false}
Regeln:
- length_mm/widthFloor_mm/widthShoulder_mm/height_mm sind die INNENMASSE des Laderaums (nicht die Außenmaße des Autos), realistisch in der Größenordnung 400-1300mm.
- widthShoulder_mm ist die Breite oben (Schulterhöhe) und immer >= widthFloor_mm (Breite unten zwischen den Radkästen).
- cargoLitersMax ist das Volumen bei umgeklappten Rücksitzen; falls nicht sinnvoll (z. B. 2-Sitzer), null.
- underFloorDepth_mm ist die Tiefe der Reserverad-/Staumulde unter dem Ladeboden; falls es die nicht gibt, null.
- Werte sind grobe, plausible Schätzungen basierend auf deinem Wissen über das Fahrzeug, keine exakten Herstellerangaben.
- Wenn die Anfrage kein erkennbares Auto ist (z. B. Unsinn oder ein anderes Objekt), antworte {"found":false}.
SYS;
try {
$message = $client->messages->create(
model: 'claude-opus-5',
maxTokens: 1024,
outputConfig: ['effort' => 'low'],
system: $systemPrompt,
messages: [
['role' => 'user', 'content' => $query],
],
);
} catch (\Throwable $e) {
http_response_code(502);
echo json_encode(['error' => 'KI-Anfrage fehlgeschlagen: ' . $e->getMessage()]);
exit;
}
$text = '';
foreach ($message->content as $block) {
if ($block->type === 'text') {
$text .= $block->text;
}
}
if (!preg_match('/\{.*\}/s', $text, $m)) {
http_response_code(502);
echo json_encode(['error' => 'Antwort konnte nicht gelesen werden.']);
exit;
}
$data = json_decode($m[0], true);
if (!is_array($data)) {
http_response_code(502);
echo json_encode(['error' => 'Antwort konnte nicht gelesen werden.']);
exit;
}
echo json_encode($data);

160
app.js
View file

@ -22,6 +22,10 @@ const lidStateLabel = document.getElementById("lidStateLabel");
const toggleFloor = document.getElementById("toggleFloor"); const toggleFloor = document.getElementById("toggleFloor");
const floorStateLabel = document.getElementById("floorStateLabel"); const floorStateLabel = document.getElementById("floorStateLabel");
const floorToggleRow = document.getElementById("floorToggleRow"); const floorToggleRow = document.getElementById("floorToggleRow");
const estimateBox = document.getElementById("estimateBox");
const estimateChips = document.getElementById("estimateChips");
const estimateAIBtn = document.getElementById("estimateAIBtn");
const estimateAIStatus = document.getElementById("estimateAIStatus");
const subPresetsBox = document.getElementById("subPresets"); const subPresetsBox = document.getElementById("subPresets");
const subW = document.getElementById("subW"); const subW = document.getElementById("subW");
@ -52,6 +56,19 @@ const FLOOR_UP_ANGLE = -0.8;
const BODY_PAINT_COLOR = 0x3c4046; const BODY_PAINT_COLOR = 0x3c4046;
// Näherungswerte je Fahrzeugklasse (Mittelwerte aus der Beispieldatenbank), für Marken/Modelle,
// die nicht in data/cars.json hinterlegt sind. So lässt sich trotzdem jede beliebige Eingabe
// mit einer plausiblen 3D-Näherung darstellen.
const GENERIC_CATEGORIES = [
{ id: "kleinwagen", label: "Kleinwagen", bodyType: "Kleinwagen (Schätzung)", cargoLiters: 300, cargoLitersMax: 950, length_mm: 700, widthFloor_mm: 925, widthShoulder_mm: 1190, height_mm: 490, sillHeight_mm: 690, underFloorDepth_mm: 100 },
{ id: "kompakt", label: "Kompaktklasse", bodyType: "Kompaktklasse (Schätzung)", cargoLiters: 380, cargoLitersMax: 1230, length_mm: 750, widthFloor_mm: 1000, widthShoulder_mm: 1300, height_mm: 500, sillHeight_mm: 700, underFloorDepth_mm: 130 },
{ id: "kombi", label: "Kombi", bodyType: "Kombi (Schätzung)", cargoLiters: 590, cargoLitersMax: 1650, length_mm: 1040, widthFloor_mm: 1040, widthShoulder_mm: 1330, height_mm: 565, sillHeight_mm: 690, underFloorDepth_mm: 170 },
{ id: "limousine", label: "Limousine", bodyType: "Limousine (Schätzung)", cargoLiters: 480, cargoLitersMax: null, length_mm: 850, widthFloor_mm: 1000, widthShoulder_mm: 1320, height_mm: 550, sillHeight_mm: 770, underFloorDepth_mm: 150 },
{ id: "suv-kompakt", label: "Kompakt-SUV", bodyType: "Kompakt-SUV (Schätzung)", cargoLiters: 590, cargoLitersMax: 1700, length_mm: 915, widthFloor_mm: 1040, widthShoulder_mm: 1350, height_mm: 748, sillHeight_mm: 745, underFloorDepth_mm: 190 },
{ id: "suv-mittel", label: "Mittelklasse-SUV", bodyType: "Mittelklasse-SUV (Schätzung)", cargoLiters: 560, cargoLitersMax: 1620, length_mm: 940, widthFloor_mm: 1040, widthShoulder_mm: 1360, height_mm: 750, sillHeight_mm: 765, underFloorDepth_mm: 210 },
{ id: "van", label: "Van / Großraum", bodyType: "Van (Schätzung)", cargoLiters: 700, cargoLitersMax: 1900, length_mm: 1050, widthFloor_mm: 1100, widthShoulder_mm: 1400, height_mm: 800, sillHeight_mm: 680, underFloorDepth_mm: 150 },
];
const VIN_RE = /^[A-HJ-NPR-Z0-9]{17}$/; // ISO 3779: no I, O, Q const VIN_RE = /^[A-HJ-NPR-Z0-9]{17}$/; // ISO 3779: no I, O, Q
const SUB_PRESETS = [ const SUB_PRESETS = [
@ -78,7 +95,10 @@ async function init() {
searchInput.addEventListener("input", onInput); searchInput.addEventListener("input", onInput);
searchInput.addEventListener("keydown", onKeyDown); searchInput.addEventListener("keydown", onKeyDown);
document.addEventListener("click", (e) => { document.addEventListener("click", (e) => {
if (!e.target.closest(".search-panel")) suggestionsBox.hidden = true; if (!e.target.closest(".search-panel")) {
suggestionsBox.hidden = true;
estimateBox.hidden = true;
}
}); });
randomBtn.addEventListener("click", () => { randomBtn.addEventListener("click", () => {
const car = cars[Math.floor(Math.random() * cars.length)]; const car = cars[Math.floor(Math.random() * cars.length)];
@ -178,6 +198,7 @@ function buildChips() {
searchInput.value = `${car.brand} ${car.model}`; searchInput.value = `${car.brand} ${car.model}`;
selectCar(car); selectCar(car);
suggestionsBox.hidden = true; suggestionsBox.hidden = true;
estimateBox.hidden = true;
}); });
chipsBox.appendChild(chip); chipsBox.appendChild(chip);
}); });
@ -205,6 +226,7 @@ function buildSubPresets() {
function onInput() { function onInput() {
const raw = searchInput.value.trim(); const raw = searchInput.value.trim();
hintBox.hidden = true; hintBox.hidden = true;
estimateBox.hidden = true;
activeSuggestionIndex = -1; activeSuggestionIndex = -1;
if (raw.length === 0) { if (raw.length === 0) {
@ -219,9 +241,112 @@ function onInput() {
} }
const matches = filterCars(raw); const matches = filterCars(raw);
if (matches.length === 0) {
suggestionsBox.hidden = true;
renderEstimateOption(raw);
return;
}
renderSuggestions(matches); renderSuggestions(matches);
} }
// Für Marken/Modelle ohne hinterlegte Werte: Fahrzeugklasse wählen lassen und daraus
// eine plausible Näherung bauen, damit die Suche nicht auf die Beispiel-Datenbank begrenzt ist.
function renderEstimateOption(query) {
estimateChips.innerHTML = "";
GENERIC_CATEGORIES.forEach((cat) => {
const chip = document.createElement("button");
chip.className = "chip";
chip.type = "button";
chip.textContent = cat.label;
chip.addEventListener("click", () => {
selectCar(buildEstimatedCar(query, cat));
estimateBox.hidden = true;
});
estimateChips.appendChild(chip);
});
estimateAIBtn.disabled = false;
estimateAIBtn.textContent = `Mit KI nach „${query}“ suchen`;
estimateAIStatus.hidden = true;
estimateAIBtn.onclick = () => runAiLookup(query);
estimateBox.hidden = false;
}
function buildEstimatedCar(query, cat) {
return {
id: "estimate-" + cat.id,
brand: query,
model: "",
bodyType: cat.bodyType,
cargoLiters: cat.cargoLiters,
cargoLitersMax: cat.cargoLitersMax,
length_mm: cat.length_mm,
widthFloor_mm: cat.widthFloor_mm,
widthShoulder_mm: cat.widthShoulder_mm,
height_mm: cat.height_mm,
sillHeight_mm: cat.sillHeight_mm,
underFloorDepth_mm: cat.underFloorDepth_mm,
isEstimate: true,
};
}
// Hält Werte in einem plausiblen Bereich, falls die KI-Antwort mal Ausreißer liefert
function clampNum(value, fallback, min, max) {
const n = Number(value);
if (!Number.isFinite(n) || n <= 0) return fallback;
return Math.min(max, Math.max(min, n));
}
async function runAiLookup(query) {
estimateAIBtn.disabled = true;
estimateAIStatus.hidden = false;
estimateAIStatus.textContent = `Frage Claude nach „${query}“ …`;
try {
const res = await fetch("api/lookup.php", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query }),
});
const data = await res.json();
if (!res.ok || data.error) {
throw new Error(data.error || `HTTP ${res.status}`);
}
if (data.found === false) {
estimateAIStatus.textContent = `Claude konnte „${query}“ nicht sicher als Fahrzeug erkennen. Bitte Kategorie wählen oder Eingabe präzisieren.`;
estimateAIBtn.disabled = false;
return;
}
const car = {
id: "ai-" + Date.now(),
brand: String(data.brand || query).slice(0, 60),
model: String(data.model || "").slice(0, 60),
bodyType: String(data.bodyType || "Unbekannt") + " (KI-Schätzung)",
cargoLiters: Math.round(clampNum(data.cargoLiters, 450, 80, 2200)),
cargoLitersMax: data.cargoLitersMax ? Math.round(clampNum(data.cargoLitersMax, null, 80, 2600)) : null,
length_mm: clampNum(data.length_mm, 900, 400, 1400),
widthFloor_mm: clampNum(data.widthFloor_mm, 1000, 600, 1500),
widthShoulder_mm: clampNum(data.widthShoulder_mm, 1300, 700, 1700),
height_mm: clampNum(data.height_mm, 550, 300, 950),
sillHeight_mm: clampNum(data.sillHeight_mm, 700, 500, 900),
underFloorDepth_mm: data.underFloorDepth_mm ? clampNum(data.underFloorDepth_mm, null, 40, 260) : null,
isEstimate: true,
isAIEstimate: true,
};
// Breite unten darf die Breite oben nicht überschreiten (Wanne läuft nach oben konisch zu)
car.widthFloor_mm = Math.min(car.widthFloor_mm, car.widthShoulder_mm);
selectCar(car);
estimateBox.hidden = true;
} catch (err) {
estimateAIStatus.textContent = `KI-Anfrage fehlgeschlagen (${err.message}). Bitte erneut versuchen oder Kategorie wählen.`;
estimateAIBtn.disabled = false;
}
}
function handleVin(vin) { function handleVin(vin) {
const wmi = vin.slice(0, 3); const wmi = vin.slice(0, 3);
const brand = wmiTable[wmi]; const brand = wmiTable[wmi];
@ -239,10 +364,24 @@ function handleVin(vin) {
renderSuggestions(brandCars); renderSuggestions(brandCars);
} }
// Gängige Kurzformen/Schreibweisen, damit z. B. "VW Golf" auch "Volkswagen Golf" findet
const BRAND_ALIASES = {
vw: "volkswagen", mb: "mercedes-benz", mercedes: "mercedes-benz", benz: "mercedes-benz",
chevy: "chevrolet", vag: "volkswagen",
};
function normalizeQuery(query) {
return query
.toLowerCase()
.split(/\s+/)
.map((word) => BRAND_ALIASES[word] || word)
.join(" ");
}
function filterCars(query) { function filterCars(query) {
const q = query.toLowerCase(); const q = normalizeQuery(query);
return cars return cars
.filter((c) => `${c.brand} ${c.model}`.toLowerCase().includes(q)) .filter((c) => normalizeQuery(`${c.brand} ${c.model}`).includes(q))
.slice(0, 8); .slice(0, 8);
} }
@ -754,9 +893,22 @@ function renderInfoPanel(car) {
? `<div class="spec-row"><span class="label">Stauraum unter dem Zwischenboden</span><span class="value">ca. ${car.underFloorDepth_mm} mm tief</span></div>` ? `<div class="spec-row"><span class="label">Stauraum unter dem Zwischenboden</span><span class="value">ca. ${car.underFloorDepth_mm} mm tief</span></div>`
: ""; : "";
const estimateNote = car.isAIEstimate
? `<p class="legend-note estimate-note">
Für „${car.brand}“ liegen keine hinterlegten Werte vor. Diese Maße hat Claude anhand seines
Wissens über dieses Modell geschätzt — keine offiziellen Herstellerangaben.
</p>`
: car.isEstimate
? `<p class="legend-note estimate-note">
Für „${car.brand}“ liegen keine spezifischen Werte vor. Die Maße sind eine grobe Schätzung
anhand der Fahrzeugklasse „${car.bodyType.replace(" (Schätzung)", "")}“, keine Angaben zum konkreten Modell.
</p>`
: "";
infoPanel.innerHTML = ` infoPanel.innerHTML = `
<h2>${car.brand} ${car.model}</h2> <h2>${`${car.brand} ${car.model}`.trim()}</h2>
<div class="body-type">${car.bodyType}</div> <div class="body-type">${car.bodyType}</div>
${estimateNote}
<div class="spec-highlight"> <div class="spec-highlight">
<div class="num">${car.cargoLiters}</div> <div class="num">${car.cargoLiters}</div>
<div class="unit">Liter Kofferraumvolumen (VDA)</div> <div class="unit">Liter Kofferraumvolumen (VDA)</div>

View file

@ -22,6 +22,15 @@
</div> </div>
<div id="suggestions" class="suggestions" hidden></div> <div id="suggestions" class="suggestions" hidden></div>
<div id="hintBox" class="hint-box" hidden></div> <div id="hintBox" class="hint-box" hidden></div>
<div id="estimateBox" class="hint-box estimate-box" hidden>
<p>Kein Modell mit hinterlegten Werten gefunden.</p>
<div class="estimate-ai-row">
<button id="estimateAIBtn" type="button" class="ai-btn"></button>
</div>
<p id="estimateAIStatus" class="estimate-ai-status" hidden></p>
<p class="estimate-or">…oder direkt eine Fahrzeugklasse für eine grobe Schätzung wählen:</p>
<div id="estimateChips" class="chips estimate-chips"></div>
</div>
<div id="chips" class="chips"></div> <div id="chips" class="chips"></div>
</section> </section>

View file

@ -131,6 +131,57 @@ main {
justify-content: center; justify-content: center;
} }
.estimate-box {
background: rgba(255,138,61,0.08);
border-color: rgba(255,138,61,0.35);
color: var(--text-dim);
}
.estimate-box p {
margin: 0 0 4px;
font-size: 0.85rem;
}
.estimate-chips {
margin-top: 8px;
}
.estimate-ai-row {
margin: 10px 0;
}
.ai-btn {
width: 100%;
padding: 10px 14px;
border-radius: 8px;
border: 1px solid rgba(255,138,61,0.4);
background: rgba(255,138,61,0.12);
color: var(--text);
font-size: 0.88rem;
font-weight: 600;
cursor: pointer;
}
.ai-btn:hover:not(:disabled) {
background: rgba(255,138,61,0.2);
}
.ai-btn:disabled {
cursor: default;
opacity: 0.7;
}
.estimate-ai-status {
margin: -4px 0 10px;
font-size: 0.82rem;
}
.estimate-or {
margin: 0 0 4px;
font-size: 0.78rem;
opacity: 0.85;
}
.chip { .chip {
padding: 6px 12px; padding: 6px 12px;
background: var(--bg-panel); background: var(--bg-panel);
@ -322,6 +373,16 @@ main {
line-height: 1.5; line-height: 1.5;
} }
.estimate-note {
margin: 0 0 14px;
padding: 10px 12px;
border-top: none;
background: rgba(255,138,61,0.08);
border: 1px solid rgba(255,138,61,0.3);
border-radius: 8px;
color: var(--text-dim);
}
.spec-highlight { .spec-highlight {
background: var(--bg-panel-2); background: var(--bg-panel-2);
border-radius: 10px; border-radius: 10px;