# miriyalajayanth-19/vidhi_sahayak architecture

> Architecture diagram of the GitHub repository miriyalajayanth-19/vidhi_sahayak, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miriyalajayanth-19/vidhi_sahayak
- Repository: https://github.com/miriyalajayanth-19/vidhi_sahayak

## Overview

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: [`src/app/page.tsx`](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/page.tsx) (Landing), [`src/app/categories/page.tsx`](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/categories/page.tsx) (Discovery), [`src/app/chat/page.tsx`](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/chat/page.tsx) (AI chat), [`src/lib/lawyers.ts`](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/lawyers.ts) (Lawyers data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App routes"]
  node_node_layout["App shell<br/>layout/styling<br/>[layout.tsx]"]
  node_node_home["Landing<br/>route page<br/>[page.tsx]"]
  node_node_discovery["Discovery<br/>routes<br/>[page.tsx]"]
  node_node_chat["AI chat<br/>route page<br/>[page.tsx]"]
  node_node_documents["Documents<br/>routes<br/>[page.tsx]"]
  node_node_consultation["Consultation<br/>routes<br/>[page.tsx]"]
  node_node_auth["Auth flow<br/>routes<br/>[page.tsx]"]
  node_node_onboarding["Onboarding<br/>role setup<br/>[page.tsx]"]
  node_node_dashboard["Dashboard<br/>workspace routes<br/>[page.tsx]"]
  node_node_user_dash["User space<br/>dashboard<br/>[page.tsx]"]
  node_node_lawyer_dash["Lawyer space<br/>dashboard<br/>[page.tsx]"]
  node_node_lawyer_ops["Lawyer ops<br/>dashboard subroutes<br/>[page.tsx]"]
  node_node_api_chat["Chat API<br/>route handler<br/>[route.ts]"]
  node_node_api_lawyers["Lawyers API<br/>route handler<br/>[route.ts]"]
  node_node_api_tts["TTS API<br/>route handler<br/>[route.ts]"]
end

subgraph group_group_domain["Domain data"]
  node_node_categories_lib["Categories<br/>content model<br/>[categories.ts]"]
  node_node_guidance_lib["Guidance<br/>domain logic<br/>[guidance.ts]"]
  node_node_lawyers_lib["Lawyers data<br/>domain model<br/>[lawyers.ts]"]
  node_node_types_lib["Shared types<br/>[types.ts]"]
  node_node_supabase[("Supabase<br/>client setup<br/>[supabase.ts]")]
end

subgraph group_group_components["UI components"]
  node_node_shell_ui["Shell UI<br/>shared components<br/>[navbar.tsx]"]
  node_node_ai_ui["AI widgets<br/>interactive ui<br/>[ai-chat-widget.tsx]"]
  node_node_voice_ui["Voice search<br/>interactive ui<br/>[voice-search.tsx]"]
end

node_node_layout -->|"uses"| node_node_shell_ui
node_node_layout -->|"wraps"| node_node_home
node_node_home -->|"routes to"| node_node_discovery
node_node_home -->|"routes to"| node_node_chat
node_node_home -->|"routes to"| node_node_documents
node_node_home -->|"routes to"| node_node_consultation
node_node_discovery -->|"reads"| node_node_categories_lib
node_node_discovery -->|"reads"| node_node_lawyers_lib
node_node_discovery -->|"enhanced by"| node_node_voice_ui
node_node_chat -->|"uses"| node_node_ai_ui
node_node_chat -->|"calls"| node_node_api_chat
node_node_chat -->|"reads"| node_node_guidance_lib
node_node_documents -->|"uses"| node_node_types_lib
node_node_consultation -->|"uses"| node_node_lawyers_lib
node_node_auth -->|"authenticates"| node_node_supabase
node_node_onboarding -->|"uses"| node_node_types_lib
node_node_dashboard -->|"splits to"| node_node_user_dash
node_node_dashboard -->|"splits to"| node_node_lawyer_dash
node_node_lawyer_dash -->|"expands to"| node_node_lawyer_ops
node_node_lawyer_ops -->|"uses"| node_node_lawyers_lib
node_node_lawyer_ops -->|"persists via"| node_node_supabase
node_node_api_lawyers -->|"reads"| node_node_lawyers_lib
node_node_api_chat -->|"uses"| node_node_guidance_lib
node_node_api_chat -.->|"persists via"| node_node_supabase
node_node_api_tts -->|"supports"| node_node_voice_ui
node_node_api_tts -.->|"integrates with"| node_node_supabase
node_node_shell_ui -->|"navigates"| node_node_home
node_node_shell_ui -->|"navigates"| node_node_dashboard

click node_node_layout "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/layout.tsx"
click node_node_home "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/page.tsx"
click node_node_discovery "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/categories/page.tsx"
click node_node_chat "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/chat/page.tsx"
click node_node_documents "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/documents/page.tsx"
click node_node_consultation "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/consultation/page.tsx"
click node_node_auth "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/auth/signin/page.tsx"
click node_node_onboarding "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/onboarding/user/page.tsx"
click node_node_dashboard "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/page.tsx"
click node_node_user_dash "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/user/page.tsx"
click node_node_lawyer_dash "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/lawyer/page.tsx"
click node_node_lawyer_ops "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/lawyer/cases/page.tsx"
click node_node_api_chat "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/chat/route.ts"
click node_node_api_lawyers "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/lawyers/route.ts"
click node_node_api_tts "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/tts/route.ts"
click node_node_categories_lib "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/categories.ts"
click node_node_guidance_lib "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/guidance.ts"
click node_node_lawyers_lib "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/lawyers.ts"
click node_node_types_lib "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/types.ts"
click node_node_supabase "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/supabase.ts"
click node_node_shell_ui "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/navbar.tsx"
click node_node_ai_ui "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/ai-chat-widget.tsx"
click node_node_voice_ui "https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/voice-search.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_layout,node_node_home,node_node_discovery,node_node_chat,node_node_documents,node_node_consultation,node_node_auth,node_node_onboarding,node_node_dashboard,node_node_user_dash,node_node_lawyer_dash,node_node_lawyer_ops,node_node_api_chat,node_node_api_lawyers,node_node_api_tts toneBlue
class node_node_categories_lib,node_node_guidance_lib,node_node_lawyers_lib,node_node_types_lib,node_node_supabase toneAmber
class node_node_shell_ui,node_node_ai_ui,node_node_voice_ui toneMint
```

## Components

### App routes

Next.js App Router pages and route handlers

- [App shell](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/layout.tsx): layout/styling · Global layout and styles for the app · `src/app/layout.tsx`
- [Landing](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/page.tsx): route page · Public entry page and primary navigation hub · `src/app/page.tsx`
- [Discovery](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/categories/page.tsx): routes · Category browsing, search, lawyer listing, and templates · `src/app/categories/page.tsx`
- [AI chat](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/chat/page.tsx): route page · Legal question and assistant interaction surface · `src/app/chat/page.tsx`
- [Documents](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/documents/page.tsx): routes · Document templates, generation, and detail pages · `src/app/documents/page.tsx`
- [Consultation](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/consultation/page.tsx): routes · Consultation browsing and booking flow · `src/app/consultation/page.tsx`
- [Auth flow](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/auth/signin/page.tsx): routes · Signin, signup, and auth callback handling · `src/app/auth/signin/page.tsx`
- [Onboarding](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/onboarding/user/page.tsx): role setup · Post-signup onboarding for user, lawyer, and consultant roles · `src/app/onboarding/user/page.tsx`
- [Dashboard](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/page.tsx): workspace routes · Entry point for user and lawyer dashboards · `src/app/dashboard/page.tsx`
- [User space](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/user/page.tsx): dashboard · User dashboard home · `src/app/dashboard/user/page.tsx`
- [Lawyer space](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/lawyer/page.tsx): dashboard · Lawyer dashboard home and management area · `src/app/dashboard/lawyer/page.tsx`
- [Lawyer ops](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/dashboard/lawyer/cases/page.tsx): dashboard subroutes · Cases, invoices, payments, profile, and verification · `src/app/dashboard/lawyer/cases/page.tsx`
- [Chat API](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/chat/route.ts): route handler · Backend handler for AI/legal chat requests · `src/app/api/chat/route.ts`
- [Lawyers API](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/lawyers/route.ts): route handler · Backend handler for lawyer data access · `src/app/api/lawyers/route.ts`
- [TTS API](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/app/api/tts/route.ts): route handler · Backend handler for text-to-speech generation · `src/app/api/tts/route.ts`

### Domain data

Shared legal content, types, and Supabase helpers

- [Categories](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/categories.ts): content model · Legal category content and navigation data · `src/lib/categories.ts`
- [Guidance](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/guidance.ts): domain logic · Legal help content and response scaffolding · `src/lib/guidance.ts`
- [Lawyers data](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/lawyers.ts): domain model · Lawyer listings, profiles, and related data helpers · `src/lib/lawyers.ts`
- [Shared types](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/types.ts): types · Cross-app TypeScript models · `src/lib/types.ts`
- [Supabase](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/lib/supabase.ts): client setup · Browser, server, and shared Supabase client configuration · `src/lib/supabase.ts`

### UI components

Reusable interactive shell and AI/voice widgets

- [Shell UI](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/navbar.tsx): shared components · Navbar and footer shared across routes · `src/components/navbar.tsx`
- [AI widgets](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/ai-chat-widget.tsx): interactive ui · Chat widget and inline voice assistant · `src/components/ai-chat-widget.tsx`
- [Voice search](https://github.com/miriyalajayanth-19/vidhi_sahayak/blob/main/src/components/voice-search.tsx): interactive ui · Voice-assisted search interaction · `src/components/voice-search.tsx`

## Connections

- 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
