Brimfox AI Core / AI helper service / 2026
Ranking recipes and checking explanations in Python.
Brimfox AI Core packages two inspectable recipe helpers behind FastAPI, with a Laravel client prepared to carry their results, traces and failures across the service boundary.
- ROLE
- Software engineering
- STATE OF THE BUILD
- Prototype
- RECORD UPDATED
THE WORK
The project.
Brimfox AI Core gives recipe ranking and explanation checks a small, independently startable Python service. One endpoint reorders supplied recipe candidates using explicit weights. Another compares explanation text with supplied grounding and returns support counts and warnings. These are deterministic helpers around a recipe workflow, not a model that retrieves or generates recipes.
The Laravel client makes that separate process usable as an HTTP dependency. It sends structured JSON, authentication and trace identifiers, applies connection and request timeouts, and distinguishes an exhausted timeout from other service failures. Optional logs describe the request without recording its raw payload values.
The remaining step is the product connection. Brimfox still creates explanations through its PHP provider, validator, cache and fallback; no caller in that response invokes these Python helpers. The service and client establish a concrete integration foundation, while enablement, result acceptance and end-to-end failure behavior remain work for the application that will consume it.
IMPLEMENTATION
Design choices.
- Explicit weights and support counts make the prototype's calculations inspectable. They provide a starting point for evaluation, without implying learned ranking quality or semantic verification.
- The Python package owns helper calculations; Laravel retains the recipe response and its user context. That separation keeps authority with the product, which still has to decide whether a helper result is useful enough to accept.
- Retries cover connection failures and server errors rather than every unsuccessful status. This avoids repeatedly sending rejected requests, while making retry time part of the latency a synchronous caller must budget for.
- Configuration validation and request execution are separate operations. Registering a client or setting an enable flag does not prove that a product route checks the flag or uses the service.
- The verifier reports counts instead of silently editing generated text. An application can then define an acceptance or fallback rule explicitly, after tightening nested input validation and evaluating cases the current lexical check handles poorly.
HOW IT FITS TOGETHER
Architecture.
- FastAPI runs under Uvicorn with separate health, information, ranking and verification routes. Pydantic checks the request envelope and the ranking limit, but nested candidates, explanations, grounding and configuration remain permissive dictionaries.
- The reranker adds query-token coverage, phrase matches, ingredient readiness and substitution coverage to each supplied candidate score. It sorts that existing set and returns the requested 1–20 results without fetching recipes or calling a model.
- The explanation checker selects text units, rejects a fixed list of unsafe phrases and measures keyword overlap with supplied grounding. It returns supported and dropped counts, warnings and an aggregate outcome; it does not return a cleaned explanation.
- A shared authentication dependency checks configured bearer credentials in constant time. Production-like environments refuse protected calls without a configured token, while health remains public and other environments can allow no-token calls.
- Laravel makes synchronous JSON requests with separate connection and request timeouts. Connection failures and server errors can be retried within a configured limit; the result carries status and latency, or a typed exception explains the failure.
- Laravel continues to own user-scoped context, provider calls, final validation, caching and fallback. The Python request objects and payload factory exist alongside that path, but no product caller currently joins them to it.
Explore the architecture map9 components · 12 connections
Brimfox AI Core and its Laravel integration code
The client and Python handlers exist. The reviewed product code doesn't yet call this path to produce a response.
Laravel integration
FastAPI boundary
Deterministic helpers
Scroll or drag the background to move. Use the zoom buttons to resize.Arrow keys move between components. Enter selects.
Choose a component to explore
Select a numbered component on the map or use the component menu. Its details and connections will appear here.
No component selected.
All connections (12)
- 01 · AiCoreHttpClient → 03 · require_service_authBearer-authenticated operation request · Direct call
- 01 · AiCoreHttpClient → 04 · Pydantic request modelsStructured JSON body · Direct call
- 03 · require_service_auth → 05 · Protected operation handlersAuthentication dependency accepted · Direct call
- 04 · Pydantic request models → 05 · Protected operation handlersValidated request envelope · Direct call
- 03 · require_service_auth → 02 · AiCoreResponse or service exception401 or 503 becomes service failure · Blocked / denied
- 05 · Protected operation handlers → 07 · rerank_itemsQuery, candidates and limit · Direct call
- 05 · Protected operation handlers → 08 · verify_recipe_explanationExplanation, grounding and config · Direct call
- 07 · rerank_items → 09 · Pydantic response modelsRanked candidate list · Response / return
- 08 · verify_recipe_explanation → 09 · Pydantic response modelsOutcome, counts and warnings · Response / return
- 09 · Pydantic response models → 02 · AiCoreResponse or service exceptionJSON result with latency and status · Response / return
- 01 · AiCoreHttpClient → 06 · Health handlerHealth request · Direct call
- 06 · Health handler → 02 · AiCoreResponse or service exceptionStatus and version · Response / return
MADE WITH
Python 3.11 · FastAPI · Pydantic 2 · Uvicorn · pytest · Laravel HTTP client · Docker
ACCESS & INPUT
Security controls.
- Protected endpoints use constant-time bearer comparison. A production-like environment with no configured service token returns 503; when a token is configured, absent or incorrect credentials return 401.
- The health route is unauthenticated, and other environments permit helper calls without credentials when no token is configured. Those choices make correct environment settings and network exposure part of any deployment review.
- The container recipe selects a non-root application user. That is an implemented packaging control, not evidence that a container has been built, deployed or isolated on a network.
- When Laravel request logging is enabled, it records route, trace identifier, latency, status, payload key names and candidate counts. Raw request values are not included in that logging path.
- The Python helpers do not call providers or own account, authorization or database decisions. A support outcome describes their lexical checks, not factual correctness or medical and allergy safety.
- Laravel defaults the service to disabled and validates connection settings when enabled. Its low-level HTTP client does not enforce the enable flag, so the eventual product caller must make that check before sending a request.
Explore the security map9 components · 11 connections
Authentication and output trust at the optional helper boundary
The implemented client and service have separate configuration, authentication and logging controls; no current product caller consumes the helper results.
Laravel integration
Python service
Responses and diagnostics
Scroll or drag the background to move. Use the zoom buttons to resize.Arrow keys move between components. Enter selects.
Choose a component to explore
Select a numbered component on the map or use the component menu. Its details and connections will appear here.
No component selected.
All connections (11)
- 01 · Connection configuration → 02 · Optional-service HTTP clientConnection values; enablement not enforced here · Direct call
- 02 · Optional-service HTTP client → 03 · Unauthenticated health routeHealth request without route auth · Direct call
- 03 · Unauthenticated health route → 09 · Support metadata, not product authorityStatus metadata only · Response / return
- 02 · Optional-service HTTP client → 04 · Environment-aware bearer checkProtected helper request · Direct call
- 04 · Environment-aware bearer check → 07 · Rejected or unavailable requestRequired token absent or incorrect · Blocked / denied
- 04 · Environment-aware bearer check → 05 · Pydantic request envelopeEnvironment and credential policy allow · Direct call
- 05 · Pydantic request envelope → 07 · Rejected or unavailable requestInvalid request envelope · Blocked / denied
- 05 · Pydantic request envelope → 06 · Deterministic support helpersAccepted structured input · Direct call
- 06 · Deterministic support helpers → 09 · Support metadata, not product authorityTyped support response · Response / return
- 02 · Optional-service HTTP client → 07 · Rejected or unavailable requestTimeout or exhausted service failure · Response / return
- 02 · Optional-service HTTP client → 08 · Optional metadata-only request logConfigured request metadata logging · Async task
CHECKS & RESULTS
What was checked.
A source review shows what the code does. It is not a fresh test of the running app.
Code and development records reviewedReviewed
The code, tests and available development records were checked. Reported test results keep their original scope. No fresh app or live deployment check was run for this write-up.
- Scope of this check
- Code review, not a fresh run of the app
NEXT
Still to work through.
The next milestone is a recipe request that deliberately uses this service and has defined behavior for success, timeout, rejected authentication and unusable output. The verifier also needs stronger nested validation: missing fields can become the text None, and the threshold accepts arbitrary configuration values. A historical report records six Python tests passing, but no fresh service run, end-to-end integration or ranking improvement is established here.