How nuanceaidev/ranksphere works
1. Overall shape
- This is a client-side React SPA built with Vite, TypeScript, Tailwind CSS, and shipped as static files in dist/.
- There is no custom backend server in the repo. The app talks directly to Supabase for data/storage and to ValueSERP for live rank checks.
2. Application shell
- src/App.tsx is the top-level composition point.
- Sidebar appears to drive navigation and client selection, while the main workspace swaps between dashboard sections like Overview, Keywords, Rankings, Analytics.
- ThemeContext provides the dark/light mode boundary across the app.
3. UI subsystem boundaries
- src/components/ is organized by domain responsibility:
- ClientModal and DeleteConfirmModal handle client CRUD interactions.
- Keywords manages keyword entry and CSV import.
- Rankings and RankTypeToggle present rank comparison and filtering.
- Overview and Analytics present summary/reporting views.
- Sidebar is the primary navigation/control surface.
- These components are mostly orchestration and presentation over shared data.
4. Data access layer
- src/lib/supabase.ts is the single integration point for the database/storage client.
- src/lib/valueserp.ts is the dedicated integration for external rank lookup requests.
- src/types/index.ts defines the shared domain model used across components, keeping UI, API results, and database records aligned.
5. Persistent data model
- The Supabase migrations under supabase/migrations/ are the source of truth for schema.
- The core entities described by the README are:
- clients: name, domain, industry
- keywords: keyword records with monthly rank snapshots
- The architecture is centered on client-owned keyword sets rather than a global keyword list.
6. Keyword ranking flow
- Keywords can be added manually or via CSV upload in the UI.
- Importantly, keyword creation is decoupled from rank fetching: new keywords are stored first, and live rank data is fetched later.
- The “Fetch Ranks” workflow calls ValueSERP once per keyword, with a deliberate delay between calls to avoid API limits and duplicate work.
- The resulting monthly snapshot updates power the comparison views in Rankings/Overview.
7. Analytics screenshots flow
- Analytics handles uploading screenshots such as GA4 or GBP images.
- Files are stored in Supabase Storage in an analytics_screenshots bucket, organized by a client/month path pattern.
- The bucket is intended to be publicly readable so the images can be embedded into generated reports.
- The README also describes storage lifecycle cleanup, making screenshots effectively temporary report inputs.
8. Reporting flow
- The reporting feature combines data from three sources: client metadata, keyword ranking snapshots, and analytics screenshots.
- Reports are generated as PDFs in the browser using the bundled PDF/image tooling implied by the build output and README.
- The report output includes summary metrics, rank deltas, and screenshots only when those screenshots exist for the selected month.
9. External dependencies and deployment boundaries
- Supabase is the persistence boundary: PostgreSQL for structured data and Storage for binary assets.
- ValueSERP is the only external live-search/ranking data source.
- The app is configured through environment variables in .env / .env.example, including the Supabase connection and VITE_VALUESERP_API_KEY.
- vite.config.ts, tailwind.config.js, postcss.config.js, and eslint.config.js indicate a standard frontend build/tooling pipeline, with dist/ holding the deployable static artifact.
10. What to show in an architecture diagram
- Draw the browser app as the center.
- Connect it to:
- Supabase Postgres for clients and keywords
- Supabase Storage for analytics screenshots
- ValueSERP API for rank lookups
- Show client-side report generation inside the app, consuming database records plus storage assets.
- Keep the main domain boundary around client → keywords → rankings → analytics → report generation.
Main entry points: App.tsx App shell · supabase.ts Supabase client · index.ts Domain types · Rankings.tsx Rankings
Components 19
Browser app
Client-side React workspace and shell
UI features
Domain-oriented presentation and interaction components
- Sidebar · Client selection and primary navigation
src/components/Sidebar.tsx - Overview · Summary metrics and high-level status
src/components/Overview.tsx - Keywords · Keyword entry and CSV import
src/components/Keywords.tsx - Rankings · Rank snapshots, deltas, and filters
src/components/Rankings.tsx - Rank toggle · Switches rank comparison modes
src/components/RankTypeToggle.tsx - Analytics · Screenshot upload and report assets
src/components/Analytics.tsx - Client modal · Create and edit client records
src/components/ClientModal.tsx - Delete confirm · Confirms removals
src/components/DeleteConfirmModal.tsx
Data layer
Shared types and service integrations
- Domain types · Shared client and keyword shapes
src/types/index.ts - Supabase client · Single integration point for persistence
src/lib/supabase.ts - ValueSERP client · Fetches live rank results
src/lib/valueserp.ts
Persistence
Database schema and storage boundaries
- Migrations · Postgres schema and data model migrations
- Screenshots bucket · Public analytics screenshot assets
supabase/storage/README.md - Supabase Postgres · Structured storage for clients and keywords
- ValueSERP API · Live search ranking source
Connections 26
- Entry → App shell: bootstraps · Entry mounts the application shell
- App shell → Theme: wraps · Theme context spans the SPA
- App shell → Sidebar: navigates · Sidebar drives client and section switching
- App shell → Overview: shows · Overview is one workspace section
- App shell → Keywords: shows · Keywords section manages keyword data
- App shell → Rankings: shows · Rankings compares monthly snapshots
- App shell → Analytics: shows · Analytics handles screenshot/report inputs
- App shell → Client modal: opens · Client CRUD flows use modal forms
- App shell → Delete confirm: confirms · Destructive actions use confirmation dialog
- Rankings → Rank toggle: filters · Rankings uses toggle controls for comparisons
- Keywords → Domain types: uses · Keyword and client shapes stay aligned
- Rankings → Domain types: uses · Rank snapshots consume shared domain types
- Analytics → Domain types: uses · Screenshot metadata is typed through the shared model
- Overview → Domain types: uses · Summary views are built on shared entities
- App shell → Supabase client: reads/writes · UI persists clients, keywords, and assets through Supabase
- Keywords → Supabase client: stores · Keyword creation and import persist first
- Analytics → Supabase client: uploads · Screenshots are stored in Supabase Storage
- Supabase client → Supabase Postgres: connects · Structured app data lives in Postgres
- Supabase client → Screenshots bucket: connects · Binary report inputs live in object storage
- Migrations → Supabase Postgres: defines · Migrations are the source of truth for schema
- Rankings → ValueSERP client: fetches · Rank checks query the live external API
- ValueSERP client → ValueSERP API: calls · External ranking lookups happen per keyword
- Report builder → Supabase client: reads · Report generation consumes stored client and keyword data
- Report builder → Screenshots bucket: embeds · Reports include available screenshots for the month
- Report builder → Domain types: uses · Report assembly shares the same domain model
- App shell → Report builder: exports · Browser-side PDF generation is part of the workspace