12 KiB
Dead Code Report — branch DEAD_CODE_CLEAN
Status: EXECUTED. The dead code listed below has been removed (see "Removal status" at the bottom). The one exception is the Drizzle relation exports, which were kept after verification.
Static-analysis sweep for reachable-code / caller-less code across the monorepo. Method: ripgrep-based caller search + manual verification.
- tRPC endpoints: every procedure in
admin/user/commonrouters was enumerated, then searched for callers (trpc.<path>andtrpcClient.<path>) inapps/admin-ui,apps/user-ui,apps/web-ui,apps/admin-web,apps/fallback-ui,apps/info-site. - Methods/functions: exported + local
function/constdefinitions inapps/backend/srcandpackages/db_helper_sqlite/srcwere searched repo-wide; classified as truly uncalled only when they appear nowhere except their definition (and pure re-export files). - Files: inbound-reference scan by module name.
- Excludes
node_modules,dist,.wrangler,.output,.expo,.turbo,.tanstack.
Caveats at the bottom — some of these may be intentional (manual tooling, external API consumers, planned features). Verify before deleting.
1. Dead tRPC endpoints (15)
No caller in any client app (native or web). Each is still registered on the router, so it is reachable over HTTP but unused by this repo.
| Endpoint | File | Line | Note |
|---|---|---|---|
trpc.admin.coupon.validate |
apps/backend/src/trpc/apis/admin-apis/apis/coupon.ts |
265 | Admin coupon validation |
trpc.admin.vendorSnippets.getById |
.../admin-apis/apis/vendor-snippets.ts |
184 | Single snippet fetch |
trpc.admin.vendorSnippets.getVendorOrders |
.../admin-apis/apis/vendor-snippets.ts |
464 | Vendor orders |
trpc.admin.slots.getSlotsProductIds |
.../admin-apis/apis/slots.ts |
138 | Dup of product.* variant |
trpc.admin.slots.updateSlotProducts |
.../admin-apis/apis/slots.ts |
194 | Dup of product.* variant |
trpc.admin.slots.getSlots |
.../admin-apis/apis/slots.ts |
387 | Only trpc.user.slots.getSlots is used |
trpc.admin.slots.deleteSlot |
.../admin-apis/apis/slots.ts |
583 | No delete-slot UI |
trpc.admin.product.updateSlotProducts |
.../admin-apis/apis/product.ts |
392 | Duplicate router entry |
trpc.admin.product.getSlotsProductIds |
.../admin-apis/apis/product.ts |
462 | Duplicate router entry |
trpc.admin.staffUser.getUsers |
.../admin-apis/apis/staff-user.ts |
79 | admin.user.getAllUsers is the used one |
trpc.admin.staffUser.getUserDetails |
.../admin-apis/apis/staff-user.ts |
104 | admin.user.getUserDetails is used |
trpc.admin.staffUser.updateUserSuspension |
.../admin-apis/apis/staff-user.ts |
128 | admin.user.updateUserSuspension is used |
trpc.admin.user.createUserByMobile |
.../admin-apis/apis/user.ts |
29 | No caller |
trpc.common.product.getDashboardTags |
.../common-apis/common.ts |
144 | Home reads tags from products.json, not this |
trpc.hello |
apps/backend/src/trpc/router.ts |
14 | Scaffold sample endpoint |
Notable: the slots ↔ product routers have four duplicated procedures (getSlotsProductIds, updateSlotProducts) — both copies are dead. The staffUser router duplicates three user-management procedures that are only ever called via the admin.user router.
2. Dead backend functions / constants (truly uncalled)
Defined/exported but never referenced anywhere else in the repo.
Env / config
| Symbol | File |
|---|---|
getJwtSecret |
apps/backend/src/lib/env-exporter.ts |
getRedisUrl |
apps/backend/src/lib/env-exporter.ts |
getPhonePeBaseUrl |
apps/backend/src/lib/env-exporter.ts |
getPhonePeClientId |
apps/backend/src/lib/env-exporter.ts |
getPhonePeClientVersion |
apps/backend/src/lib/env-exporter.ts |
getPhonePeClientSecret |
apps/backend/src/lib/env-exporter.ts |
getPhonePeMerchantId |
apps/backend/src/lib/env-exporter.ts |
READABLE_ORDER_ID_KEY |
apps/backend/src/lib/const-strings.ts |
WELCOME_MESSAGE |
apps/backend/src/lib/const-strings.ts |
defaultRole |
apps/backend/src/lib/roles-manager.ts |
Notifications / jobs
| Symbol | File | Note |
|---|---|---|
sendPushNotificationsMany |
apps/backend/src/lib/expo-service.ts |
Whole file has no importers (see §4) |
sendOrderPlacedNotification |
apps/backend/src/lib/notif-job.ts |
Only an unused import + a commented call in user-apis/order.ts |
sendOrderCancelledNotification |
apps/backend/src/lib/notif-job.ts |
Same — imported, call commented |
sendPaymentFailedNotification |
apps/backend/src/lib/notif-job.ts |
No reference |
sendOrderOutForDeliveryNotification |
apps/backend/src/lib/notif-job.ts |
No reference |
sendRefundInitiatedNotification |
apps/backend/src/lib/notif-job.ts |
No reference |
(Alive: sendAdminNotification via queue-consumer.ts ← worker.ts; sendOrderPackagedNotification and sendOrderDeliveredNotification via admin order api; scheduleNotification via those.)
Stores / cache / misc
| Symbol | File |
|---|---|
getOrderDetailsWrapper |
apps/backend/src/dbService.ts |
clearAllCache |
apps/backend/src/lib/cloud_cache.ts |
getAllBanners |
apps/backend/src/stores/banner-store.ts |
getTagById |
apps/backend/src/stores/product-tag-store.ts |
getAllTags |
apps/backend/src/stores/product-tag-store.ts |
getProductSlots |
apps/backend/src/stores/slot-store.ts |
getAllProductsSlots |
apps/backend/src/stores/slot-store.ts |
getUserNegativity |
apps/backend/src/stores/user-negativity-store.ts |
createTRPCRouter |
apps/backend/src/trpc/trpc-index.ts (alias re-export, unused) |
3. Dead exports in db_helper_sqlite
| Symbol | File | Note |
|---|---|---|
mergeDuplicateProducts |
packages/db_helper_sqlite/src/admin-apis/merge-duplicate-products.ts |
Exported via index + sqliteImporter, but no code calls it (function had a "how to use manually" doc comment → manual utility). Removed. |
productSkusRelations, productMarketStatsRelations, skuFeaturesRelations, productCombosRelations (src/db/schema.ts) looked unreferenced but are NOT dead — Drizzle registers relation exports via import * as schema in db_index.ts, and db.query.*.findMany({ with: … }) depends on them. Kept.
Used only inside their own file (helpers of live code — not dead): parseDuplicateProductsMd (deleted with the merge utility), splitQuantityFeature, cleanFeatureValue, productTypeEnum.
4. Dead / unreachable files & endpoints
| Item | File | Note |
|---|---|---|
| Expo push service | apps/backend/src/lib/expo-service.ts |
No module imports it; its only export is uncalled |
av-router |
apps/backend/src/apis/admin-apis/apis/av-router.ts |
Mounted at /api/v1/av but registers zero routes (staff-auth middleware only) |
| REST product summary | apps/backend/src/apis/common-apis/apis/common-product.controller.ts (getAllProductsSummary) |
Reachable at /api/v1/cm/products/summary, but no client calls it (apps use tRPC) |
/api/test (test-controller.ts) is referenced only by apps/fallback-ui/src/routes/demo.tsx (a demo page).
5. Unused imports that point at dead code
| File | Unused import | Reality |
|---|---|---|
apps/backend/src/trpc/apis/user-apis/apis/order.ts |
sendOrderPlacedNotification (line 29) |
Call is commented out (line 235) |
apps/backend/src/trpc/apis/user-apis/apis/order.ts |
sendOrderCancelledNotification (line 30) |
Call is commented out (line 598) |
6. Commented-out / unreachable code blocks
Not "callers-less" but unreachable. Many "Old implementation" blocks were kept across the backend; the most notable registered-looking ones:
apps/backend/src/trpc/apis/common-apis/common.ts:160-176—getStoresSummaryandhealthCheckprocedures inside a/* … */block (NOT registered; the live ones are incommon-trpc-index.ts).apps/backend/src/main-router.ts—// router.route('/av', avRouter)(route disabled).- Numerous
// Old implementation - direct DB queries:blocks inadmin-apis/*,user-apis/*, and db helpers (historical only).
7. Checked and NOT dead (for reference)
apps/admin-ui/user-ui/web-uiexports: 0 truly-unused. 18 shared exports (AdminOrderItemCore,SkuFlagCore,UserStoreSummaryCore, …) are referenced only within their own file to compose other types — that's normal, not dead.- Backend functions used only inside their own file (e.g.
cloud_cacheinternalscreateProductsFileInternal,constructCacheUrl,clearUrlCache;slot-storetransformSlotToStoreSlot/extractSlotInfo/fetchAllTransformedSlots;trpc-indexcreateCallerFactory) — all reachable via their parent functions, not dead. queue-consumer.ts— although it imports only-in-backend, it IS used byworker.ts, so alive.
Caveats
- Static analysis only. A tRPC procedure can still be called by an external/undisclosed client (mobile build, partner integration). Confirm before removing public procedures.
mergeDuplicateProductsandexpo-servicelook intentionally kept for manual/one-off use — decide whether to delete or document.- The
admin-webtree is present on disk but untracked on this branch; it was included in the caller search. - Some "dead" management procedures (
staffUser.*, duplicatedslots/productentries) may be leftovers from older UI screens; safe to remove once confirmed.
Removal status (executed)
Removed — 15 tRPC procedures: admin.coupon.validate; admin.vendorSnippets.getById, getVendorOrders; admin.slots.getSlotsProductIds, updateSlotProducts, getSlots, deleteSlot; admin.product.updateSlotProducts, getSlotsProductIds; admin.staffUser.getUsers, getUserDetails, updateUserSuspension; admin.user.createUserByMobile; common.product.getDashboardTags; trpc.hello.
Removed — backend functions/constants: getJwtSecret, getRedisUrl, getExpoAccessToken, getPhonePeBaseUrl/ClientId/ClientVersion/ClientSecret/MerchantId, READABLE_ORDER_ID_KEY, WELCOME_MESSAGE, defaultRole, getOrderDetailsWrapper, clearAllCache, getAllBanners, getTagById, getAllTags, getDashboardTags, getProductSlots, getAllProductsSlots, getUserNegativity, createTRPCRouter, createCallerFactory, and the notification senders sendOrderPlacedNotification, sendPaymentFailedNotification, sendOrderOutForDeliveryNotification, sendOrderCancelledNotification, sendRefundInitiatedNotification + their message constants.
Removed — DB helper functions orphaned by the procedures above (from BOTH db_helper_sqlite and db_helper_postgres, plus their barrel exports and sqliteImporter re-exports):
createUserByMobile, deleteSlotById, getVendorOrders, updateSlotProducts, getSlotsProductIds (the five behind the deleted endpoints) and getActiveSlots, getAllUsers, getUserWithDetails, validateCoupon, checkUnitExists, getProductImagesById, replaceProductTags (same class, missed by the first scan because their names also exist in the parallel package).
Removed — files: apps/backend/src/lib/expo-service.ts, apps/backend/src/middleware/staff-auth.ts (only used by the empty av-router), apps/backend/src/apis/admin-apis/apis/av-router.ts (empty router), packages/db_helper_sqlite/src/admin-apis/merge-duplicate-products.ts.
Removed — wiring: avRouter import/route from main-router.ts + v1-router.ts; mergeDuplicateProducts exports from db_helper_sqlite/index.ts and sqliteImporter.ts; unused sendOrder*Notification import + commented calls in user-apis/order.ts; orphaned imports in all touched files.
Kept (false positives / intentional): the four Drizzle relation exports (implicitly registered); mergeDuplicateProducts was deleted per §3.
Verification: tsc clean for apps/backend, packages/db_helper_sqlite, apps/web-ui, apps/admin-ui, apps/user-ui, apps/admin-web. (apps/fallback-ui has one pre-existing vite.config.ts error unrelated to this change.)