How bigc7292/stonesightainew works
Purpose and Entry Points
StoneSight AI is a Vite/React client with a separate TypeScript Node backend for visualizing stone materials in interior imagery and generating image, video, and 3D outputs. Frontend bootstraps at src/main.tsx into src/App.tsx; backend bootstraps at server/server.ts. Local development is initiated through the root package.json.
Client Application and Session Boundary
The React application owns interactive workflow state, rendering, galleries, and authenticated-user context. Authentication is modeled through src/auth/AuthContext.tsx, with login UI in src/auth/LoginPage.tsx; Supabase client integration is centralized in src/lib/supabase.ts. App features should consume this boundary rather than directly coupling UI to persistence/auth APIs.
Stone Catalog and Visualization UI
Stone choices and associated local assets are represented by src/stones.ts, backed by material directories such as public/Dekton, public/granite, and public/quartz. The primary result presentation layer includes src/components/GenerationGallery.tsx, src/components/BeforeAfterSlider.tsx, and src/components/SplatViewer3D.tsx, separating generated-media display from generation orchestration.
Generation Orchestration
Client-side service modules form the generation API boundary: src/services/generationService.ts handles paid/main generation workflows, while src/services/freeGenerationService.ts handles the free 3D path. src/services/aiMemoryService.ts indicates persistent or reusable AI context. These services should mediate calls from src/App.tsx to backend routes, rather than embedding provider logic in components.
Backend API Stages
The Node server exposes capability-oriented HTTP routes:
• Image generation/editing: server/routes/image.ts
• Video generation: server/routes/video.ts
• Primary 3D generation: server/routes/3d.ts
• Free 3D/splat conversion: server/routes/3d-free.ts
server/server.ts composes these routes, while server/middleware/auth.ts protects backend operations. This is the trust boundary for secrets, provider credentials, input validation, job submission, and provider-response normalization.
AI Providers and Media Pipeline
The README identifies NVIDIA NIM and Cosmos 3 as material external AI infrastructure, configured through NVIDIA_API_KEY. Repository artifacts such as ai_logic.json, bucket_config.json, and metadata.json, plus setup documents docs/image-pipeline-setup.md and docs/video-pipeline-setup.md, indicate multi-stage image/video generation and storage pipeline concerns. 3D output is represented as PLY assets, including public/demo_trellis_1784532841222.ply and test.ply.
Persistence, Storage, and Deployment Assets
Supabase is the apparent authentication and object-storage backend, accessed via src/lib/supabase.ts, src/services/supabaseAuth.ts, and src/services/supabaseStorage.ts; schema/bootstrap material resides in supabase-setup.sql. Public media is served from public/, while generated artifacts likely move through Supabase storage before being rendered in the gallery/viewer. Environment-specific secrets remain outside the client, with .env.example documenting required configuration.
Main entry points: server.ts API server · App.tsx Workflow application · GenerationGallery.tsx Generation gallery · AuthContext.tsx Auth context
Components 22
React Client
Interactive material-selection and generation workflow.
- Client bootstrap
src/main.tsx - Workflow application · Owns interactive generation workflow state.
src/App.tsx - Auth context · Provides authenticated-user context to client features.
src/auth/AuthContext.tsx - Login UI
src/auth/LoginPage.tsx - Stone catalog · Maps stone choices to local material assets.
src/stones.ts - Material assets
public/Dekton - Paid generation API · Mediates main image, video, and 3D workflows.
src/services/generationService.ts - Free 3D API · Mediates free splat conversion.
src/services/freeGenerationService.ts - AI memory service · Manages reusable AI context.
src/services/aiMemoryService.ts - Generation gallery
src/components/GenerationGallery.tsx - Before/after viewer
src/components/BeforeAfterSlider.tsx - 3D splat viewer
src/components/SplatViewer3D.tsx
Node API
Protected generation capability boundary.
- API server · Composes capability routes.
server/server.ts - API authentication · Protects backend operations before provider access.
server/middleware/auth.ts - Image generation
server/routes/image.ts - Video generation
server/routes/video.ts - Primary 3D generation
server/routes/3d.ts - Free 3D conversion
server/routes/3d-free.ts
External Platform
Identity, storage, and AI infrastructure.
- Supabase client · Central client access to authentication and storage.
src/lib/supabase.ts - Supabase · Stores identity and generated media artifacts.
supabase-setup.sql - NVIDIA NIM / Cosmos 3 · External image, video, and 3D generation infrastructure.
Other components
- Local development
package.json
Connections 28
- Local development → Client bootstrap: starts client
- Local development → API server: starts API
- Client bootstrap → Workflow application: mounts
- Workflow application → Auth context: uses session
- Login UI → Auth context: signs in through
- Auth context → Supabase client: uses
- Supabase client → Supabase: connects to
- Workflow application → Stone catalog: selects material
- Stone catalog → Material assets: references
- Workflow application → Paid generation API: requests generation
- Workflow application → Free 3D API: requests free 3D
- Workflow application → AI memory service: uses context
- Workflow application → Generation gallery: renders results
- Generation gallery → Before/after viewer: presents image results
- Generation gallery → 3D splat viewer: presents 3D results
- Paid generation API → API server: calls protected API
- Free 3D API → API server: calls protected API
- API server → API authentication: applies
- API server → Image generation: mounts
- API server → Video generation: mounts
- API server → Primary 3D generation: mounts
- API server → Free 3D conversion: mounts
- Image generation → NVIDIA NIM / Cosmos 3: submits jobs
- Video generation → NVIDIA NIM / Cosmos 3: submits jobs
- Primary 3D generation → NVIDIA NIM / Cosmos 3: submits jobs
- Free 3D conversion → NVIDIA NIM / Cosmos 3: converts media
- API server → Supabase: stores generated artifacts
- Supabase → Generation gallery: serves generated media