Skip to content

nirukk52/ScreenGraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ScreenGraph

Autonomous UX Mapping, Drift Detection & AI-Driven QA

AI agents crawl mobile apps, discover screens/transitions, and build a navigable knowledge graph.

What It Does

  • Autonomous exploration via UI actions
  • Real-time UX map generation
  • Visual/structural diff detection
  • Competitor UX mapping
  • Test gap identification
  • Analytics overlay on graph
  • AI agent context for RAG/planning

Who It's For

  • QA: Regression detection, exploratory testing
  • Product: UX analysis, journey mapping
  • Design: Flow consistency validation
  • Founders: Competitive benchmarking
  • Engineering: Visual bug replay

Core Concepts

  • ScreenGraph: Screens (nodes) + actions (edges)
  • Flows: Reusable step sequences
  • Perceptual Hashing: Screen uniqueness detection
  • Policies: Exploration strategies
  • Artifacts: Screenshots, XMLs, OCR, traces

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   SvelteKit     │────────▢│   Encore Backendβ”‚
β”‚   Frontend      β”‚  REST   β”‚   Services      β”‚
β”‚   (Vercel)      β”‚  +SSE   β”‚   (Encore Cloud)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚   PostgreSQL    β”‚
                              β”‚   + Event Store β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Stack:

  • Backend: Encore.ts microservices
  • Frontend: SvelteKit 2 (Svelte 5)
  • Agent: XState-driven orchestration
  • Database: PostgreSQL with event sourcing
  • Logging: Structured logs (module/actor)

πŸ“Š ScreenGraph Storage

Single-Sink Architecture:

  • Agent writes events to run_events (append-only log)
  • Graph projection service derives screen graph
  • No dual-writes

Screen Deduplication:

  • Identified by structural layout (XML) + visual appearance (perceptual hash)
  • Same screen across runs β†’ single canonical record
  • Tracks: first seen, last seen, visit count

Navigation Edges:

  • Captures: Screen A β†’ Action β†’ Screen B
  • Evidence-based traversal counts
  • Enables pathfinding + reachability analysis

API Endpoints (Planned):

  • GET /graph/:app_id - Full graph
  • GET /graph/screens/:screen_id - Screen details
  • GET /graph/:app_id/paths - Pathfinding
  • GET /graph/:app_id/coverage - Coverage metrics
  • GET /graph/:app_id/stream - Real-time SSE

πŸš€ Prerequisites

Install Bun:

curl -fsSL https://bun.sh/install | bash

Install Encore CLI:

# macOS
brew install encoredev/tap/encore

# Linux
curl -L https://encore.dev/install.sh | bash

πŸ“¦ Setup

Clone:

git clone <repository-url>
cd ScreenGraph

Install Dependencies:

bun install
cd frontend && bun install

Environment (.env):

# Backend: Managed by Encore (encore secret set)
# Frontend: Create frontend/.env
PUBLIC_API_BASE=http://localhost:4000  # local
# PUBLIC_API_BASE=https://steering-wheel-documentation-65b2.encr.app  # prod

Run

Backend

cd backend && encore run
  • API: http://localhost:4000
  • Dashboard: http://localhost:9400

Frontend

cd frontend && bun run dev
  • UI: http://localhost:5173

Test

Backend

cd backend && encore test

Specific test:

cd backend && encore test agent/tests/determinism.test.ts

Frontend

cd frontend && bun test

🌐 Key API Endpoints

Run Management:

  • POST /run - Start agent run
  • GET /run/:id/stream - SSE event stream
  • POST /run/:id/cancel - Cancel run
  • GET /health - Health check

Event Types:

  • agent.* - Agent state transitions
  • screen.discovered - New screen found
  • screen.mapped - Screen added to graph
  • edge.created - New navigation edge
  • edge.reinforced - Existing edge traversed

πŸ“ Project Structure

ScreenGraph/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agent/              # Agent orchestration
β”‚   β”‚   β”œβ”€β”€ orchestrator/   # XState machine + worker
β”‚   β”‚   β”œβ”€β”€ nodes/          # Setup/Main/Policy/Recovery/Terminal
β”‚   β”‚   β”œβ”€β”€ ports/          # Interfaces
β”‚   β”‚   └── adapters/       # Implementations
β”‚   β”œβ”€β”€ run/                # Run API endpoints
β”‚   β”œβ”€β”€ graph/              # Graph projection
β”‚   β”œβ”€β”€ artifacts/          # Screenshot/XML storage
β”‚   └── db/migrations/      # Schema migrations
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/routes/         # SvelteKit routes
β”‚   └── src/lib/            # Components + Encore client
β”œβ”€β”€ .cursor/
β”‚   β”œβ”€β”€ commands/           # Task automation
β”‚   └── rules/              # Coding standards
└── vibes/                  # Engineering personas

πŸ”§ Database

Migrations:

cd backend && encore db reset --all    # Reset dev cluster
cd backend && encore db shell db       # Shell access
cd backend && encore db migrate        # Run migrations

Test Cluster:

cd backend && encore db reset --all --test
cd backend && encore db shell db --test

πŸ› Troubleshooting

Port conflicts:

lsof -ti:4000 | xargs kill    # Backend
lsof -ti:5173 | xargs kill    # Frontend

Database issues:

cd backend && encore db reset --all

Frontend sync errors:

cd frontend
rm -rf .svelte-kit node_modules
bun install
bunx svelte-kit sync
bun run dev

πŸ“€ Deployment

Backend (Encore Cloud):

encore auth login
git push encore main

Dashboard: https://app.encore.cloud/steering-wheel-documentation-65b2

Frontend (Vercel):

cd frontend && vercel --prod

Set env: PUBLIC_API_BASE=https://steering-wheel-documentation-65b2.encr.app


πŸ” Secrets

Backend:

encore secret set --type prod SecretName
encore secret list

Frontend: Vercel Dashboard β†’ Settings β†’ Environment Variables


πŸ“Š Monitoring

Backend:

Frontend:


🎯 Status

βœ… Completed:

  • Agent orchestration (XState machine)
  • Structured logging (module/actor)
  • Type-safe APIs (Encore generated clients)
  • Event sourcing + snapshots
  • Run lifecycle (start/cancel/stream)

🟑 In Progress:

  • Node handler implementation
  • Main loop (Perceive β†’ Act β†’ Verify)
  • Graph projection service

⏳ Upcoming:

  • LLM integration for action selection
  • Graph visualization UI
  • Multi-policy exploration
  • Analytics overlay

πŸ“š Resources

Framework Docs:

Project Docs:

  • CLAUDE.md - Commands + quick reference
  • .cursor/rules/ - Coding standards
  • backend/agent/CLAUDE.md - Agent architecture
  • backend/graph/README.md - Graph implementation
  • backend/API_DOCUMENTATION.md - Complete API reference

External:


🀝 Contributing

Git Workflow:

git checkout -b feature/my-feature
# ... make changes ...
git commit -m "feat: description"
git push origin feature/my-feature

Standards:

  • Backend: Encore.ts conventions
  • Frontend: Svelte 5 runes ($state, $derived, $effect)
  • TypeScript: Strict mode, no any
  • Testing: All tests passing before PR

πŸ“ License

[Your License Here]


ScreenGraph - Autonomous UX mapping for mobile apps.

For detailed commands: CLAUDE.md
For coding standards: .cursor/rules/founder_rules.mdc