RecognitionBridge
Digital ink recognition provider adapters + candidate normalization
Statusβ
| Key | Value |
|---|---|
| Layer | core |
| Tier | L1 |
| Status | wip |
| Version | 0.9.0 |
| Price | Free (free) |
| Category | Input & UX |
Overviewβ
Overviewβ
RecognitionBridge is the Layer 1 Core Plugin of multi-saas-kit. It sends DigitalInk stroke data to external recognition providers and normalizes candidate text into a standard result shape.
Provider operations, pricing policy, and usage billing are outside this plugin. For example, apis.how Hand Writer is one provider that RecognitionBridge can call; apis.how owns its own product and billing policy.
Alongside DigitalInk (stroke standard) and BrushConfiguration (rendering settings), this is one of the three foundations for the HandwritingInput composite plugin.
Core Componentsβ
RecognizerInterfaceβ
Common contract for all recognition adapters:
interface RecognizerInterface {
public function recognize(
array $ink, int $width, int $height,
?string $language = null, ?string $mode = null, ?int $returnCount = null,
): RecognitionResult;
}
RecognitionResult (DTO)β
Standard result shape β ok, provider, elapsed_ms, candidates, message. success() / failure() named constructors.
CandidateNormalizer (Pure)β
Extracts candidates from response. Auto-detects 3 shapes:
| Response shape | Origin |
|---|---|
['candidates' => [...]] | Hand Writer API |
['data' => ['candidates' => [...]]] | Wrapping variant |
[_, [[_, [...]]]] | Google Input Tools native |
Additional processing: trim, numeric mode regex filter, deduplication, return_count clamp.
HandWriterRecognizer (Adapter)β
apis.how Bearer token adapter. Safe fallback on missing API key / 5xx / network exception.
GoogleInputToolsRecognizer (Adapter)β
google.com.tw/inputtools/request unauthenticated fallback.
RecognizerChainβ
Tries multiple recognizers in order. Returns first ok=true. All-failed returns last failure.
Usageβ
use App\Plugins\DigitalInk\Data\StrokeData;
use App\Plugins\RecognitionBridge\Services\CandidateNormalizer;
use App\Plugins\RecognitionBridge\Services\RecognizerChain;
use App\Plugins\RecognitionBridge\Recognizers\HandWriterRecognizer;
use App\Plugins\RecognitionBridge\Recognizers\GoogleInputToolsRecognizer;
$normalizer = CandidateNormalizer::fromConfig(config('recognition-bridge.candidates'));
$primary = new HandWriterRecognizer(config('recognition-bridge.hand_writer'), $normalizer);
$fallback = new GoogleInputToolsRecognizer(config('recognition-bridge.google_input_tools'), $normalizer);
$chain = new RecognizerChain([$primary, $fallback]);
$stroke = StrokeData::fromArray($payload);
$result = $chain->recognize($stroke->toArray(), $stroke->canvasWidth, $stroke->canvasHeight, mode: 'numeric');
if ($result->ok) {
return response()->json($result->toArray());
}
Scopeβ
This plugin only provides provider call adapters and candidate normalization. API gateways, pricing tables, quotas, metering, and spend logs belong to ApiUsageAnalytics or each provider SaaS project.
Roadmap (Phase 3+)β
- Filament Settings Page (provider / credential management)
- Custom Recognizer registration (DI container binding)
- Failure statistics + Audit log integration
Licenseβ
MIT
Dependenciesβ
Demosβ
- Platform κ΄λ¦¬μ ν¨λμμ λ©ν νμΈ π Login required
- μ¬μ© μμ (PHP)
π View on Plugin Store: store.codebase.how/plugins/recognition-bridge