BizOSaaS Platform β Essential File Reference Map
Purpose: Zero-search reference for all critical files, folders, and configurations.
Updated: 2026-07-15
Use this file FIRST before performing any grep/find operations to save LLM tokens.
π Monorepo Rootβ
/media/alagirirajesh/storage/projects/bizosaas-platform/
βββ apps/
β βββ web/ β Next.js 16 multi-tenant app (client + admin + partner portals)
β βββ workers/ β BullMQ background workers (TypeScript)
β βββ ai-service/ β Python FastAPI AI agent service
β βββ docs/ β Docusaurus documentation site
β βββ e2e/ β Playwright E2E test suite
βββ packages/
β βββ db/ β Drizzle ORM shared DB package
β βββ ui/ β Shared shadcn/ui components
β βββ config/ β Shared ESLint, TSConfig, Tailwind config
β βββ testing/ β Shared test utilities
βββ infrastructure/ β Docker Compose, Caddy, deployment scripts
βββ package.json β Root pnpm workspace config
ποΈ Database Schemaβ
| File | Purpose |
|---|---|
packages/db/src/schema/core.ts | PRIMARY SCHEMA β all tables: tenants, users, contacts, deals, campaigns, agentTaskLog, conversations, messages, subscriptions, etc. (1567 lines) |
packages/db/src/schema/crm.ts | CRM-specific tables: crmActivities, crmMetricSnapshots, crmPipelines, crmPipelineStages |
packages/db/src/schema/pages.ts | Payload CMS Pages table |
packages/db/src/schema/partner-alerts.ts | partnerAlertPreferences, userAlertPreferences, consequenceWarnings |
packages/db/src/index.ts | DB client exports β getAuthDb(), withTenant(), all table refs |
Key Tables (in core.ts)β
| Table | Location (line) | Description |
|---|---|---|
tenants | ~4 | Multi-tenant anchor β every row is scoped by tenantId |
user | ~53 | Auth users (better-auth native) |
contacts | ~351 | CRM contacts β firstName, lastName, email, status, leadScore |
deals | ~379 | CRM deals β amount, stage, probability |
campaigns | ~425 | Marketing campaigns β platform, spend, revenue, conversions |
agentTaskLog | ~670 | BullMQ task telemetry β status, progress (0-100), workerName |
agentMilestoneLog | ~703 | Granular agent milestone events |
conversations | ~521 | Inbox conversations β platform, participantName, lastMessageAt |
messages | ~541 | Individual messages per conversation |
subscriptions | ~201 | Stripe/Razorpay subscriptions β gateway, status, plan |
invoices | ~224 | Invoice records |
crmTeams | ~892 | CRM teams β name, description |
crmTeamMembers | ~909 | Team-user pivot β teamId, userId, role |
crmWorkflows | ~980 | CRM workflow definitions |
auditLogs | ~1127 | Immutable compliance/security audit log |
connectorSecrets | ~1480 | OAuth tokens per tenant per connector |
partnerManagedTenants | ~86 | PartnerβClient relationships |
tenantIntegrations | ~779 | Integration config per tenant (Shopify, Gmail, etc.) |
supportTickets | ~631 | Support ticket system |
agentTaskLog | ~670 | Real-time agent task progress (source of truth for all progress bars) |
π Web App Structure (apps/web/src/)β
Key Library Filesβ
| File | Purpose |
|---|---|
lib/auth.ts | Better-Auth configuration + session helpers |
lib/tenant.ts | getEffectiveTenantId(), getTenantIdByHost() |
lib/format.ts | formatCurrency() and other formatters |
lib/cms/api.ts | getPayloadClient(), getTenantProducts(), getPlatformSettings() |
lib/cms/products.ts | Payload product fetch helpers |
lib/billing/ | Billing helpers |
lib/actions/ai-actions.ts | Server actions for AI endpoints |
lib/actions/cms-actions.ts | Server actions for Payload CMS mutations |
Authenticationβ
| File | Purpose |
|---|---|
middleware.ts | Multi-tenant routing + auth guards (subdomain detection) |
app/api/auth/[...all]/route.ts | Better-Auth catch-all handler |
Admin Portal (app/(admin)/admin/)β
| Route | File | Purpose |
|---|---|---|
/admin | page.tsx | Admin overview dashboard |
/admin/tenants | tenants/page.tsx | Tenant management |
/admin/billing | billing/page.tsx | Admin billing overview |
/admin/billing/gateways | billing/gateways/page.tsx | Payment gateway config |
/admin/economics | economics/page.tsx | Platform economics / BizCredits |
/admin/marketplace | marketplace/page.tsx | Add-ons marketplace |
/admin/ai-agents | ai-agents/page.tsx | AI agent fleet management |
/admin/ai-agents/actions.ts | β | Agent task server actions |
/admin/observability/agents | agents/page.tsx | Agent observatory |
/admin/observability/agents/actions.ts | β | Observability server actions |
/admin/inbox | inbox/page.tsx | Unified inbox |
/admin/inbox/actions.ts | β | fetchInboxConversations(), fetchInboxStats(), sendReply() |
/admin/crm/broadcasts | broadcasts/page.tsx | CRM broadcast campaigns |
/admin/moderation | moderation/actions.ts | Content moderation actions |
/admin/infrastructure | infrastructure/page.tsx | Server health metrics |
/admin/analytics | analytics/page.tsx | Platform analytics charts |
/admin/ecommerce/policy | policy/actions.ts | E-commerce policy management |
Client Dashboard (app/(dashboard)/dashboard/)β
| Route | File | Purpose |
|---|---|---|
/dashboard | page.tsx | Main client overview |
/dashboard/crm | crm/page.tsx | CRM overview |
/dashboard/crm/contacts | crm/contacts/page.tsx | Contacts list |
/dashboard/crm/deals | crm/deals/page.tsx | Deals pipeline |
/dashboard/crm/teams | crm/teams/page.tsx | Teams list (loads real members via DB join) |
/dashboard/crm/teams | crm/teams/TeamsClient.tsx | Teams UI (renders real member avatars) |
/dashboard/crm/workflows | crm/workflows/page.tsx | Workflow builder |
/dashboard/crm/workflows | crm/workflows/WorkflowsClient.tsx | Workflow UI (real executionCount from DB) |
/dashboard/billing | billing/page.tsx | Client billing/subscription page |
/dashboard/ecommerce/sync | ecommerce/sync/page.tsx | Ecommerce sync pipelines (live from agentTaskLog) |
/dashboard/ecommerce/products | ecommerce/products/page.tsx | Live product catalog (from Payload CMS) |
/dashboard/partner/compliance | partner/compliance/page.tsx | GDPR/DSAR portal |
/dashboard/partner/snapshots | partner/snapshots/page.tsx | Partner snapshot deployments |
/dashboard/partner/leaderboard | partner/leaderboard/page.tsx | Partner performance leaderboard |
/dashboard/marketing/campaigns | marketing/campaigns/page.tsx | Campaign management |
/dashboard/marketing/campaigns/marketplace | marketplace/page.tsx | Campaign marketplace |
/dashboard/branding | branding/page.tsx | White-label branding settings |
/dashboard/branding/actions.ts | β | Branding server actions |
/dashboard/rewards | rewards/page.tsx | Rewards program |
/dashboard/rewards/redeem | rewards/redeem/page.tsx | Redeem rewards |
/dashboard/settings/billing | settings/billing/page.tsx | Settings billing tab |
/dashboard/settings/billing/actions.ts | β | Billing server actions |
/dashboard/activity | activity/page.tsx | AI activity log history |
Partner Portal (app/(partner)/partner/ and /dashboard/partner/)β
| Route | File | Purpose |
|---|---|---|
/partner | page.tsx | Partner overview |
/partner/clients | clients/page.tsx | Client management |
/partner/tasks | tasks/page.tsx | Partner task management |
/partner/approvals | approvals/page.tsx | Approval center |
/partner/revenue | revenue/page.tsx | Partner revenue tracking |
/partner/support | support/page.tsx | Cross-client support view |
/partner/alerts | alerts/page.tsx | Alert management |
/partner/policies | policies/page.tsx | Policy management |
API Routes (app/api/)β
| Route | File | Purpose |
|---|---|---|
/api/auth/[...all] | auth/[...all]/route.ts | Better-Auth handler |
/api/ai/briefing | ai/briefing/route.ts | AI daily briefing (real agentTaskLog progress) |
/api/ai/billing/plans | ai/billing/plans/route.ts | Subscription plans |
/api/ai/billing/subscription | ai/billing/subscription/route.ts | Active subscription |
/api/ai/billing/invoices | ai/billing/invoices/route.ts | Invoice history |
/api/tenants/usage | tenants/usage/route.ts | Usage metrics (AI credits, CRM contacts, messages) |
/api/tenants/payment-method | tenants/payment-method/route.ts | Payment method info |
/api/agent-tasks/stream | agent-tasks/stream/route.ts | SSE real-time task feed |
/api/agent-tasks | agent-tasks/route.ts | Task history REST endpoint |
/api/ecommerce/sync/pipelines | ecommerce/sync/pipelines/route.ts | Live sync pipeline status (agentTaskLog) |
/api/ecommerce/sync/inventory | ecommerce/sync/inventory/route.ts | Inventory sync trigger |
/api/ecommerce/sync/conflicts | ecommerce/sync/conflicts/route.ts | Conflict detection |
/api/partner/clients | partner/clients/route.ts | Partner's managed clients list |
/api/partner/compliance | partner/compliance/route.ts | GDPR export/deletion across tenants |
/api/partner/leaderboard | partner/leaderboard/route.ts | Partner rankings from DB |
/api/partner/snapshots | partner/snapshots/route.ts | Snapshot deployment endpoint |
/api/analytics/channel-performance | analytics/channel-performance/route.ts | NEW Live ROAS by channel from campaigns table |
/api/analytics/social-proof | analytics/social-proof/route.ts | NEW Live social proof events from contacts |
/api/templates | templates/route.ts | NEW Templates from Payload CMS |
/api/onboarding/magic | onboarding/magic/route.ts | Magic onboarding endpoint |
/api/checkout | checkout/route.ts | Stripe checkout session |
Dashboard UI Components (components/dashboard/)β
| Component | File | Purpose |
|---|---|---|
AgentActivityFeed | AgentActivityFeed.tsx | Real-time SSE task feed widget |
SocialProofWidget | SocialProofWidget.tsx | Live events from /api/analytics/social-proof |
TemplateMarketplace | TemplateMarketplace.tsx | Live from /api/templates with search/filter |
VideoReviewWidget | VideoReviewWidget.tsx | Video testimonials display |
Ecommerce Components (components/ecommerce/)β
| Component | File | Purpose |
|---|---|---|
ChannelROASChart | ChannelROASChart.tsx | Live channel ROAS from /api/analytics/channel-performance |
Providers (components/providers/)β
| Component | Purpose |
|---|---|
tenant-preferences-provider.tsx | Currency, locale preferences from DB |
β‘ Workers (apps/workers/src/)β
| File | Purpose |
|---|---|
index.ts | Main entrypoint β bootstraps all workers |
content.worker.ts | Content generation tasks |
email.worker.ts | Email sending + campaign tasks |
seo.worker.ts | SEO audit + keyword research tasks |
social-media.worker.ts | Social posting + scheduling |
billing.worker.ts | Invoice + subscription sync |
analytics.worker.ts | Analytics sync |
discovery.worker.ts | Silent discovery + competitor analysis |
domain.worker.ts | Domain assignment + expiry checks |
agent-task.worker.ts | Generic AI agent tasks |
onboarding.worker.ts | Tenant provisioning |
reporting.worker.ts | Automated ROI reports |
lib/task-log.ts | Shared logTaskStart(), logTaskProgress(), logTaskComplete(), logTaskFail() |
π€ AI Service (apps/ai-service/app/)β
| Path | Purpose |
|---|---|
api/ | FastAPI route handlers |
api/support.py | Support ticket AI auto-triage |
agents/ | CrewAI agent definitions (28+ agents) |
connectors/ | 74+ external service connectors |
connectors/erpnext.py | ERPNext connector |
connectors/cloudflare.py | Cloudflare DNS + zone management |
services/ | Business logic services |
services/billing_service.py | Stripe/Razorpay billing + usage metering |
services/usage_manager.py | Redis-based usage quota management |
services/support_email.py | Support email + multilingual detection |
models/ | SQLAlchemy models |
π§ͺ E2E Tests (apps/e2e/)β
| File | Purpose |
|---|---|
playwright.config.ts | Playwright config β base URLs for all portals |
tests/helpers/e2e.config.ts | Test environment config (IP, subdomain URLs) |
tests/01-auth.spec.ts | Auth flow tests |
tests/02-onboarding.spec.ts | Onboarding flow tests |
tests/03-dashboard-routes.spec.ts | Dashboard routing tests |
tests/04-crm.spec.ts | CRM feature tests |
tests/admin/ | Admin portal test suite |
tests/partner/ | Partner portal test suite |
Test URLs (Local)β
- Admin:
http://admin.bizoholic.local:3000 - Partner:
http://partner.bizoholic.local:3000 - Client:
http://app.bizoholic.local:3000orhttp://coreldove.bizoholic.local:3000
π³ Infrastructureβ
| File | Purpose |
|---|---|
infrastructure/docker-compose.yml | Main production compose β web, ai-service, workers, postgres, redis |
infrastructure/docker-compose.dev.yml | Local dev compose |
infrastructure/scripts/deploy.sh | Production deploy script |
infrastructure/scripts/migrate.sh | Database migration script |
infrastructure/scripts/seed.sh | Database seed script |
infrastructure/configs/ | Caddy, OTel collector configs |
π¦ Key npm Scriptsβ
# From monorepo root:
pnpm dev # Start all apps in dev mode
pnpm build # Build all apps
pnpm --filter web build # Build only web app
pnpm --filter e2e test # Run all E2E tests
pnpm --filter e2e test:admin # Run only admin E2E tests
pnpm --filter e2e test:partner # Run only partner E2E tests
pnpm lint # Lint all workspaces
pnpm typecheck # Type check all workspaces
# DB Operations (from monorepo root):
pnpm --filter @bizosaas/db generate # Generate Drizzle migrations
pnpm --filter @bizosaas/db migrate # Apply migrations to DB
pnpm --filter @bizosaas/db seed # Seed initial data
π Environment Variables (via Infisical)β
Secrets are fetched from app.infisical.com. Key env vars:
| Variable | Purpose |
|---|---|
DATABASE_URL | PostgreSQL connection string |
REDIS_URL | Redis connection for BullMQ |
BETTER_AUTH_SECRET | Auth session signing secret |
NEXT_PUBLIC_APP_URL | Base app URL |
OPENROUTER_API_KEY | All LLM calls (OpenAI, Anthropic via OpenRouter) |
STRIPE_SECRET_KEY | Stripe payments |
RAZORPAY_KEY_ID/SECRET | Razorpay (India) payments |
PADDLE_API_KEY | Paddle (MoR for partner marketplace) |
RESEND_API_KEY | Email sending |
ELEVENLABS_API_KEY | TTS / Voice agents |
CLOUDFLARE_API_TOKEN | DNS management |
PAYLOAD_SECRET | Payload CMS admin secret |
AI_SERVICE_URL | Internal FastAPI service URL |
Note: No separate OpenAI/Anthropic keys needed β use
OPENROUTER_API_KEYfor all LLMs.
π Production URLsβ
| Portal | URL |
|---|---|
| Main App | https://app.bizoholic.com |
| Admin Portal | https://admin.bizoholic.com |
| Partner Portal | https://partner.bizoholic.com |
| Client Site Example | https://coreldove.bizoholic.com |
| Docs | https://docs.bizoholic.com |
| AI Service | Internal (not public) |
π Mock Data Removal Status (2026-07-15)β
All items below have been fully replaced with live database queries:
| Component | Old Mock | New Live Source |
|---|---|---|
ChannelROASChart.tsx | MOCK_CHANNELS[] | /api/analytics/channel-performance β campaigns table |
TemplateMarketplace.tsx | MOCK_TEMPLATES[] | /api/templates β Payload CMS templates collection |
SocialProofWidget.tsx | MOCK_EVENTS[] + Math.random() | /api/analytics/social-proof β contacts table |
TeamsClient.tsx | Math.random() initials | crmTeamMembers JOIN user (real initials) |
WorkflowsClient.tsx | Math.random() * executions | workflow.executionCount from DB |
ecommerce/sync/page.tsx | MOCK_SYNCS[], MOCK_CONFLICTS[] | /api/ecommerce/sync/pipelines β agentTaskLog |
api/ai/briefing/route.ts | Math.floor(Math.random() * 30) | t.progress from agentTaskLog |
admin/inbox/actions.ts | Hardcoded stats (12, 87, etc.) | Live count queries with 24h window filter |
/ecommerce/products/page.tsx | MOCK_PRODUCTS[] | Redirect to /dashboard/ecommerce/products (Payload CMS) |
partner/compliance/page.tsx | Static DSAR UI | Live cross-tenant contact search + audit log |
partner/leaderboard/page.tsx | Hardcoded rankings | /api/partner/leaderboard β partnerManagedTenants + agentTaskLog |
partner/snapshots/page.tsx | Static snapshot list | /api/partner/clients β real managed clients |
Remaining Stubs (intentional/acceptable)β
| Component | Status | Notes |
|---|---|---|
VideoReviewWidget.tsx | Hardcoded 2 reviews | Acceptable until client uploads real video testimonials |
finance/actions.ts | Stubbed | Plaid/Razorpay ledger integration pending |
| Briefing API progress | β Fixed | Now uses real agentTaskLog.progress |
π Docs & Plans Filesβ
| File | Purpose |
|---|---|
apps/docs/docs/tasks/rebuild-tasks.md | Master task tracker β all phases + completion status |
apps/docs/docs/plans/implementation-plan.md | Detailed implementation plan |
apps/docs/docs/plans/platform-file-map.md | THIS FILE β zero-search quick reference |
apps/docs/docs/roadmap.md | Product roadmap |
π Git & CI/CDβ
| Item | Value |
|---|---|
| Repo | Bizoholic-Digital/bizosaas-platform |
| Main branch | main |
| CI workflow | .github/workflows/ci.yml |
| Deploy workflow | .github/workflows/deploy.yml |
| Container registry | GHCR (GitHub Container Registry) |
ποΈ Active Clients (Tenants)β
| Client | Slug | Status |
|---|---|---|
| Coreldove D2C | coreldove | β Onboarded, dashboard active |
| Thrillring (Gaming) | thrillring | β Internal test client |
| QuantTrade | quanttrade | β Internal test client |
| Saathi CFO | saathi | π Email intelligence pivot |
Last updated: 2026-07-15 β Generated after mock data purge sprint