# dasouvik122005/orca architecture

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

- Interactive diagram: https://gitdiagram.com/dasouvik122005/orca
- Repository: https://github.com/dasouvik122005/orca

## Overview

#### Purpose and entry points
ORCA is a marine decision-intelligence platform for safety and fishing-operation recommendations. A FastAPI backend accepts natural-language queries, coordinates domain agents, computes deterministic risk, and returns explainable results. The React/Vite client presents chat, maps, risk metrics, and execution trace.
- Backend API: `backend/app/main.py`
- Frontend bootstrap: `frontend/src/main.tsx`, `frontend/src/App.tsx`

#### Backend boundary and contracts
The backend separates HTTP/WebSocket transport, typed response contracts, agent orchestration, and external-data access. Shared schemas stabilize exchanges among agents and the frontend; configuration and API credentials are environment-driven.
- API and application setup: `backend/app/main.py`, `backend/app/config.py`
- Typed models: `backend/app/models/schemas.py`
- Streaming transport: `backend/app/websocket.py`

#### Orchestration stage
The orchestrator is the control-plane state machine. It interprets a user request, selects/invokes specialized agents—potentially in parallel—collects standardized reports, then triggers risk and explanation stages. It also emits progress events for the client’s reasoning trace.
- Coordinator: `backend/app/agents/orchestrator.py`
- Agent package boundary: `backend/app/agents/__init__.py`
- WebSocket delivery: `backend/app/websocket.py`

#### Live marine-data acquisition
Weather and ocean agents obtain current meteorological and marine conditions; the geospatial agent derives location-aware constraints such as EEZ/MPA context through geographic calculations. External REST clients isolate Open-Meteo and OpenWeatherMap integration details from agent logic.
- Weather: `backend/app/agents/weather_agent.py`
- Ocean and geospatial analysis: `backend/app/agents/ocean_agent.py`, `backend/app/agents/geospatial_agent.py`
- API integration layer: `backend/app/data/api_clients.py`

#### Operational recommendation stages
PFZ discovery produces potential fishing-zone information, while route planning produces navigable route/risk-zone data for mapping. These are independent domain outputs consumed by the final response and visualization layer rather than replacing safety assessment.
- PFZ stage: `backend/app/agents/pfz_agent.py`
- Route stage: `backend/app/agents/route_agent.py`
- Shared response definitions: `backend/app/models/schemas.py`

#### Risk and explainability boundary
Risk scoring is deterministic and threshold-based, converting collected weather, ocean, and geospatial reports into a numeric risk profile. A separate explainability agent uses Google Gemini to turn that structured profile into localized human-readable advice, preventing the LLM from being the safety decision engine.
- Deterministic risk engine: `backend/app/agents/risk_agent.py`
- Gemini-backed explanation: `backend/app/agents/explainability_agent.py`
- Environment configuration: `backend/.env.example`, `backend/app/config.py`

#### Client visualization and interaction
The frontend submits queries through a service boundary, receives final structured results and real-time progress, then renders domain-specific views. React-Leaflet displays routes, zones, and PFZ heatmaps; dashboard and trace components expose risk and orchestration status.
- API client: `frontend/src/services/api.ts`
- Map and dashboard: `frontend/src/components/MarineMap.tsx`, `frontend/src/components/RiskDashboard.tsx`
- Chat and trace: `frontend/src/components/ChatPanel.tsx`, `frontend/src/components/AgentTrace.tsx`

Main entry points: [`backend/app/agents/orchestrator.py`](https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/orchestrator.py) (Orchestrator), [`frontend/src/services/api.ts`](https://github.com/dasouvik122005/orca/blob/main/frontend/src/services/api.ts) (API client), [`backend/app/models/schemas.py`](https://github.com/dasouvik122005/orca/blob/main/backend/app/models/schemas.py) (Shared schemas), [`backend/app/main.py`](https://github.com/dasouvik122005/orca/blob/main/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React client"]
  node_app["App bootstrap<br/>React/Vite"]
  node_api_client["API client<br/>frontend service<br/>[api.ts]"]
  node_chat_trace["Chat &amp; trace<br/>React components"]
  node_map_dashboard["Map &amp; risk dashboard<br/>React-Leaflet views"]
end

subgraph group_transport["Backend transport"]
  node_api["FastAPI application<br/>HTTP API<br/>[main.py]"]
  node_websocket["WebSocket stream<br/>progress transport<br/>[websocket.py]"]
  node_schemas["Shared schemas<br/>typed contracts<br/>[schemas.py]"]
  node_config["Configuration<br/>environment settings"]
end

subgraph group_agents["Decision pipeline"]
  node_orchestrator{{"Orchestrator<br/>control-plane state machine<br/>[orchestrator.py]"}}
  node_marine_agents["Weather, ocean &amp; geospatial<br/>domain agents"]
  node_operations_agents["PFZ &amp; route planning<br/>domain agents"]
  node_risk["Risk engine<br/>deterministic scoring<br/>[risk_agent.py]"]
  node_explainability["Explainability agent<br/>LLM advice generation"]
end

subgraph group_data["External data &amp; AI"]
  node_api_clients["Marine API clients<br/>external REST adapter<br/>[api_clients.py]"]
  node_marine_apis(("Weather &amp; ocean APIs<br/>external providers"))
  node_gemini(("Google Gemini<br/>external LLM"))
end

node_app -->|"submits queries"| node_api_client
node_app -->|"renders interaction"| node_chat_trace
node_app -->|"renders results"| node_map_dashboard
node_api_client -->|"HTTP requests"| node_api
node_api_client -->|"progress stream"| node_websocket
node_api -->|"dispatches request"| node_orchestrator
node_websocket -->|"progress events"| node_chat_trace
node_orchestrator -->|"invokes"| node_marine_agents
node_orchestrator -->|"invokes"| node_operations_agents
node_orchestrator -->|"collected reports"| node_risk
node_risk -->|"structured risk profile"| node_explainability
node_orchestrator -->|"builds response"| node_schemas
node_schemas -->|"structured result"| node_api_client
node_marine_agents -->|"live-condition requests"| node_api_clients
node_api_clients -->|"REST integration"| node_marine_apis
node_explainability -->|"advice generation"| node_gemini
node_config -.->|"application settings"| node_api
node_config -.->|"API credentials"| node_api_clients
node_config -.->|"Gemini credentials"| node_explainability
node_schemas -->|"routes, zones &amp; metrics"| node_map_dashboard

click node_api_client "https://github.com/dasouvik122005/orca/blob/main/frontend/src/services/api.ts"
click node_api "https://github.com/dasouvik122005/orca/blob/main/backend/app/main.py"
click node_websocket "https://github.com/dasouvik122005/orca/blob/main/backend/app/websocket.py"
click node_schemas "https://github.com/dasouvik122005/orca/blob/main/backend/app/models/schemas.py"
click node_orchestrator "https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/orchestrator.py"
click node_risk "https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/risk_agent.py"
click node_explainability "https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/explainability_agent.py"
click node_api_clients "https://github.com/dasouvik122005/orca/blob/main/backend/app/data/api_clients.py"

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_api_client,node_chat_trace,node_map_dashboard toneBlue
class node_api,node_websocket,node_schemas,node_config toneAmber
class node_orchestrator,node_marine_agents,node_operations_agents,node_risk,node_explainability toneMint
class node_api_clients,node_marine_apis,node_gemini toneRose
```

## Components

### React client

- **App bootstrap**: React/Vite
- [API client](https://github.com/dasouvik122005/orca/blob/main/frontend/src/services/api.ts): frontend service · `frontend/src/services/api.ts`
- **Chat & trace**: React components · Captures queries and displays live orchestration progress.
- **Map & risk dashboard**: React-Leaflet views

### Backend transport

- [FastAPI application](https://github.com/dasouvik122005/orca/blob/main/backend/app/main.py): HTTP API · `backend/app/main.py`
- [WebSocket stream](https://github.com/dasouvik122005/orca/blob/main/backend/app/websocket.py): progress transport · `backend/app/websocket.py`
- [Shared schemas](https://github.com/dasouvik122005/orca/blob/main/backend/app/models/schemas.py): typed contracts · Standardizes agent reports and frontend responses. · `backend/app/models/schemas.py`
- **Configuration**: environment settings · Supplies API credentials and application settings.

### Decision pipeline

- [Orchestrator](https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/orchestrator.py): control-plane state machine · Selects agents, aggregates reports, and drives risk and explanation stages. · `backend/app/agents/orchestrator.py`
- **Weather, ocean & geospatial**: domain agents
- **PFZ & route planning**: domain agents · Produces fishing-zone and navigable route outputs independently of safety scoring.
- [Risk engine](https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/risk_agent.py): deterministic scoring · Applies threshold-based safety scoring to collected reports. · `backend/app/agents/risk_agent.py`
- [Explainability agent](https://github.com/dasouvik122005/orca/blob/main/backend/app/agents/explainability_agent.py): LLM advice generation · Turns structured risk into localized human-readable advice. · `backend/app/agents/explainability_agent.py`

### External data & AI

- [Marine API clients](https://github.com/dasouvik122005/orca/blob/main/backend/app/data/api_clients.py): external REST adapter · Isolates Open-Meteo and OpenWeatherMap integration. · `backend/app/data/api_clients.py`
- **Weather & ocean APIs**: external providers · Open-Meteo and OpenWeatherMap live conditions.
- **Google Gemini**: external LLM

## Connections

- App bootstrap → API client: submits queries
- App bootstrap → Chat & trace: renders interaction
- App bootstrap → Map & risk dashboard: renders results
- API client → FastAPI application: HTTP requests
- API client → WebSocket stream: progress stream
- FastAPI application → Orchestrator: dispatches request
- WebSocket stream → Chat & trace: progress events
- Orchestrator → Weather, ocean & geospatial: invokes
- Orchestrator → PFZ & route planning: invokes
- Orchestrator → Risk engine: collected reports
- Risk engine → Explainability agent: structured risk profile
- Orchestrator → Shared schemas: builds response
- Shared schemas → API client: structured result
- Weather, ocean & geospatial → Marine API clients: live-condition requests
- Marine API clients → Weather & ocean APIs: REST integration
- Explainability agent → Google Gemini: advice generation
- Configuration → FastAPI application: application settings
- Configuration → Marine API clients: API credentials
- Configuration → Explainability agent: Gemini credentials
- Shared schemas → Map & risk dashboard: routes, zones & metrics
