# gnanadurga09/landsafe-ai architecture

> Architecture diagram of the GitHub repository gnanadurga09/landsafe-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gnanadurga09/landsafe-ai
- Repository: https://github.com/gnanadurga09/landsafe-ai

## Overview

This repository is a NER risk-command application with a React client, a TypeScript API/authentication foundation, and a separate Python ML backend. The visible client entry routes users to Home; the sampled materials do not establish how Home’s risk workflow invokes backend services, so those domain components are shown without inferred connections. The API router exposes auth and system procedures, with system notifications delegated to the notification module. Source evidence is incomplete, and the README provides no additional capability descriptions.

Main entry points: [`client/src/App.tsx`](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/App.tsx) (App routes), [`server/_core/context.ts`](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/context.ts) (Request context), [`client/src/main.tsx`](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/main.tsx) (Client bootstrap), [`server/_core/systemRouter.ts`](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/systemRouter.ts) (System procedures)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_client_entry["Client bootstrap<br/>[main.tsx]"]
  node_app_routes["App routes<br/>[App.tsx]"]
  node_home["Risk dashboard<br/>[Home.tsx]"]
  node_chat["AI chat<br/>[AIChatBox.tsx]"]
  node_map["Map view<br/>[Map.tsx]"]
  node_auth_hook["Auth hook<br/>[useAuth.ts]"]
  node_api_client["tRPC client<br/>[trpc.ts]"]
end

subgraph group_api["API and identity"]
  node_router["API router<br/>[routers.ts]"]
  node_system_api["System procedures<br/>[systemRouter.ts]"]
  node_trpc_core["tRPC middleware<br/>[trpc.ts]"]
  node_context["Request context<br/>[context.ts]"]
  node_oauth["OAuth flow<br/>[oauth.ts]"]
  node_notify["Owner notifications<br/>[notification.ts]"]
end

subgraph group_risk["Risk and persistence"]
  node_ml_backend["ML backend<br/>[app.py]"]
  node_risk_logic["Risk logic<br/>[risk.ts]"]
  node_user_store["User persistence<br/>[db.ts]"]
  node_user_table[("Users table<br/>[schema.ts]")]
end

node_user(("User"))
node_external_notice["Notification service"]

node_user -->|"opens"| node_client_entry
node_client_entry -->|"renders"| node_app_routes
node_app_routes -->|"routes to"| node_home
node_app_routes -.-> node_api_client
node_router -->|"registers"| node_system_api
node_system_api -->|"invokes"| node_notify
node_context -.-> node_user_table
node_context -.-> node_oauth
node_oauth -->|"uses"| node_user_store
node_user_store -->|"reads/writes"| node_user_table
node_notify -.->|"delivers"| node_external_notice

click node_client_entry "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/main.tsx"
click node_app_routes "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/App.tsx"
click node_home "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/pages/Home.tsx"
click node_chat "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/components/AIChatBox.tsx"
click node_map "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/components/Map.tsx"
click node_auth_hook "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/_core/hooks/useAuth.ts"
click node_api_client "https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/lib/trpc.ts"
click node_router "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/routers.ts"
click node_system_api "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/systemRouter.ts"
click node_trpc_core "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/trpc.ts"
click node_context "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/context.ts"
click node_oauth "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/oauth.ts"
click node_notify "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/notification.ts"
click node_ml_backend "https://github.com/gnanadurga09/landsafe-ai/blob/main/ml_backend/app.py"
click node_risk_logic "https://github.com/gnanadurga09/landsafe-ai/blob/main/shared/risk.ts"
click node_user_store "https://github.com/gnanadurga09/landsafe-ai/blob/main/server/db.ts"
click node_user_table "https://github.com/gnanadurga09/landsafe-ai/blob/main/drizzle/schema.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_client_entry,node_app_routes,node_home,node_chat,node_map,node_auth_hook,node_api_client,node_user toneBlue
class node_router,node_system_api,node_trpc_core,node_context,node_oauth,node_notify toneAmber
class node_ml_backend,node_risk_logic,node_user_store,node_user_table toneMint
class node_external_notice toneIndigo
```

## Components

### Client experience

- [Client bootstrap](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/main.tsx): `client/src/main.tsx`
- [App routes](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Risk dashboard](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [AI chat](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/components/AIChatBox.tsx): `client/src/components/AIChatBox.tsx`
- [Map view](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/components/Map.tsx): `client/src/components/Map.tsx`
- [Auth hook](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/_core/hooks/useAuth.ts): `client/src/_core/hooks/useAuth.ts`
- [tRPC client](https://github.com/gnanadurga09/landsafe-ai/blob/main/client/src/lib/trpc.ts): `client/src/lib/trpc.ts`

### API and identity

- [API router](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/routers.ts): `server/routers.ts`
- [System procedures](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/systemRouter.ts): `server/_core/systemRouter.ts`
- [tRPC middleware](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/trpc.ts): `server/_core/trpc.ts`
- [Request context](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/context.ts): `server/_core/context.ts`
- [OAuth flow](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/oauth.ts): `server/_core/oauth.ts`
- [Owner notifications](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/_core/notification.ts): `server/_core/notification.ts`

### Risk and persistence

- [ML backend](https://github.com/gnanadurga09/landsafe-ai/blob/main/ml_backend/app.py): `ml_backend/app.py`
- [Risk logic](https://github.com/gnanadurga09/landsafe-ai/blob/main/shared/risk.ts): `shared/risk.ts`
- [User persistence](https://github.com/gnanadurga09/landsafe-ai/blob/main/server/db.ts): `server/db.ts`
- [Users table](https://github.com/gnanadurga09/landsafe-ai/blob/main/drizzle/schema.ts): `drizzle/schema.ts`

### Other components

- **User**
- **Notification service**

## Connections

- User → Client bootstrap: opens
- Client bootstrap → App routes: renders (evidence: `client/src/main.tsx`)
- App routes → Risk dashboard: routes to (evidence: `client/src/App.tsx`)
- App routes → tRPC client
- API router → System procedures: registers (evidence: `server/routers.ts`)
- System procedures → Owner notifications: invokes (evidence: `server/_core/systemRouter.ts`)
- Request context → Users table (evidence: `server/_core/context.ts`)
- Request context → OAuth flow
- OAuth flow → User persistence: uses (evidence: `server/_core/oauth.ts`)
- User persistence → Users table: reads/writes (evidence: `server/db.ts`)
- Owner notifications → Notification service: delivers
