How saisan23/xr_card works
Project Type and Purpose
• This is a cross‐platform mobile/desktop application built in Flutter (“xr_card”).
• Purpose: allow users to create, exchange, and view digital business cards via Bluetooth, nearby‐presence, Supabase backend, and an XR simulator view.
High-Level Architectural Layers
• Presentation Layer (Widgets & Pages)
• lib/pages/, lib/features/, lib/core/widgets/
• Responsible for rendering UI, navigation between screens (Home, Connect, Exchange, Profile, Settings, XR Simulator, Contact Detail).
• Application/Service Layer
• lib/services/ (ai_service.dart, bluetooth_service.dart, nearby_presence.dart, supabase_services.dart)
• Encapsulates business logic, external APIs, device APIs (Bluetooth, Nearby), and AI calls.
• Data Layer
• lib/data/models/ (domain models)
• lib/data/sql_init/ (local DB initialization scripts)
• supabase_services interacts with remote DB (PostgreSQL) and handles CRUD.
• Core/Foundation Layer
• lib/core/widgets/ (reusable UI components: bottom nav bar, business card, expanding FAB, XR business card widget).
• Platform-Specific Adapters
• android/, ios/, macos/, linux/, windows/ directories
• Flutter engine embedding and platform integration.
Main Components & External Systems
• Flutter Frontend (Dart code)
• Supabase Backend (remote database & auth)
• AI Service (external ML/NLP API)
• Bluetooth & Nearby (P2P card exchange)
• XR Simulator (3D view in‐app)
• Platform Embedders (Android/iOS/MacOS/Linux/Windows)
Component Interactions and Data Flows
• User taps “Exchange Card” → UI (ExchangePage) calls bluetooth_service or nearby_presence.
• bluetooth_service uses platform channels (Android/iOS) to discover and connect peers → exchanges serialized UserCompleteProfile via supabase_services or local buffer.
• On save/update profile → ProfilePage calls supabase_services → HTTP requests to Supabase REST API → updates remote DB → returns updated model.
• On launching XR simulation → XRSimulatorPage triggers XRBusinessCardWidget (core widget) → renders 3D business card using local model data.
• AI-powered suggestions (if any) → ai_service sends profile text to external AI API → receives enhancements → updates UI form.
Architectural Patterns & Principles
• Layered Architecture: clear separation between Presentation, Services, Data, Core.
• Dependency Inversion: UI depends on abstract service interfaces.
• Modular Features: each feature lives under lib/features/ for scalability.
• Reusability: core widgets and theme abstractions.
• Single Responsibility: services only handle one external system.
Essential Elements to Capture
• Core Flutter app with its internal layered modules.
• Platform‐specific runners for each OS.
• External dependencies: Supabase (DB + Auth), AI API, Bluetooth/Nearby P2P.
• Data models flowing between layers.
• Navigation flow: Home → Feature Pages → Services → External.