Technical Details
A deep dive into the architecture, integrations, AI systems, and technical decisions behind the DRAW Enterprises website.
Technology Stack
How It's Built
Frontend
- React 18 (SPA architecture)
- Tailwind CSS for utility-first styling
- Framer Motion for animations
- React Router for client-side routing
- React Query for data fetching & caching
- Shadcn/UI component library
Backend & Data
- Custom Backend-as-a-Service
- Entity-based data model (JSON schemas)
- Real-time subscriptions available
- Deno Deploy for serverless functions
- RESTful entity CRUD via SDK
Auth & Security
- Built-in authentication system
- Role-based access (admin/user)
- Admin-only dashboard protection
- Secure file uploads via SDK
- Service role for backend operations
Data Architecture
Entity Schema Overview
The app uses 10 custom entities plus the built-in User entity. Each entity is defined as a JSON schema and managed via the backend SDK.
LeadCRM-style lead tracking: name, email, phone, project_type (utility/commercial/institutional/residential), status pipeline (new → contacted → qualified → proposal → won/lost), priority, estimated_value, activities log, next follow-up date. Source field tracks origin (DRAW AI Chat vs Contact Form).
ProjectProject and estimate management: customer info, address, square footage, linear footage, status workflow (draft → internal review → sent → follow-ups → approved/declined), sent/follow-up/approved dates, project_category (commercial/residential).
EstimateLinked to Project via project_id. Contains an array of service line items (each with service_type, estimate_data object, subtotal), overall subtotal, markup_percentage, total, and version number for revision tracking.
PricingItemMaster pricing database: category (material/labor/equipment/addon), service_type, item_name, unit (sqft/lnft/hour/etc), unit_price, active flag. Used to populate estimate calculations.
GalleryImageImage records with URL, title, description, category (utility/commercial/residential), is_featured flag, sort_order. Titles can be AI-generated via the analyzeGalleryImage backend function.
ApplicationJob applications: personal info, position_category, years_experience, CDL info, work_history, resume_url, additional_docs_urls array, status (new → reviewed → interview → hired/declined), referral_source.
SharedCollectionShareable gallery collections: title, image_ids array, unique share_code for URL generation, optional message. Public-facing page (SharedGallery) fetches by share_code without auth.
TestimonialClient testimonials: client_name, company, email, project info, 6 rating categories (overall, quality, communication, timeliness, professionalism, value), testimonial_text, is_ai_assisted flag, would_recommend, status (pending → approved/featured/declined), request_id link, optional photo_url.
TestimonialRequestTracks sent testimonial requests: client info, project details, unique request_code for URL generation, status (sent → opened → completed/expired), personal_message from employee, sent/completed dates.
AppSettingsSimple key-value store (setting_key / setting_value) for app-wide configuration. Flexible schema for future settings expansion.
AI Chat System
DRAW AI — Under the Hood
Architecture
- Frontend widget: AskWesWidget → AskWesChatWindow → AskWesButton components
- LLM integration via the AI service API
- Full conversation history is sent with each request for context continuity
- System prompt contains comprehensive DRAW company knowledge (70+ lines of context)
- Page-aware: the widget detects which page the visitor is on and passes it as context
- Returning visitor detection via localStorage (stores visitor name)
Lead Capture Mechanism
- The system prompt instructs the LLM to collect estimate info conversationally (name, phone, email, project type, description, location)
- When all fields are collected, the LLM emits a hidden [ESTIMATE_READY]...[/ESTIMATE_READY] tag in its response
- Frontend regex parses the tag, extracts structured data, and strips the tag from the visible message
- Lead is created via the SDK with source = "DRAW AI Chat"
- Email notification sent to sales@drawenterprises.com via the email service API
- Full conversation transcript is saved in the lead's notes field for sales context
Follow-Up Suggestions
- The system prompt asks the LLM to append 2-3 follow-up question suggestions after each response
- Suggestions are wrapped in [FOLLOW_UPS]...[/FOLLOW_UPS] tags
- Frontend parses and renders them as clickable pill buttons below the AI response
- Clicking a suggestion sends it as the next user message, creating a guided conversation flow
- Suggestions are context-aware — they change based on what was just discussed
Tone & Safety Controls
- System prompt enforces professional, courteous, and warm tone at all times
- AI is instructed to never make up information — directs visitors to contact the team for unknowns
- Estimate tags are never shown to the visitor — only parsed by the frontend
- The AI uses Markdown formatting for clean rendering via react-markdown
- If the visitor goes off-topic, the AI gracefully redirects to DRAW-relevant topics
Backend Functions
Serverless Functions
analyzeGalleryImage
Deno Deploy serverless function that accepts an image URL and uses the LLM vision capability to generate a professional one-sentence description of a construction project photo.
// Flow:
// 1. Frontend uploads image → gets image_url
// 2. Calls the analyzeGalleryImage serverless function with { image_url }
// 3. Function passes image to the AI vision API with JSON schema
// 4. Returns { description: "..." } for auto-populating gallery captions
// Auth: Requires authenticated user
// Service Role: Uses elevated permissions for AI integration callContact & Lead Forms
Form Implementation Details
Contact Form
- Fields: firstName, lastName, email, phone, service, message, preferredContact, timeline, referralSource
- File uploads via the upload API — supports images, PDFs, docs
- Parallel execution: Lead.create() and SendEmail() fire simultaneously via Promise.all()
- Service-to-project_type mapping for consistent CRM categorization
- File attachment URLs included in both the lead record and the email notification
Careers Application Form
- Multi-step form (3 steps): Personal Info → Experience & Qualifications → Documents & Submit
- Position categories: field_construction, cdl_trucking, office_administrative, general_inquiry
- Conditional fields: CDL class appears only when has_cdl = true
- Resume upload and additional document uploads stored as URLs on the Application entity
- Status tracking: new → reviewed → interview → hired/declined
Admin Dashboard
CRM & Lead Management
Dashboard Features
- React Query for lead data fetching with automatic cache invalidation
- Dual view modes: sortable table (List) and Kanban board
- Multi-field filtering: status, source, project type, and text search
- Sortable columns: name, status, estimated value, created date
- CSV export with all lead fields
- LeadAnalytics component: KPIs, bar chart (monthly), pie chart (status), source breakdown
Lead Detail Panel
- Inline editing for status, priority, estimated value, follow-up date, and notes
- Activity logging: calls, emails, meetings, and general notes with timestamps
- Activities stored as JSON array on the Lead entity
- Overdue follow-up detection with visual indicators
- Lead deletion with confirmation dialog
- Recharts library powers all analytics visualizations
SEO Implementation
Search Engine Optimization
Meta Tag Management (Layout Component)
- PAGE_META object in Layout.js maps page names to unique title, description, and OG image
- Dynamic meta tag injection via document.head manipulation on route change
- Open Graph tags (og:title, og:description, og:image, og:url, og:type) set per page
- Twitter Card tags (summary_large_image) for social sharing previews
- Custom favicon set programmatically
- Scroll-to-top behavior on route changes for better UX
- Each service page sets its own document.title and meta description via useEffect
Testimonial System
Client Testimonial Collection & Display
A complete testimonial lifecycle system — from sending personalized requests to displaying approved reviews on the homepage. Client satisfaction is the strongest form of marketing for a construction company, and this system makes it effortless to collect and showcase that proof.
Request & Collection Flow
- Admin Dashboard → Testimonials tab → Send Request form
- Generates unique request_code (random 8-char base36 string)
- AI-powered personal message generation via InvokeLLM — uses client name, project name, and project type for context
- Creates TestimonialRequest entity and sends personalized email to client with unique submission URL
- Public SubmitTestimonial page fetches request by code, pre-fills project details
- Client rates across 6 categories with star ratings, writes testimonial (optional AI writing assistant), uploads optional photo
- Submitted testimonial linked to request via request_id; request status updated to "completed"
Management & Display
- TestimonialManager component in Admin Dashboard with 3 tabs: Testimonials, Requests, Send Request
- Status workflow: pending → approved / featured / declined
- Featured testimonials auto-displayed in homepage TestimonialsSection carousel
- TestimonialsSection fetches featured/approved testimonials via the backend SDK, falls back to static data if none exist
- Auto-rotating carousel with navigation arrows and pagination dots
- StarRating reusable component for consistent rating display
- Components: TestimonialManager, TestimonialForm, SendTestimonialRequest, StarRating, TestimonialsSection
Gallery System
Photo Management & Sharing
Gallery Components
- GalleryGrid: filterable image grid with category tabs and admin controls
- GalleryLightbox: full-screen image viewer with navigation
- GalleryUploadForm: drag-and-drop upload with AI description generation
- ShareCollectionModal: select images → generate unique share link
Share Collection Flow
- Admin selects images → opens ShareCollectionModal
- Random 8-character share_code generated (Math.random base36)
- SharedCollection entity created with image_ids array
- Public URL: /SharedGallery?code={share_code}
- SharedGallery page fetches collection by code, then fetches images by IDs — no auth required
Component Architecture
File Organization
Directory Structure
pages/ → Top-level route pages (flat, no subfolders) Home, About, Contact, Careers, Gallery, Leadership, UtilityConstruction, CommercialServices, InstitutionalServices, ResidentialServices, AdminDashboard, Portfolio, SharedGallery, ExecutiveSummary, TechnicalDetails, PrivacyPolicy, TermsOfService, etc. components/ website/ → Shared website components (Header, Footer, Hero, etc.) chat/ → DRAW AI widget (AskWesWidget, AskWesChatWindow, AskWesButton) admin/ → Dashboard components (LeadAnalytics, LeadDetailPanel, LeadKanban) testimonials/ → Testimonial system (TestimonialManager, TestimonialForm, SendRequest, StarRating) gallery/ → Gallery components (GalleryGrid, Lightbox, Upload, ShareModal) careers/ → Careers page sections (ApplicationForm, OpenPositions, etc.) commercial/ → Commercial services page sections residential/ → Residential services page sections institutional/ → Institutional services page sections utility/ → Utility construction page sections leadership/ → Leadership page components ui/ → Shadcn/UI primitives (button, card, dialog, etc.) entities/ → JSON schema definitions for all data entities functions/ → Deno Deploy serverless functions Layout.js → App-wide layout wrapper (header, footer, meta tags)
