How miriyalajayanth-19/vidhi_sahayak works
1. Overall shape
VidhiSahayak is a Next.js App Router application that mixes static content pages, interactive client components, and a small server-side API layer. The repo is organized around legal-domain experiences: AI chat, lawyer discovery/consultation, document generation, and onboarding/dashboard flows for different user roles.
2. Presentation layer: src/app
The main UI lives in route-based pages under src/app. This includes the public landing pages, legal category browsing, search, chat, documents, support, privacy/terms, and role-specific onboarding and dashboards. Because it uses App Router, each folder is a route boundary, and many pages are likely composed of shared layout pieces plus route-specific content.
3. Public user journeys
The visible product flows are:
• landing and discovery via src/app/page.tsx, categories, search, and lawyers
• AI assistance via src/app/chat
• document creation via src/app/documents
• consultation booking via src/app/consultation
These are the primary end-user paths and likely feed into one another, for example browsing categories or lawyers before initiating chat or booking.
4. Domain-specific dashboard split
There is a clear separation between dashboard/user and dashboard/lawyer. The lawyer side is much richer, with subpages for cases, invoices, payments, profile, and verification. This suggests the architecture is intended to support multiple roles, with different capabilities and workspaces rather than a single generic dashboard.
5. Server API boundary
The server API is concentrated under src/app/api with three routes:
• api/chat for AI/legal question handling
• api/lawyers for lawyer data access
• api/tts for text-to-speech generation
This indicates the app uses Next.js route handlers as the backend boundary, with the client UI calling these endpoints instead of talking directly to external AI or speech services.
6. Shared domain/data layer
Reusable business data and helpers live in src/lib. The important modules are:
• categories.ts for legal category content/navigation
• guidance.ts for legal help content or response scaffolding
• lawyers.ts for lawyer listings/profile data
• types.ts for shared TypeScript models
• lang-utils.ts and utils.ts for text/localization/general helpers
• supabase-browser.ts, supabase-server.ts, and supabase.ts for database client setup
This layer is the main boundary between UI/routes and data/domain logic.
7. AI and voice features
The repo includes dedicated client components for AI and audio experiences:
• ai-chat-widget.tsx
• inline-voice-assistant.tsx
• voice-search.tsx
These likely connect to the chat and TTS API routes, and the README shows AI providers and voice APIs are environment-driven. Architecturally, AI and voice are optional service integrations rather than core storage features.
8. Authentication and onboarding flow
There is an auth section under src/app/auth with signin, signup, and callback handling, plus role-based onboarding under src/app/onboarding/{user,lawyer,consultant}. This suggests auth is designed around post-signup role selection and redirect handling, with the callback route acting as the external auth provider handshake boundary.
9. Styling and shared shell
Global styling is handled by src/app/globals.css, with shared layout in src/app/layout.tsx. The app also has common shell components such as navbar.tsx and footer.tsx. The README and config files indicate Tailwind CSS and shadcn/ui are the main UI system, so most UI composition is utility-class based with reusable component primitives.
10. Operational boundaries and external services
The repo is configured for environment-driven integrations rather than hardcoded infrastructure. The README lists required/optional keys for Gemini, Supabase, OpenAI, Perplexity, and Google TTS, which means the deployment shape depends on those services being available. supabase.schema.sql shows the database schema is part of the repo, but the README frames Supabase as an evolving persistence/auth layer rather than the only current data source.
11. Request handling and cross-cutting control
The presence of proxy.ts implies there is some request-level interception or routing control, likely for auth guards, redirects, or feature gating. In an architecture diagram, this should sit in front of protected dashboard/auth routes as a cross-cutting boundary rather than as a business subsystem.
12. Current maturity
This is a product-oriented scaffold with strong route structure and feature surfaces, but some subsystems are clearly still evolving. The roadmap explicitly calls out fuller auth/roles, persistent Supabase-backed data, payments, and retrieval-enhanced AI chat. So the diagram should treat several areas as present-but-partial, especially around persistence and payment/workflow automation.
Main entry points: app/page.tsx Landing · categories/page.tsx Discovery · chat/page.tsx AI chat · lawyers.ts Lawyers data
Components 23
App routes
Next.js App Router pages and route handlers
- App shell · Global layout and styles for the app
src/app/layout.tsx - Landing · Public entry page and primary navigation hub
src/app/page.tsx - Discovery · Category browsing, search, lawyer listing, and templates
src/app/categories/page.tsx - AI chat · Legal question and assistant interaction surface
src/app/chat/page.tsx - Documents · Document templates, generation, and detail pages
src/app/documents/page.tsx - Consultation · Consultation browsing and booking flow
src/app/consultation/page.tsx - Auth flow · Signin, signup, and auth callback handling
src/app/auth/signin/page.tsx - Onboarding · Post-signup onboarding for user, lawyer, and consultant roles
src/app/onboarding/user/page.tsx - Dashboard · Entry point for user and lawyer dashboards
src/app/dashboard/page.tsx - User space · User dashboard home
src/app/dashboard/user/page.tsx - Lawyer space · Lawyer dashboard home and management area
src/app/dashboard/lawyer/page.tsx - Lawyer ops · Cases, invoices, payments, profile, and verification
src/app/dashboard/lawyer/cases/page.tsx - Chat API · Backend handler for AI/legal chat requests
src/app/api/chat/route.ts - Lawyers API · Backend handler for lawyer data access
src/app/api/lawyers/route.ts - TTS API · Backend handler for text-to-speech generation
src/app/api/tts/route.ts
Domain data
Shared legal content, types, and Supabase helpers
- Categories · Legal category content and navigation data
src/lib/categories.ts - Guidance · Legal help content and response scaffolding
src/lib/guidance.ts - Lawyers data · Lawyer listings, profiles, and related data helpers
src/lib/lawyers.ts - Shared types · Cross-app TypeScript models
src/lib/types.ts - Supabase · Browser, server, and shared Supabase client configuration
src/lib/supabase.ts
UI components
Reusable interactive shell and AI/voice widgets
- Shell UI · Navbar and footer shared across routes
src/components/navbar.tsx - AI widgets · Chat widget and inline voice assistant
src/components/ai-chat-widget.tsx - Voice search · Voice-assisted search interaction
src/components/voice-search.tsx
Connections 28
- App shell → Shell UI: uses · Shared frame composes navigation and footer
- App shell → Landing: wraps · App shell wraps public pages and route content
- Landing → Discovery: routes to · Landing leads into browsing and search flows
- Landing → AI chat: routes to · Landing exposes AI help entry
- Landing → Documents: routes to · Landing exposes document creation
- Landing → Consultation: routes to · Landing exposes consultation booking
- Discovery → Categories: reads · Discovery pages are driven by category content
- Discovery → Lawyers data: reads · Lawyer browsing uses lawyer domain data
- Discovery → Voice search: enhanced by · Search and discovery can use voice input
- AI chat → AI widgets: uses · Chat page embeds assistant UI
- AI chat → Chat API: calls · Client chat delegates to backend route handler
- AI chat → Guidance: reads · Chat response scaffolding comes from guidance data
- Documents → Shared types: uses · Document flows share typed models
- Consultation → Lawyers data: uses · Booking flow depends on lawyer availability/data
- Auth flow → Supabase: authenticates · Auth routes rely on Supabase client setup
- Onboarding → Shared types: uses · Role onboarding is shaped by shared types
- Dashboard → User space: splits to · User dashboard branch
- Dashboard → Lawyer space: splits to · Lawyer dashboard branch
- Lawyer space → Lawyer ops: expands to · Lawyer workspace includes operational subpages
- Lawyer ops → Lawyers data: uses · Lawyer workspace consumes lawyer domain data
- Lawyer ops → Supabase: persists via · Operational workflows are expected to use Supabase storage
- Lawyers API → Lawyers data: reads · Lawyers API is backed by lawyer data helpers
- Chat API → Guidance: uses · Chat backend likely assembles responses from guidance content
- Chat API → Supabase: persists via · Chat backend can rely on shared persistence/auth layer
- TTS API → Voice search: supports · Voice features consume synthesized audio
- TTS API → Supabase: integrates with · TTS integration is configured through shared service setup
- Shell UI → Landing: navigates · Global shell links into top-level journeys
- Shell UI → Dashboard: navigates · Global shell links to authenticated areas