Prompt file imported from BeathovenGala/NexaAssist (
.github/prompts/plan-generalPurposeSaas.prompt.md). Copyright stays with the author.
Plan: General-Purpose SaaS (appointments, inventory, chatbot, ads)
TL;DR - Build a multi-tenant SaaS platform that supports role-based user access, calendar/appointment booking, inventory management, a chatbot that queries inventory and books appointments, and automated ad/poster generation and delivery (e.g., WhatsApp). Start with a focused MVP for hospitals/medical stores then generalize for grocery / fashion.
Steps
- Discovery & Constraints (short): confirm compliance needs (HIPAA/PHI for hospitals), scale targets, and initial client personas. blocks: legal/compliance decisions
- Choose tech stack and infra (quick decision): pick frontend, backend, DB, queue, LLM+image APIs, notification providers.
- Initialize repo & scaffolding: monorepo or separated repos; create
frontend/,backend/,infra/,docs/,tests/. - Core platform services (auth, tenancy, RBAC): implement JWT/OAuth, tenant isolation, role model, audit logging. depends on step 2
- MVP features (parallel where possible):
- Appointment booking & calendar UI + API
- Basic inventory CRUD and availability query
- Chatbot integration (LLM + inventory lookup hooks)
- Notifications (email/SMS/WhatsApp) + webhook delivery
- Admin features: schedules management, inventory adjustments, offer/campaign composer
- Ads/image generation integration: image generation API + template system + send via WhatsApp API
- Background processing: job queue for notifications, image generation, async chat fallbacks
- Testing & QA: unit, integration, E2E, security scans, compliance checks
- Deploy: CI/CD pipelines, staging, production, monitoring, backups
Relevant files to create initially
frontend/— React + Next.js app skeletonbackend/— Node.js (NestJS/Express) or Python (FastAPI) serviceinfra/—docker-compose.yml, basic Terraform/CloudFormationREADME.md,.env.sample,package.jsonorrequirements.txt
Tech stack (recommended)
- Frontend: React + Next.js, TypeScript, Tailwind CSS
- Backend: Node.js + NestJS (or FastAPI) with TypeScript (or Python)
- DB: PostgreSQL (multi-tenant via schema or row-level), Redis for caching
- Jobs/Queue: BullMQ + Redis
- Storage: S3-compatible (AWS S3)
- Auth: Auth0 or OpenID Connect + JWTs
- LLM / Chatbot: OpenAI (gpt-4o/advanced) or Anthropic; local LLM for on-prem optional
- Image generation: OpenAI images / Stability.ai / Midjourney API
- Messaging/WhatsApp: Twilio or WhatsApp Business Cloud API
- Infra: Docker, Kubernetes (optional), Terraform
- Monitoring: Prometheus + Grafana / Sentry
Users & Roles (RBAC)
- Super Admin: platform-wide config, billing
- Tenant Admin (store/hospital owner): manage org, users, inventory, campaigns
- Manager: manage schedule, inventory approvals, messages
- Doctor / Staff / Pharmacist: view appointments, inventory, communicate with users via chat
- Customer / Patient / Shopper: book appointments, chat, view offers
- Chatbot: service account used by LLM integrations
Data model (high level tables / collections)
- organizations: id, name, domain, settings, billing_info, created_at
- users: id, org_id, role_id, name, email, phone, password_hash, meta
- roles: id, name, permissions
- permissions: id, name
- appointments: id, org_id, user_id (patient), staff_id (doctor), service_type, start, end, status, created_by, notes
- calendars: id, org_id, owner_id, timezone, visibility
- inventory_items: id, org_id, sku, name, category, qty, unit, price, details, location, reorder_threshold
- inventory_transactions: id, item_id, org_id, change, reason, actor_id, created_at
- chatbot_sessions: id, org_id, user_id, messages (json), resolved_flag, escalation_id
- messages: id, session_id, sender_type, content, metadata, created_at
- campaigns: id, org_id, name, content_template, image_asset_id, audience_filter, schedule
- assets: id, org_id, url, type, metadata
- notifications: id, target, channel, status, payload, sent_at
- audit_logs: id, actor_id, org_id, action, resource, created_at
Key API flows / endpoints
- Auth:
POST /auth/login,POST /auth/register,POST /auth/refresh - Tenant:
POST /orgs,GET /orgs/:id(admin) - Users: CRUD users and roles
- Appointments:
GET /availabilities?provider_id&date,POST /appointments,PATCH /appointments/:id(reschedule/cancel) - Inventory:
GET /inventory?query,POST /inventory,PATCH /inventory/:id - Chatbot:
POST /chat/message(proxy to LLM + local hooks),GET /chat/sessions/:id - Campaigns:
POST /campaigns/preview,POST /campaigns/send - Notifications/webhooks:
POST /webhooks/whatsapp-callback
Chatbot integration pattern
- User sends message -> backend receives -> pre-process (intent/entity extraction) -> run inventory/appointment lookup hooks -> construct context -> call LLM API with context -> post-process LLM result (if not confident, escalate to human) -> respond via UI/WhatsApp.
- Keep structured tools: inventory_check(item_name) and appointment_check(provider, date) that LLM can call or that are run by the backend before prompting.
Multi-tenancy & security
- Tenant isolation: row-level security in Postgres or separate schemas per org
- Data encryption at rest and in transit
- Audit logs for PHI access; role-based access control strictly enforced
- Compliance: design for HIPAA if supporting hospitals (BAA, encryption, logging, data minimization)
MVP scope (priority)
- Auth + tenant + RBAC
- Appointment booking + calendar UI
- Basic inventory CRUD + inventory lookup API
- Chatbot MVP with hooks to inventory + booking (no image gen)
- Notifications (email/SMS) for booking confirmations
Phase 2 (after MVP)
- Add image/ad generation and WhatsApp sending
- Campaign automation and segmentation
- Advanced analytics and reporting
- SLA/performance scaling and multi-region deployment
Verification
- Unit tests for business logic (appointments, inventory adjustments)
- Integration tests for API endpoints and DB transactions
- E2E tests for booking flow and chatbot interaction
- Security review and HIPAA checklist if required
- Load tests for calendar and chatbot concurrency
Decisions & Assumptions
- Multi-tenant design is required; decide between schema-per-tenant or RLS; recommend RLS for many tenants.
- Hospitals require HIPAA — assume we need BAA and strict controls for that tenant type.
- Use managed services where possible to accelerate time-to-market.
Next immediate actions (pick one and I will produce the artifacts)
- A. Choose tech stack (I will scaffold repo + starter files)
- B. Draft detailed DB schema DDL for PostgreSQL
- C. Draft API contract (OpenAPI) for MVP endpoints
- D. Design UX wireframes for booking + admin panels