# danish26-dev/crosslens architecture

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

- Interactive diagram: https://gitdiagram.com/danish26-dev/crosslens
- Repository: https://github.com/danish26-dev/crosslens

## Overview

CrossLens is a courtroom-memory application: attorneys ingest case documents, build persistent case context, then use live testimony, grounded questions, and case views to retrieve evidence and surface contradictions. The graph combines the documented product workflow and capabilities with relationships visible in the sampled sources. Several domain implementations were not sampled, so README-described links are cited to the README; unsampled internal call details are not inferred.

Main entry points: [`src/lib/api/case.server.ts`](https://github.com/danish26-dev/crosslens/blob/main/src/lib/api/case.server.ts) (Case operations), [`src/lib/openrouter/client.ts`](https://github.com/danish26-dev/crosslens/blob/main/src/lib/openrouter/client.ts) (OpenRouter reasoning), [`src/routes/dashboard.tsx`](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.tsx) (Attorney dashboard), [`src/routes/dashboard.live.tsx`](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.live.tsx) (Live testimony)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Case workflow"]
  node_documents["Legal documents"]
  node_ingest["Document ingestion"]
  node_parser["Document parser<br/>[parser.ts]"]
  node_api["Server RPC API<br/>[index.ts]"]
  node_case_service["Case operations<br/>[case.server.ts]"]
  node_testimony["Live testimony<br/>[dashboard.live.tsx]"]
end

subgraph group_services["Memory and reasoning"]
  node_cognee_client["Cognee client<br/>[client.ts]"]
  node_cognee_demo["Cognee workflows<br/>[demo.server.ts]"]
  node_cognee[("Cognee memory graph")]
  node_openrouter["OpenRouter reasoning<br/>[client.ts]"]
end

subgraph group_records["Case records"]
  node_postgres[("Postgres case store<br/>[pg.ts]")]
  node_seed["Demo case data<br/>[seed.ts]"]
  node_case_types["Case domain types<br/>[case.ts]"]
end

subgraph group_experience["Attorney experience"]
  node_dashboard["Attorney dashboard<br/>[dashboard.tsx]"]
  node_ask["Grounded questions<br/>[dashboard.ask.tsx]"]
  node_contradictions["Contradiction review"]
  node_evidence["Evidence view"]
  node_timeline["Timeline view"]
  node_knowledge_graph["Knowledge graph view<br/>[witness-graph.tsx]"]
  node_memory_ui["Memory lifecycle view"]
  node_ui_components["Shared UI components"]
  node_mobile_hook["Mobile layout hook<br/>[use-mobile.tsx]"]
end

node_attorney(("Attorney"))

node_attorney -->|"provides"| node_documents
node_documents -->|"uploads"| node_ingest
node_ingest -->|"requests document listing"| node_api
node_api -->|"delegates operations"| node_case_service
node_documents -->|"extracts text"| node_parser
node_case_service -.->|"reads and writes case records"| node_postgres
node_case_service -.->|"uses memory service"| node_cognee_client
node_cognee_demo -.->|"uses primitives"| node_cognee_client
node_cognee_client -->|"adds and searches"| node_cognee
node_attorney -->|"enters testimony"| node_testimony
node_testimony -->|"requests analysis"| node_openrouter
node_openrouter -->|"recalls context"| node_cognee
node_openrouter -->|"returns citations"| node_testimony
node_cognee -->|"provides prior context"| node_contradictions
node_cognee -->|"provides graph data"| node_knowledge_graph
node_cognee -->|"provides event context"| node_timeline
node_attorney -->|"asks questions"| node_ask
node_ask -.->|"retrieves memories"| node_cognee
node_attorney -->|"manages memory"| node_memory_ui
node_seed -->|"seeds records"| node_postgres
node_dashboard -.->|"uses shared controls"| node_ui_components
node_ui_components -->|"checks viewport"| node_mobile_hook
node_attorney -->|"views case workspace"| node_dashboard
node_dashboard -->|"opens evidence"| node_evidence

click node_ingest "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.ingest.tsx"
click node_parser "https://github.com/danish26-dev/crosslens/blob/main/src/lib/documents/parser.ts"
click node_api "https://github.com/danish26-dev/crosslens/blob/main/src/lib/api/index.ts"
click node_case_service "https://github.com/danish26-dev/crosslens/blob/main/src/lib/api/case.server.ts"
click node_testimony "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.live.tsx"
click node_cognee_client "https://github.com/danish26-dev/crosslens/blob/main/src/lib/cognee/client.ts"
click node_cognee_demo "https://github.com/danish26-dev/crosslens/blob/main/src/lib/cognee/demo.server.ts"
click node_openrouter "https://github.com/danish26-dev/crosslens/blob/main/src/lib/openrouter/client.ts"
click node_postgres "https://github.com/danish26-dev/crosslens/blob/main/src/lib/db/pg.ts"
click node_seed "https://github.com/danish26-dev/crosslens/blob/main/src/lib/db/seed.ts"
click node_case_types "https://github.com/danish26-dev/crosslens/blob/main/src/lib/types/case.ts"
click node_dashboard "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.tsx"
click node_ask "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.ask.tsx"
click node_contradictions "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.contradictions.tsx"
click node_evidence "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.evidence.tsx"
click node_timeline "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.timeline.tsx"
click node_knowledge_graph "https://github.com/danish26-dev/crosslens/blob/main/src/components/witness-graph.tsx"
click node_memory_ui "https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.memory.tsx"
click node_ui_components "https://github.com/danish26-dev/crosslens/tree/main/src/components/ui"
click node_mobile_hook "https://github.com/danish26-dev/crosslens/blob/main/src/hooks/use-mobile.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_documents,node_ingest,node_parser,node_api,node_case_service,node_testimony toneBlue
class node_cognee_client,node_cognee_demo,node_cognee,node_openrouter toneAmber
class node_postgres,node_seed,node_case_types toneMint
class node_dashboard,node_ask,node_contradictions,node_evidence,node_timeline,node_knowledge_graph,node_memory_ui,node_ui_components,node_mobile_hook toneRose
class node_attorney toneIndigo
```

## Components

### Case workflow

- **Legal documents**
- [Document ingestion](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.ingest.tsx): `src/routes/dashboard.ingest.tsx`
- [Document parser](https://github.com/danish26-dev/crosslens/blob/main/src/lib/documents/parser.ts): `src/lib/documents/parser.ts`
- [Server RPC API](https://github.com/danish26-dev/crosslens/blob/main/src/lib/api/index.ts): `src/lib/api/index.ts`
- [Case operations](https://github.com/danish26-dev/crosslens/blob/main/src/lib/api/case.server.ts): `src/lib/api/case.server.ts`
- [Live testimony](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.live.tsx): `src/routes/dashboard.live.tsx`

### Memory and reasoning

- [Cognee client](https://github.com/danish26-dev/crosslens/blob/main/src/lib/cognee/client.ts): `src/lib/cognee/client.ts`
- [Cognee workflows](https://github.com/danish26-dev/crosslens/blob/main/src/lib/cognee/demo.server.ts): `src/lib/cognee/demo.server.ts`
- **Cognee memory graph**
- [OpenRouter reasoning](https://github.com/danish26-dev/crosslens/blob/main/src/lib/openrouter/client.ts): `src/lib/openrouter/client.ts`

### Case records

- [Postgres case store](https://github.com/danish26-dev/crosslens/blob/main/src/lib/db/pg.ts): `src/lib/db/pg.ts`
- [Demo case data](https://github.com/danish26-dev/crosslens/blob/main/src/lib/db/seed.ts): `src/lib/db/seed.ts`
- [Case domain types](https://github.com/danish26-dev/crosslens/blob/main/src/lib/types/case.ts): `src/lib/types/case.ts`

### Attorney experience

- [Attorney dashboard](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.tsx): `src/routes/dashboard.tsx`
- [Grounded questions](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.ask.tsx): `src/routes/dashboard.ask.tsx`
- [Contradiction review](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.contradictions.tsx): `src/routes/dashboard.contradictions.tsx`
- [Evidence view](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.evidence.tsx): `src/routes/dashboard.evidence.tsx`
- [Timeline view](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.timeline.tsx): `src/routes/dashboard.timeline.tsx`
- [Knowledge graph view](https://github.com/danish26-dev/crosslens/blob/main/src/components/witness-graph.tsx): `src/components/witness-graph.tsx`
- [Memory lifecycle view](https://github.com/danish26-dev/crosslens/blob/main/src/routes/dashboard.memory.tsx): `src/routes/dashboard.memory.tsx`
- [Shared UI components](https://github.com/danish26-dev/crosslens/tree/main/src/components/ui): `src/components/ui`
- [Mobile layout hook](https://github.com/danish26-dev/crosslens/blob/main/src/hooks/use-mobile.tsx): `src/hooks/use-mobile.tsx`

### Other components

- **Attorney**

## Connections

- Attorney → Legal documents: provides (evidence: `README.md`)
- Legal documents → Document ingestion: uploads (evidence: `README.md`)
- Document ingestion → Server RPC API: requests document listing (evidence: `src/routes/dashboard.ingest.tsx`)
- Server RPC API → Case operations: delegates operations (evidence: `src/lib/api/index.ts`)
- Legal documents → Document parser: extracts text (evidence: `README.md`)
- Case operations → Postgres case store: reads and writes case records
- Case operations → Cognee client: uses memory service
- Cognee workflows → Cognee client: uses primitives
- Cognee client → Cognee memory graph: adds and searches (evidence: `src/lib/cognee/client.ts`)
- Attorney → Live testimony: enters testimony (evidence: `README.md`)
- Live testimony → OpenRouter reasoning: requests analysis (evidence: `README.md`)
- OpenRouter reasoning → Cognee memory graph: recalls context (evidence: `README.md`)
- OpenRouter reasoning → Live testimony: returns citations (evidence: `README.md`)
- Cognee memory graph → Contradiction review: provides prior context (evidence: `README.md`)
- Cognee memory graph → Knowledge graph view: provides graph data (evidence: `README.md`)
- Cognee memory graph → Timeline view: provides event context (evidence: `README.md`)
- Attorney → Grounded questions: asks questions (evidence: `README.md`)
- Grounded questions → Cognee memory graph: retrieves memories
- Attorney → Memory lifecycle view: manages memory (evidence: `README.md`)
- Demo case data → Postgres case store: seeds records (evidence: `src/lib/db/seed.ts`)
- Attorney dashboard → Shared UI components: uses shared controls
- Shared UI components → Mobile layout hook: checks viewport (evidence: `src/components/ui/sidebar.tsx`)
- Attorney → Attorney dashboard: views case workspace (evidence: `README.md`)
- Attorney dashboard → Evidence view: opens evidence (evidence: `README.md`)
