38 Commits

Author SHA1 Message Date
sriram
c0601b65fe Brand Discovery-LLM Updates 2026-09-29 16:42:49 +05:30
sriram
c0489d89d6 Updates on Image search using vectors 2026-09-28 15:44:01 +05:30
sriram
fe208f4715 Image capturing Flow updates 2026-09-24 17:18:38 +05:30
sriram
f933ea10a1 Image vector to product details 2026-09-19 15:39:53 +05:30
sriram
bc786b1c49 GET api update for image vector 2026-09-18 17:50:14 +05:30
sriram
d6296bd1f0 imag vector generation with dimentionality reduction 2026-09-18 15:26:25 +05:30
sriram
9c8dbf1759 Image vector embedding 2026-09-16 16:33:39 +05:30
sriram
ce4fa70dee Brand valid image generation 2026-09-11 15:47:56 +05:30
sriram
10b24c6348 Catalog feature updates on column fields 2026-09-08 15:18:29 +05:30
sriram
2749bee1a3 Brand Ingestion 2026-09-07 17:52:45 +05:30
sriram
7ac3571b59 Backend scores updates on products 2026-09-05 11:53:13 +05:30
sriram
0c3e23fac4 Health score updates in backend 2026-09-04 12:06:40 +05:30
sriram
d5ec5755bf Brand image display cards 2026-09-02 13:34:40 +05:30
sriram
6c7a886659 New updates on DB and JSON 2026-09-01 13:55:15 +05:30
sriram
183b65b3bd Backend fix checkbox 2026-09-01 11:25:04 +05:30
sriram
a6e78fee95 Feature Elimination backend 2026-08-31 16:31:43 +05:30
sriram
3df2dc5991 Backend upload-automation file 2026-08-31 14:59:14 +05:30
sriram
998df898db Dagster Orchestration 2026-08-29 14:49:45 +05:30
sriram
27d53fa957 upload-catalog-integration 2026-08-29 11:21:11 +05:30
sriram
5aa2669f7d upload files without API-Key 2026-08-28 17:13:31 +05:30
Suriyakumarvijayanayagam
52f5d3be1d sheet upload fix 2026-08-28 11:22:53 +05:30
sriram
0e75d32f61 ingestion updates 2026-08-28 08:57:10 +05:30
sriram
a54bd43f8b Backend- file ingestion API Updates 2026-08-28 07:49:56 +05:30
sriram
f698720ee2 excel file update 2026-08-27 16:41:25 +05:30
sriram
1b347f91db Production Login page passcode updates 2026-08-24 22:55:06 +05:30
sriram
7bf8dc6922 Add Dagster orchestration and reduce active brands in backend 2026-08-20 16:39:54 +05:30
sriram
fbb1356e47 updates on catalog search and suggestions in backend 2026-08-20 13:03:16 +05:30
sriram
7a4583372f backend stores data file enrichment pipeline 2026-08-18 16:58:36 +05:30
sriram
691efef880 backend update auth settings and add brand catalogs 2026-08-18 12:21:37 +05:30
sriram
dba8d36175 backend updates for bulk product uploads from user 2026-08-17 15:26:49 +05:30
Suriyakumarvijayanayagam
dce2405e50 Stop /api/system/status 500ing when Ollama is switched off
_ensure_client() returns None - not False - when USE_OLLAMA is false, because
it returns before it ever probes. SystemStatusOut.ollama_connected is typed
bool, so pydantic rejected the None and the endpoint answered 500 on exactly
the configuration this deployment runs.

Found by smoke-testing the live host: every other read route answered 200 and
this one alone was a server error, which read like a database problem and was
not one. "Ollama is off" now reports as ollama_connected: false.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 18:29:16 +05:30
sriram
86bb1ebd0a Merge branch 'master' of https://gitapp.workolik.com/nearle_daily/catalogue_backend 2026-08-13 16:11:24 +05:30
sriram
241fd237f8 backend apis updation 2026-08-13 15:54:29 +05:30
Suriyakumarvijayanayagam
ad7bb9250b Expose the catalog to AI clients over MCP at /mcp
Adds a FastMCP server mounted onto the existing FastAPI app, so it ships in the
same container and answers on the same host rather than needing a process of
its own.

Fifteen tools, all read-only: catalog search and browse, nutrition facts and
health scores, healthier alternatives, per-store inventory and pricing,
discounts, trending and sales analytics. Each wraps a service function the REST
API already reaches through a GET. None of the write or compute endpoints are
exposed, because a tool list is chosen from by a model rather than by a person,
and catalog generation or model retraining is not something to leave one tool
call away.

The tools are written by hand rather than generated from the OpenAPI schema.
Mirroring all 63 routes would work, but a model picks a tool by reading its
description, and 63 near-identical generated entries is a worse thing to choose
from than a dozen written to be told apart.

Authentication reuses the access token from POST /api/auth/login - no separate
MCP credential, the same Principal and expiry as the REST API. The check lives
in one middleware rather than at the top of each tool, so a tool added later
cannot be left unguarded by forgetting a line. Note that this requires passing
include={"authorization"} to get_http_headers(), which strips that header by
default to avoid forwarding it downstream; without it the header is invisible
and every request looks unauthenticated, valid ones included.

Mounting a sub-app does not run its lifespan - only the outermost app's is
executed - so the MCP app's lifespan is chained through the FastAPI one. Without
that the endpoint accepts a connection and then fails on the first message with
a session manager that was never started.

Adds GET /api/mcp/info and POST /api/mcp/tools/{name} for the admin UI. The MCP
endpoint speaks streamable HTTP with session handling, so rendering a tool list
in the browser would otherwise mean shipping a full MCP client in React.

fastmcp needs Python 3.10+. The image is 3.11; on anything older the import
fails and the REST API starts without the MCP endpoint instead of not starting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 13:14:00 +05:30
Suriyakumarvijayanayagam
2493b86ed8 Fix nutrition upload crash, persist runtime writes, serve API on its own domain
/api/upload/nutrition called json.dumps() in a module that never imported
json, so every request to it raised NameError, was swallowed by the broad
except, and came back as "500 Database import failed". Import json.

Persist the three directories the app writes to at runtime. Products added
through the UI are appended to data/seed_catalogs/*.json and retrained models
are written to app/intelligence/artifacts/*.joblib; both live inside the image,
so a redeploy silently discarded them. The paths now come from settings
(DATA_DIR / SEED_CATALOG_DIR / MODEL_ARTIFACTS_DIR) so a volume can be mounted
on them, and catalog_engine.save_catalog resolves against DATA_DIR instead of
a working-directory-relative "data/", which landed somewhere different
depending on where the process was started from.

Mounting those volumes would otherwise have made things worse: Docker seeds a
named volume from the image on first use, but a bind mount starts empty and
just hides what the image shipped. A bind mount on /app/data would have left
the API with no seed catalogs, so the next product added would write a JSON
file containing only that product. The image now keeps pristine copies at
/app/.bundled, and restore_bundled_assets() tops up whatever a freshly mounted
directory is missing at startup without overwriting anything already there.

Configure CORS for the split-domain deployment: the React app is served from
catalogue.nearle.ai.in and calls the API on mcp.catalogue.nearle.ai.in, so the
frontend origin has to be in API_CORS_ORIGINS. A wrong list fails only in the
browser while the server logs a healthy 200, so the effective origins are now
logged at startup with a warning when they are localhost-only.

Fix FRONTEND_DIST, which looked for a sibling "frontend/" directory that is
actually named "catalogue_frontend/", so the single-port unified-serving branch
could never activate even with a build sitting next to it.

Rebuild the Dockerfile on the frontend's multi-stage pattern: dependencies
resolve into a venv in a build stage, the runtime stage copies only that.
Adds PYTHONUNBUFFERED so startup errors reach Dokploy's log pane, a liveness
HEALTHCHECK (/api/health answers 200 even when Postgres is down, so a database
blip cannot restart-loop the container), and an overridable PORT. The CMD execs
uvicorn so SIGTERM reaches it rather than the sh wrapper.

Add "from __future__ import annotations" to ollama_service and image_search,
which used PEP 604 unions in runtime-evaluated signatures and so could not be
imported below Python 3.10.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 12:30:45 +05:30
sriram
b8d93fbbf2 Updated backend auth settings 2026-08-12 18:10:25 +05:30
sriram
ac8cfacbc9 Updated backend 2026-08-12 16:37:28 +05:30
sriram
c2af4556c6 updates on the backend 2026-08-11 19:16:01 +05:30