Public App Documentation β
ποΈ Architecture Overview β
Technology Stack β
- Framework: Next.js 14.2.5 with Pages Router
- Language: TypeScript 5 for type safety
- Styling: Tailwind CSS v3.4.4 + SCSS (Sass)
- UI Components: Custom React components
- Fonts: Merriweather (headlines) + Inter (body)
- Dependencies: React 18.3.1, axios, markdown-it
- Deployment: Vercel-ready with serverless functions
Project Structure β
apps/public/
βββ src/
β βββ pages/ # Next.js file-based routing
β β βββ index.tsx # Homepage (/)
β β βββ how-it-works.tsx # How it works (/how-it-works)
β β βββ trustedhub.tsx # TrustedHub (/trustedhub)
β β βββ faq.tsx # FAQ (/faq)
β β βββ privacy.tsx # Privacy Policy (/privacy)
β β βββ terms&conditions.tsx # Terms & Conditions (/terms&conditions)
β β βββ _app.tsx # App wrapper with Header/Footer/Chatbot
β β βββ _document.tsx # Document wrapper
β βββ components/ # Reusable components
β β βββ Header.tsx # Navigation header with mobile menu
β β βββ Footer.tsx # Footer component
β β βββ Button.tsx # Button component
β β βββ ChatbotWidget.tsx # AI chatbot with markdown support
β β βββ MyTrustedHub.tsx # Hub feature (currently commented out)
β βββ styles/
β βββ globals.scss # Global styles with design tokens
βββ public/ # Static assets (images, PDFs, etc.)
βββ package.json # Dependenciesπ― Application Flow β
User Journey Architecture β
The Public App follows a strategic user conversion funnel:
- Awareness Stage: Homepage hero section with compelling value proposition
- Interest Stage: Interactive features and educational content
- Consideration Stage: TrustedHub features and transparent pricing
- Action Stage: CTA buttons leading to portal app integration
- Conversion Stage: Seamless handoff to portal app for patient intake
Page Flow Architecture β
Homepage (/) - Primary Entry Point β
- Hero Section:
- Compelling headline "Take control of your surgery"
- Typewriter effect rotating specialties (CABG, Knee, Hip, Spinal, Cataract surgeons)
- Animated bubble background
- Value proposition with $99 pricing
- Feature Tiles: 6 key benefits with interactive hover effects and scroll animations
- Interactive Demo: "How Trusted Surgeon Works" with step navigation (3 steps)
- Sample Report Section: Scroll-triggered animations for report display
- Why Trusted Surgeon Section: Benefits and value propositions
- Patient Testimonials: Multiple testimonial cards with scroll animations
- TrustedHub Section: Secure vault platform features with CTA
- Pricing Information: Transparent $99 one-time investment
- CTA Buttons: Primary ("Join the Movement Today") and secondary ("See a Sample Report") action buttons
- Scroll Animations: Intersection Observer API for fade-in animations
How It Works (/how-it-works) - Educational Content β
- Process Overview: 3-step surgical journey explanation
- Step-by-Step Navigation: Interactive step buttons with visual feedback
- Detailed Steps: In-depth procedure information for each step
- Scroll Animations: Intersection Observer for step visibility
- Report Card Display: Sample report card with scroll-triggered animation
- Benefits: Why choose Trusted Surgeon platform
- Data Sources: Transparency about data collection methods
- Success Stories: Patient testimonials and outcomes
TrustedHub (/trustedhub) - Secure Vault Platform β
- Journey Sections:
- Pre-Surgery section with scroll animations
- Hospital section with scroll animations
- Post-Surgery section with scroll animations
- Feature Cards: 4 feature cards with scroll-triggered animations
- Hub Features: Document storage and management capabilities
- Security: Blockchain-based security measures
- Journey Management: Complete surgical process tracking
- Integration: Connection with surgeon reports and data
- Visual Elements: Timeline icons and feature illustrations
FAQ (/faq) - Support Information β
- Accordion Interface: Expandable FAQ items with toggle functionality
- Common Questions: Patient and procedure-related FAQs
- Platform Usage: How to use Trusted Surgeon effectively
- TrustedSurgeon & TrustedVault: Detailed explanations of platform features
- Technical Support: Troubleshooting and help resources
Privacy Policy (/privacy) - Legal Information β
- CCPA Compliance: California Consumer Privacy Act employee privacy notice
- Data Collection: Information about data collection practices
- User Rights: Consumer privacy rights and how to exercise them
- Contact Information: Privacy-related contact details
Terms & Conditions (/terms&conditions) - Legal Information β
- Terms of Service: Comprehensive terms and conditions
- Content Formatting: Properly formatted sections with bullet points
- Legal Sections: Multiple sections covering service usage, liability, etc.
π§© Component Architecture β
Core Components β
Header Component (src/components/Header.tsx) β
typescript
// Navigation with mobile responsiveness
- Logo with brand link to homepage (Next.js Image component)
- Desktop navigation menu (Home, How it Works, TrustedHubβ’, FAQs)
- Mobile hamburger menu with responsive design
- CTA buttons (Sign In, Get Started) with portal app integration
- Fixed positioning with backdrop blur effect (bg-white/70 backdrop-blur)
- State management for mobile menu toggleKey Features:
- Responsive navigation for all screen sizes
- Portal app integration via
NEXT_PUBLIC_PORTAL_URLenvironment variable - Smooth transitions and hover effects
- Accessibility support with ARIA labels
- Mobile menu state management with React hooks
App Wrapper (src/pages/_app.tsx) β
typescript
// Global app wrapper with shared components
- Header component (fixed on all pages)
- Footer component (fixed on all pages)
- ChatbotWidget component (fixed on all pages)
- Next.js Head component for SEO metadata
- Router integration for page transitionsKey Features:
- Consistent layout across all pages
- Global styles via
globals.scssimport - SEO metadata management
- Shared component structure
Footer Component (src/components/Footer.tsx) β
typescript
// Multi-column footer with comprehensive site information
- Brand section with logo, tagline, and social media links
- About links (Mission, Team, How It Works, Partnerships)
- Resources (FAQs, Blog, Patient Guide, Glossary)
- Contact information with phone, email, and address
- Legal links (Privacy Policy, Terms of Service, Cookie Policy)Social Media Integration:
- Facebook, Twitter, Instagram, LinkedIn icons
- Hover effects and smooth transitions
- Responsive grid layout
Button Component (src/components/Button.tsx) β
typescript
interface ButtonProps {
children: React.ReactNode;
variant?: 'outlined' | 'filled';
onClick?: () => void;
className?: string;
style?: React.CSSProperties;
}Variants:
- Filled: Turquoise background with white text
- Outlined: White background with navy border and text
- Interactive: Hover effects and focus states
- Accessible: Keyboard navigation and screen reader support
ChatbotWidget Component (src/components/ChatbotWidget.tsx) β
typescript
// AI-powered chatbot with modal interface
- Fixed position floating button (bottom-right, configurable offset)
- Modal overlay with backdrop
- Message input with send functionality and file upload support
- AI assistant integration via axios API calls
- Markdown rendering for AI responses (markdown-it)
- Message history with user and AI message types
- Typing indicators and loading states
- Mobile responsive design with touch optimization
- Auto-scroll to latest messageFeatures:
- Context-aware responses for surgical procedures
- Markdown support for formatted AI responses
- Real-time message handling with state management
- File upload capability for document sharing
- Message history persistence during session
- Smooth animations and transitions
- TypeScript interfaces for type safety (Message interface)
π¨ Design System Architecture β
Color Palette β
scss
// Brand Colors - Healthcare-focused palette
$warm-navy: #23395D; // Primary - Trust, authority, stability
$soft-sand: #F4E9E1; // Comfort - Approachability, warmth
$turquoise: #00BFA6; // Secondary - Healing, calm reassurance
$olive-green: #8B9A5B; // Natural - Health, balance, growth
$coral-accent: #FF6F61; // Accent - Human connection, careTypography System β
scss
// Font Families - Dual-font system for optimal hierarchy
$font-headline: 'Merriweather', serif; // Trust, authority, headlines
$font-body: 'Inter', sans-serif; // Readability, modern, body text
// Typography Scale
.headline-1 { font-size: 3.5rem; line-height: 1.1; font-weight: 700; }
.headline-2 { font-size: 2.5rem; line-height: 1.2; font-weight: 700; }
.headline-3 { font-size: 2rem; line-height: 1.3; font-weight: 700; }
.headline-4 { font-size: 1.5rem; line-height: 1.4; font-weight: 700; }
.body-large { font-size: 1.125rem; line-height: 1.6; font-weight: 400; }
.body-regular { font-size: 1rem; line-height: 1.6; font-weight: 400; }Responsive Design System β
scss
// Breakpoint System
Mobile: < 640px // Single column, stacked layout
Tablet: 640px - 1024px // Two-column layouts
Desktop: > 1024px // Multi-column, full layouts
// Grid System
.grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 // Responsive grid
.flex flex-col sm:flex-row // Responsive flexπ State Management Architecture β
Local State Management β
typescript
// React hooks for component-level state
const [howStep, setHowStep] = useState<number>(1); // Step navigation
const [isOpen, setIsOpen] = useState(false); // Modal states
const [message, setMessage] = useState(''); // Form inputs
const [showAIInfo, setShowAIInfo] = useState(false); // UI toggles
const [openItems, setOpenItems] = useState<Set<string>>(new Set()); // FAQ accordion
const [typedText, setTypedText] = useState<string>(''); // Typewriter effect
const [wordIndex, setWordIndex] = useState<number>(0); // Typewriter word index
const [charIndex, setCharIndex] = useState<number>(0); // Typewriter char index
const [isDeleting, setIsDeleting] = useState<boolean>(false); // Typewriter direction
const [messages, setMessages] = useState<Message[]>([]); // Chatbot messages
const [isTyping, setIsTyping] = useState(false); // Chatbot typing stateGlobal State Patterns β
- URL State: Search parameters and navigation state
- Local Storage: User preferences and settings persistence
- Session Management: Cross-app authentication state
- Environment Variables: Portal app URL configuration
State Flow Examples β
typescript
// Interactive step navigation
const handleStepClick = (step: number) => {
setHowStep(step);
// Update UI based on selected step
};
// Chatbot state management
const toggleChatbot = () => {
setIsOpen(!isOpen);
if (!isOpen) {
// Reset states when opening - start fresh session
setShowAIMessage(false);
setHasUserMessage(false);
setMessages([]);
setIsTyping(false);
}
};
// Typewriter effect state management
useEffect(() => {
const typeWriter = () => {
const currentWord = rotatingSpecialties[wordIndex];
// Type and delete logic with state updates
};
const timer = setTimeout(typeWriter, isDeleting ? 50 : 100);
return () => clearTimeout(timer);
}, [wordIndex, charIndex, isDeleting, typedText]);
// Scroll animation with Intersection Observer
const useIntersection = (ref: RefObject<HTMLElement>, threshold = 0.1) => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => setIsVisible(entry.isIntersecting),
{ threshold }
);
if (ref.current) observer.observe(ref.current);
return () => observer.disconnect();
}, [ref, threshold]);
return isVisible;
};π Integration Architecture β
Portal App Integration β
typescript
// Environment-based cross-app navigation
const portalUrl = process.env.NEXT_PUBLIC_PORTAL_URL;
// Authentication flow integration
<a href={`${portalUrl}/sign-in`}>
Sign In
</a>
// Patient intake integration
<a href={`${portalUrl}/patient-surgery-intake`}>
Get Started / Join the Movement Today
</a>Integration Points:
- Header navigation links to portal app
- CTA buttons redirect to portal app patient intake
- Environment variable
NEXT_PUBLIC_PORTAL_URLfor configuration - Seamless handoff from public marketing to portal application
External API Integration β
- Chatbot API: AI assistant integration via axios
- POST requests to chatbot endpoint
- Markdown response rendering
- File upload support for document sharing
- Message history management
- Analytics: User behavior tracking and conversion monitoring (ready for implementation)
Data Flow Architecture β
User Interaction β Component State β API Call β Data Processing β UI Updateπ± User Experience Flow β
Homepage Experience β
- Hero Section:
- Compelling headline "Take control of your surgery"
- Typewriter effect with rotating surgeon specialties
- Animated bubble background
- Clear value proposition
- Feature Tiles: 6 key benefits with interactive hover effects and scroll animations
- Interactive Demo: "How Trusted Surgeon Works" with 3-step navigation buttons
- Sample Report Section: Scroll-triggered report display with animations
- Why Trusted Surgeon: Benefits section with scroll animations
- Patient Testimonials: Multiple testimonial cards with staggered scroll animations
- TrustedHub Section: Secure vault features and benefits with CTA
- Pricing Information: Transparent $99 one-time investment
- CTA Buttons: Primary ("Join the Movement Today") and secondary ("See a Sample Report") action buttons
Interactive Elements β
typescript
// Step navigation with visual feedback
const [howStep, setHowStep] = useState<number>(1);
// Interactive step buttons with active states
<button
onClick={() => setHowStep(1)}
className={`step-button ${howStep === 1 ? 'active' : ''}`}
>
Step 01
</button>
// Typewriter effect for hero section
const rotatingSpecialties = ['CABG Surgeon', 'Knee Surgeon', 'Hip Surgeon', 'Spinal Surgeon', 'Cataract Surgeon'];
// Auto-typing and deleting effect with cursor animation
// Scroll-triggered animations
const useIntersection = (ref: RefObject<HTMLElement>, threshold = 0.1) => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => setIsVisible(entry.isIntersecting),
{ threshold }
);
if (ref.current) observer.observe(ref.current);
return () => observer.disconnect();
}, [ref, threshold]);
return isVisible;
};
// FAQ accordion toggle
const toggleItem = (itemId: string) => {
const newOpenItems = new Set(openItems);
if (newOpenItems.has(itemId)) {
newOpenItems.delete(itemId);
} else {
newOpenItems.add(itemId);
}
setOpenItems(newOpenItems);
};Mobile Experience Optimization β
- Touch-friendly: Minimum 44px touch targets
- Responsive Layout: Adaptive grid systems and typography
- Fast Loading: Optimized images and lazy loading
- Smooth Animations: CSS transitions and transforms
- Gesture Support: Swipe and touch interactions
π Security Architecture β
Data Protection β
- Input Validation: Sanitize all user inputs and form data
- HTTPS: Secure communication with SSL/TLS encryption
- Privacy Controls: User data management and GDPR compliance
- Cross-Origin Security: Proper CORS configuration for API calls
Authentication Flow β
typescript
// Secure portal app integration
const handleSignIn = () => {
// Redirect to portal app for authentication
window.location.href = `${process.env.NEXT_PUBLIC_PORTAL_URL}/sign-in`;
};
// Session management
const checkAuthStatus = () => {
const isAuthenticated = localStorage.getItem('isAuthenticated') === 'true';
return isAuthenticated;
};β‘ Performance Architecture β
Optimization Strategies β
- Code Splitting: Automatic page-based splitting with Next.js
- Image Optimization: Next.js Image component with lazy loading
- Static Generation: Pre-rendered pages where possible
- CDN: Global content delivery for assets
- Bundle Optimization: Tree shaking and dead code elimination
Loading Performance β
typescript
// Image optimization with Next.js
<Image
src="/logo.svg"
alt="Trusted Surgeon"
width={180}
height={40}
className="h-10 w-auto"
priority // For above-the-fold images
/>
// Lazy loading for below-the-fold content
<Image
src="/background.jpg"
alt="Background"
loading="lazy"
/>Core Web Vitals Optimization β
- LCP (Largest Contentful Paint): Optimize hero section loading
- FID (First Input Delay): Minimize JavaScript execution time
- CLS (Cumulative Layout Shift): Prevent layout shifts with proper sizing
π― Business Logic Flow β
User Conversion Funnel β
- Awareness: Homepage hero and feature presentation
- Interest: Interactive demo and educational content
- Consideration: TrustedHub features and transparent pricing
- Action: CTA buttons with clear value proposition
- Conversion: Seamless portal app integration
Value Proposition Delivery β
- Data-Driven: 30+ proprietary data points analysis
- Personalized: 5+ top-rated recommended specialists
- Trusted: TrustedRangeβ’ personalized rating system
- Secure: TrustedHubβ’ blockchain-based vault platform
- Affordable: $99 one-time investment in health
Call-to-Action Strategy β
typescript
// Primary CTA - Main conversion goal
<a href={`${portalUrl}/patient-surgery-intake`}>
Join the Movement Today
</a>
// Secondary CTA - Trust building
<a href="/sample-report.pdf" target="_blank">
See a Sample Report
</a>π Analytics and Monitoring β
User Behavior Tracking β
- Page Views: Navigation patterns and user flow
- Interaction Events: Button clicks and form submissions
- Conversion Tracking: CTA button effectiveness and conversion rates
- Performance Metrics: Core Web Vitals and loading times
Business Intelligence β
- User Journey Analysis: Complete conversion funnel tracking
- Feature Usage: Component interaction and engagement metrics
- A/B Testing: CTA button optimization and content testing
- Performance Monitoring: Real-time app performance and error tracking
Analytics Implementation β
typescript
// Event tracking for user interactions (ready for implementation)
const trackEvent = (eventName: string, properties: Record<string, unknown>) => {
if (typeof window !== 'undefined' && window.gtag) {
window.gtag('event', eventName, properties);
}
};
// Conversion tracking
const trackConversion = (conversionType: string) => {
trackEvent('conversion', {
event_category: 'engagement',
event_label: conversionType,
value: 1
});
};
// Chatbot interaction tracking
const trackChatbotMessage = (messageType: 'user' | 'ai') => {
trackEvent('chatbot_interaction', {
event_category: 'engagement',
event_label: messageType
});
};π Deployment Architecture β
Build Process β
bash
# Development
npm run dev
# Production build
npm run build
# Production server
npm startVercel Deployment β
- Serverless Functions: API routes as serverless functions
- Edge Caching: Global CDN caching for optimal performance
- Automatic Scaling: Handle traffic spikes automatically
- Preview Deployments: Branch-based preview environments
Environment Configuration β
env
# Development
NEXT_PUBLIC_PORTAL_URL=http://localhost:5173
# Production
NEXT_PUBLIC_PORTAL_URL=https://portal.trustedsurgeon.aiπ§ Development Workflow β
Code Quality β
- TypeScript: Type safety and better developer experience
- ESLint: Code linting and style enforcement
- Prettier: Code formatting consistency
- Husky: Git hooks for pre-commit checks
Testing Strategy β
- Unit Tests: Component testing with Jest and React Testing Library
- Integration Tests: Page-level testing and user flow validation
- E2E Tests: Full user journey testing with Playwright
- Performance Tests: Core Web Vitals monitoring
Development Tools β
- Hot Reload: Fast development with Next.js dev server
- Type Checking: Real-time TypeScript error detection
- Source Maps: Debug-friendly development builds
- Component Library: Reusable component documentation
This comprehensive architecture provides a robust, scalable foundation for the Trusted Surgeon Public App, ensuring optimal user experience, performance, and maintainability.