How nishal77/localseobot works
1. This repository is a Next.js App Router application that combines a customer-facing dashboard with a substantial server-side API and a separate background worker layer. It is not just a UI app; it behaves like a SaaS backend/frontend monolith plus async job runner.
2. The browser-facing surface lives under src/app. There are public/auth pages (/, /login, /signup), an onboarding flow, and the authenticated dashboard area with sections for citations, posts, rankings, reports, reviews, and settings. src/app/layout.tsx, src/app/globals.css, and the shared UI components support the overall shell.
3. The backend is exposed through many route handlers in src/app/api, organized by domain rather than by generic CRUD. The main API boundaries are auth, onboarding, dashboard metrics, citations, posts, rankings, reports, reviews, settings, billing, and webhooks. This structure suggests the frontend mostly talks to its own internal API rather than directly to database or external services.
4. Persistence is centralized through Prisma. prisma/schema.prisma, prisma.config.ts, src/lib/prisma.ts, and prisma/seed.ts indicate a relational database as the system of record for users, businesses, content, reports, rankings, reviews, and job state. The rest of the app appears to treat Prisma as the shared data access boundary.
5. There is a distinct asynchronous processing subsystem under workers/. workers/index.ts, workers/scheduler.ts, and the processor files show queued or scheduled background jobs for report generation, review polling/responding, ranking checks, competitor monitoring, onboarding audits, citation submission, and GBP post generation/publishing. This is the main non-request-driven execution path in the architecture.
6. The product domain appears centered on local SEO / reputation management. The dashboard sections and worker names point to business-profile management, review handling, ranking tracking, citation building, and content/post automation. The app likely aggregates data from external sources into internal reports and operational workflows.
7. Google Business Profile is a key external integration. The onboarding and settings routes for GBP connect/callback/reconnect, plus post generation/publishing and review workflows, imply OAuth-style connection management and ongoing API access to a business’s profile. This integration is likely one of the main reasons the system needs both webhooks and background jobs.
8. Billing and account lifecycle are handled separately from the core product flows. src/app/api/billing/* and src/app/api/webhooks/whop/route.ts indicate an external billing platform integration, likely used to activate, suspend, or provision access. The settings/billing dashboard page is the user-facing boundary for that subsystem.
9. Authentication is handled with NextAuth. src/auth.ts and src/app/api/auth/[...nextauth]/route.ts define the session/auth boundary, while src/middleware.ts likely protects dashboard and API routes. Signup is custom (/api/auth/signup), suggesting the app may blend credentials and provider-based auth.
10. AI-assisted generation is a notable service dependency. src/lib/anthropic.ts implies the app uses Anthropic to generate or assist with content such as GBP posts, reports, or response drafts. That AI layer is probably invoked from workers or server routes rather than directly from the client.
11. Supporting libraries show the main shared runtime boundaries: src/lib/queue.ts for async dispatch, src/lib/gbp.ts for profile API interactions, src/lib/audit.ts for onboarding checks, src/lib/crypto.ts for sensitive data handling, and src/lib/utils.ts for shared helpers. These are the glue between request handlers, workers, and external APIs.
12. The UI is built from a small custom component set plus reusable dashboard widgets. src/components/ui/* provides the design system primitives, while src/components/dashboard/* contains page-specific controls like bot settings, post actions, and the sidebar. This keeps presentation concerns separate from the domain/API logic.
13. Overall data flow is: user logs in, completes onboarding, connects GBP and billing, then the dashboard reads from internal APIs backed by Prisma. Scheduled or queued workers continuously fetch, generate, or update domain data, and the dashboard surfaces the latest state and history. Webhooks and callback routes are used where external systems need to push state back into the app.
Main entry points: prisma.ts Prisma · layout.tsx Dashboard shell · index.ts Worker runtime · queue.ts Job queue
Components 29
Frontend
Browser app, shared shell, and dashboard UI
- App shell · Root layout and global app chrome
src/app/layout.tsx - Public pages · Homepage plus login and signup surfaces
src/app/page.tsx - Dashboard shell · Protected dashboard layout and navigation
src/app/dashboard/layout.tsx - Onboarding · User onboarding entry point
src/app/onboarding/page.tsx - UI kit · Reusable primitives for forms and layout
src/components/ui/button.tsx - Dashboard widgets · Custom dashboard controls and sidebar
src/components/dashboard/sidebar.tsx
API
Route handlers organized by product domain
- Auth API · NextAuth session and signup endpoints
src/app/api/auth/[...nextauth]/route.ts - Onboarding API · Business setup, GBP connect, and completion routes
src/app/api/onboarding/complete/route.ts - Dashboard API · Overview and activity data for the dashboard
src/app/api/dashboard/overview/route.ts - Citations API · Citation inventory, stats, and retry flows
src/app/api/citations/route.ts - Posts API · Post listing, approval, and status routes
src/app/api/posts/route.ts - Rankings API · Keyword tracking and history routes
src/app/api/rankings/route.ts - Reports API · Report generation and retrieval routes
src/app/api/reports/route.ts - Reviews API · Review polling, approval, and response routes
src/app/api/reviews/route.ts - Settings API · Business, GBP, bot, and billing settings surface
src/app/api/settings/route.ts - Webhooks · Inbound events from billing and content workflows
src/app/api/webhooks/whop/route.ts
Core services
Shared runtime libraries and persistence
- Prisma · Database gateway and shared models
src/lib/prisma.ts - Job queue · Shared queue boundary between routes and workers
src/lib/queue.ts - GBP client · Integration for business profile operations
src/lib/gbp.ts - AI client · Anthropic-powered drafting and generation
src/lib/anthropic.ts - Audit helpers · Onboarding and account state validation
src/lib/audit.ts - Crypto · Sensitive token and credential utilities
src/lib/crypto.ts
Workers
Background execution and scheduled jobs
- Worker runtime · Background worker entrypoint and processor wiring
workers/index.ts - Scheduler · Timed triggers for recurring background work
workers/scheduler.ts - Report jobs · Generate and send reports in the background
workers/processors/report-generate.ts - Review jobs · Poll, draft, and respond to reviews
workers/processors/review-poll.ts - Ranking jobs · Keyword and competitor monitoring jobs
workers/processors/ranking-check.ts - Post jobs · Generate and publish GBP posts
workers/processors/gbp-post-generate.ts - Citation jobs · Batch citation submission and retry work
workers/processors/citation-submit-batch.ts
Connections 48
- App shell → Public pages: renders · Root shell frames public routes
- App shell → Dashboard shell: wraps · Root shell contains the authenticated area
- Dashboard shell → Dashboard widgets: uses · Dashboard layout composes reusable controls
- Public pages → Auth API: auth flow · Login and signup rely on session endpoints
- Onboarding → Onboarding API: submits · Setup flow posts business and GBP data
- Dashboard shell → Dashboard API: loads · Dashboard screens read overview and activity data
- Dashboard shell → Citations API: loads · Citations page reads citation state
- Dashboard shell → Posts API: loads · Posts page reads and approves content
- Dashboard shell → Rankings API: loads · Rankings page reads tracking data
- Dashboard shell → Reports API: loads · Reports page reads generated reports
- Dashboard shell → Reviews API: loads · Reviews page reads review state and drafts
- Dashboard shell → Settings API: loads · Settings pages manage account and integration state
- Auth API → Prisma: reads/writes · Session and signup state is persisted
- Auth API → Crypto: secures · Credential handling uses shared crypto utilities
- Onboarding API → Prisma: reads/writes · Stores business and onboarding progress
- Onboarding API → GBP client: connects · Starts and completes GBP linkage
- Onboarding API → Audit helpers: validates · Runs onboarding checks and audit results
- Onboarding API → Job queue: enqueues · Can trigger downstream async setup work
- Dashboard API → Prisma: reads · Aggregates product state from the database
- Citations API → Prisma: reads/writes · Tracks citation records and retry status
- Citations API → Job queue: enqueues · Schedules citation submission jobs
- Posts API → Prisma: reads/writes · Persists posts and approval state
- Posts API → Job queue: enqueues · Sends post work to background processing
- Posts API → AI client: generates · Uses AI for drafting and content assistance
- Posts API → GBP client: publishes · Posts are sent to Google Business Profile
- Rankings API → Prisma: reads/writes · Stores keyword tracking and history
- Reports API → Prisma: reads/writes · Persists report results and snapshots
- Reports API → Job queue: enqueues · Report generation is dispatched asynchronously
- Reports API → AI client: generates · AI may assist with report drafting
- Reviews API → Prisma: reads/writes · Stores reviews, approvals, and responses
- Reviews API → GBP client: syncs · Talks to GBP for review operations
- Reviews API → Job queue: enqueues · Review response work can be deferred
- Settings API → Prisma: reads/writes · Persists business, bot, and billing settings
- Settings API → GBP client: reconnects · Manages GBP reconnect and profile settings
- Webhooks → Prisma: updates · External events update internal account state
- Webhooks → Job queue: triggers · Webhook events may kick off background work
- Job queue → Worker runtime: consumed by · Queued jobs are picked up by workers
- Scheduler → Worker runtime: starts · Scheduler feeds the worker process
- Worker runtime → Report jobs: runs · Worker executes report generation jobs
- Worker runtime → Review jobs: runs · Worker executes review polling and response jobs
- Worker runtime → Ranking jobs: runs · Worker executes ranking and competitor checks
- Worker runtime → Post jobs: runs · Worker executes GBP content jobs
- Worker runtime → Citation jobs: runs · Worker executes citation submission jobs
- Report jobs → Prisma: reads/writes · Reports are assembled from stored domain data
- Report jobs → AI client: generates · Report content can be AI-assisted
- Review jobs → Prisma: reads/writes · Review processing updates stored records
- Review jobs → GBP client: syncs · Polls and responds through GBP
- Ranking jobs → Prisma: reads/writes · Ranking snapshots and history are persisted