# gani-sma/fie architecture

> Architecture diagram of the GitHub repository gani-sma/fie, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gani-sma/fie
- Repository: https://github.com/gani-sma/fie

## Overview

ENACT is a browser-based Indian legal assistant. Users enter through the routed React app, authenticate if needed, ask questions in chat, receive AI guidance, and can revisit conversation history. The repository also exposes results and case-tracking pages and conversation export/PDF utilities. The README documents provider fallback and legal-code grounding, but those implementations were not sampled; the legal-chat function and provider connections are therefore shown at the documented level only.

Main entry points: [`src/App.tsx`](https://github.com/gani-sma/fie/blob/main/src/App.tsx) (App Router), [`src/pages/Chat.tsx`](https://github.com/gani-sma/fie/blob/main/src/pages/Chat.tsx) (Chat Page), [`src/integrations/supabase/client.ts`](https://github.com/gani-sma/fie/blob/main/src/integrations/supabase/client.ts) (Supabase Client), [`supabase/functions/legal-chat/index.ts`](https://github.com/gani-sma/fie/blob/main/supabase/functions/legal-chat/index.ts) (Legal Chat Function)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["App Router<br/>[App.tsx]"]
  node_home["Home<br/>[Home.tsx]"]
  node_auth["Authentication<br/>[Auth.tsx]"]
  node_results["Results<br/>[Results.tsx]"]
  node_case["Case Tracking<br/>[CaseTracking.tsx]"]
end

subgraph group_chat["Chat and History"]
  node_chat["Chat Page<br/>[Chat.tsx]"]
  node_chatui["Chat Interface<br/>[ChatInput.tsx]"]
  node_voice["Voice Input<br/>[useVoiceInput.ts]"]
  node_messages["Message State<br/>[useMessages.ts]"]
  node_conversations["Conversation State"]
  node_repository["Conversation Repository"]
end

subgraph group_services["Backend Services"]
  node_legalfn["Legal Chat Function<br/>[index.ts]"]
  node_supabaseclient["Supabase Client<br/>[client.ts]"]
  node_database[("Supabase Database")]
end

subgraph group_support["Product Support"]
  node_export["Conversation Export"]
  node_pdf["PDF Generator<br/>[pdfGenerator.ts]"]
  node_i18n["Localization<br/>[config.ts]"]
end

node_user(("User"))
node_groq{{"Groq AI"}}
node_gemini{{"Gemini AI"}}
node_openrouter{{"OpenRouter AI"}}

node_user -->|"opens"| node_app
node_app -->|"routes"| node_home
node_app -->|"routes"| node_auth
node_app -->|"routes"| node_results
node_app -->|"routes"| node_case
node_app -->|"routes"| node_chat
node_auth -->|"authenticates via"| node_supabaseclient
node_chat -->|"renders"| node_chatui
node_chat -->|"uses"| node_voice
node_chat -->|"manages messages"| node_messages
node_chat -->|"manages history"| node_conversations
node_chat -->|"requests guidance"| node_legalfn
node_legalfn -->|"inference"| node_groq
node_legalfn -.->|"fallback inference"| node_gemini
node_legalfn -.->|"fallback inference"| node_openrouter
node_messages -->|"reads and writes"| node_supabaseclient
node_conversations -->|"reads and writes"| node_supabaseclient
node_repository -->|"queries"| node_supabaseclient
node_supabaseclient -->|"accesses"| node_database
node_chat -->|"exports"| node_export
node_export -->|"generates PDF"| node_pdf
node_app -->|"uses translations"| node_i18n

click node_app "https://github.com/gani-sma/fie/blob/main/src/App.tsx"
click node_home "https://github.com/gani-sma/fie/blob/main/src/pages/Home.tsx"
click node_auth "https://github.com/gani-sma/fie/blob/main/src/pages/Auth.tsx"
click node_results "https://github.com/gani-sma/fie/blob/main/src/pages/Results.tsx"
click node_case "https://github.com/gani-sma/fie/blob/main/src/pages/CaseTracking.tsx"
click node_chat "https://github.com/gani-sma/fie/blob/main/src/pages/Chat.tsx"
click node_chatui "https://github.com/gani-sma/fie/blob/main/src/components/chat/ChatInput.tsx"
click node_voice "https://github.com/gani-sma/fie/blob/main/src/hooks/useVoiceInput.ts"
click node_messages "https://github.com/gani-sma/fie/blob/main/src/hooks/useMessages.ts"
click node_conversations "https://github.com/gani-sma/fie/blob/main/src/hooks/useConversations.ts"
click node_repository "https://github.com/gani-sma/fie/blob/main/src/repositories/conversationsRepository.ts"
click node_legalfn "https://github.com/gani-sma/fie/blob/main/supabase/functions/legal-chat/index.ts"
click node_supabaseclient "https://github.com/gani-sma/fie/blob/main/src/integrations/supabase/client.ts"
click node_export "https://github.com/gani-sma/fie/blob/main/src/utils/conversationExport.ts"
click node_pdf "https://github.com/gani-sma/fie/blob/main/src/utils/pdfGenerator.ts"
click node_i18n "https://github.com/gani-sma/fie/blob/main/src/i18n/config.ts"

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_app,node_home,node_auth,node_results,node_case,node_user toneBlue
class node_chat,node_chatui,node_voice,node_messages,node_conversations,node_repository toneAmber
class node_legalfn,node_supabaseclient,node_database,node_openrouter toneMint
class node_export,node_pdf,node_i18n toneRose
class node_groq,node_gemini toneIndigo
```

## Components

### Application

- [App Router](https://github.com/gani-sma/fie/blob/main/src/App.tsx): `src/App.tsx`
- [Home](https://github.com/gani-sma/fie/blob/main/src/pages/Home.tsx): `src/pages/Home.tsx`
- [Authentication](https://github.com/gani-sma/fie/blob/main/src/pages/Auth.tsx): `src/pages/Auth.tsx`
- [Results](https://github.com/gani-sma/fie/blob/main/src/pages/Results.tsx): `src/pages/Results.tsx`
- [Case Tracking](https://github.com/gani-sma/fie/blob/main/src/pages/CaseTracking.tsx): `src/pages/CaseTracking.tsx`

### Chat and History

- [Chat Page](https://github.com/gani-sma/fie/blob/main/src/pages/Chat.tsx): `src/pages/Chat.tsx`
- [Chat Interface](https://github.com/gani-sma/fie/blob/main/src/components/chat/ChatInput.tsx): `src/components/chat/ChatInput.tsx`
- [Voice Input](https://github.com/gani-sma/fie/blob/main/src/hooks/useVoiceInput.ts): `src/hooks/useVoiceInput.ts`
- [Message State](https://github.com/gani-sma/fie/blob/main/src/hooks/useMessages.ts): `src/hooks/useMessages.ts`
- [Conversation State](https://github.com/gani-sma/fie/blob/main/src/hooks/useConversations.ts): `src/hooks/useConversations.ts`
- [Conversation Repository](https://github.com/gani-sma/fie/blob/main/src/repositories/conversationsRepository.ts): `src/repositories/conversationsRepository.ts`

### Backend Services

- [Legal Chat Function](https://github.com/gani-sma/fie/blob/main/supabase/functions/legal-chat/index.ts): `supabase/functions/legal-chat/index.ts`
- [Supabase Client](https://github.com/gani-sma/fie/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- **Supabase Database**

### Product Support

- [Conversation Export](https://github.com/gani-sma/fie/blob/main/src/utils/conversationExport.ts): `src/utils/conversationExport.ts`
- [PDF Generator](https://github.com/gani-sma/fie/blob/main/src/utils/pdfGenerator.ts): `src/utils/pdfGenerator.ts`
- [Localization](https://github.com/gani-sma/fie/blob/main/src/i18n/config.ts): `src/i18n/config.ts`

### Other components

- **User**
- **Groq AI**
- **Gemini AI**
- **OpenRouter AI**

## Connections

- User → App Router: opens
- App Router → Home: routes
- App Router → Authentication: routes
- App Router → Results: routes
- App Router → Case Tracking: routes
- App Router → Chat Page: routes
- Authentication → Supabase Client: authenticates via
- Chat Page → Chat Interface: renders
- Chat Page → Voice Input: uses
- Chat Page → Message State: manages messages
- Chat Page → Conversation State: manages history
- Chat Page → Legal Chat Function: requests guidance
- Legal Chat Function → Groq AI: inference
- Legal Chat Function → Gemini AI: fallback inference
- Legal Chat Function → OpenRouter AI: fallback inference
- Message State → Supabase Client: reads and writes
- Conversation State → Supabase Client: reads and writes
- Conversation Repository → Supabase Client: queries
- Supabase Client → Supabase Database: accesses
- Chat Page → Conversation Export: exports
- Conversation Export → PDF Generator: generates PDF
- App Router → Localization: uses translations
