# eloquent-algorithmics/automotive-ai architecture

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

- Interactive diagram: https://gitdiagram.com/eloquent-algorithmics/automotive-ai
- Repository: https://github.com/eloquent-algorithmics/automotive-ai

## Overview

Automotive AI is a voice-activated vehicle diagnostic assistant. The main workflow starts in app.py, selects voice handling with or without an ELM327 device, recognizes commands, and dispatches vehicle queries or connected services; responses can be spoken back. Separate capabilities cover diagnostic reports, live OBD-II data, conversational AI and search, and Google or Microsoft email/calendar. Relationships follow the sampled calls, source-index references, or README; unsampled implementation details are omitted where wiring is uncertain.

Main entry points: [`app.py`](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/app.py) (Application entry), [`voice/voice_recognition.py`](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/voice_recognition.py) (Voice command handling), [`voice/elm327.py`](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/elm327.py) (ELM voice handling), [`utils/serial_commands.py`](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/serial_commands.py) (OBD commands and reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application and voice"]
  node_app["Application entry<br/>[app.py]"]
  node_voice["Voice command handling"]
  node_elm_voice["ELM voice handling<br/>[elm327.py]"]
  node_commands["Command definitions<br/>[commands.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_vehicle["Vehicle diagnostics"]
  node_serial["OBD commands and reports<br/>[serial_commands.py]"]
  node_vin["VIN decoding<br/>[vin_decoder.py]"]
  node_stream["Live OBD stream"]
end

subgraph group_assistant["AI and speech"]
  node_chat["OpenAI chat<br/>[gpt_chat.py]"]
  node_search["Google custom search<br/>[functions.py]"]
  node_speech["Speech output<br/>[audio_output.py]"]
end

subgraph group_services["Connected services"]
  node_google["Google email and calendar<br/>[google_api.py]"]
  node_ms_auth["Microsoft authorization<br/>[ms_authserver.py]"]
  node_graph["Microsoft Graph services<br/>[graph_api.py]"]
end

node_user(("Driver"))
node_vehicle_device{{"ELM327 device"}}
node_speech_service{{"Speech services"}}
node_google_services{{"Google APIs"}}
node_microsoft_services{{"Microsoft Graph"}}
node_nhtsa{{"NHTSA vehicle data"}}

node_user -->|"starts"| node_app
node_app -->|"greets with"| node_chat
node_app -->|"speaks greeting"| node_speech
node_app -->|"starts voice mode"| node_voice
node_app -->|"starts device mode"| node_elm_voice
node_app -->|"gets authorization"| node_ms_auth
node_app -->|"initializes Graph"| node_graph
node_voice -->|"uses commands"| node_commands
node_voice -->|"handles conversation"| node_chat
node_voice -->|"speaks responses"| node_speech
node_voice -->|"dispatches Google tasks"| node_google
node_voice -->|"dispatches Microsoft tasks"| node_graph
node_elm_voice -->|"uses common commands"| node_voice
node_elm_voice -->|"sends vehicle commands"| node_serial
node_elm_voice -->|"starts data stream"| node_stream
node_elm_voice -->|"communicates over serial"| node_vehicle_device
node_serial -->|"sends diagnostic queries"| node_vehicle_device
node_serial -->|"decodes VIN"| node_vin
node_serial -->|"requests vehicle data"| node_nhtsa
node_serial -->|"emails diagnostic report"| node_graph
node_stream -->|"queries sensors"| node_vehicle_device
node_chat -->|"calls search tool"| node_search
node_chat -->|"returns spoken response"| node_speech
node_speech -->|"synthesizes audio"| node_speech_service
node_google -->|"calls email and calendar APIs"| node_google_services
node_ms_auth -.->|"authorizes account"| node_microsoft_services
node_graph -.->|"requests mail and calendar"| node_microsoft_services

click node_app "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/app.py"
click node_voice "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/voice_recognition.py"
click node_elm_voice "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/elm327.py"
click node_commands "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/commands.py"
click node_config "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/config.py"
click node_serial "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/serial_commands.py"
click node_vin "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/nhtsa_functions/vin_decoder.py"
click node_stream "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/datastreams/flask_air_fuel_datastream.py"
click node_chat "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/openai_functions/gpt_chat.py"
click node_search "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/functions.py"
click node_speech "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/audio/audio_output.py"
click node_google "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/google_functions/google_api.py"
click node_ms_auth "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/microsoft_functions/ms_authserver.py"
click node_graph "https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/microsoft_functions/graph_api.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_voice,node_elm_voice,node_commands,node_config toneBlue
class node_serial,node_vin,node_stream toneAmber
class node_chat,node_search,node_speech,node_google_services toneMint
class node_google,node_ms_auth,node_graph toneRose
class node_user,node_vehicle_device,node_speech_service,node_microsoft_services,node_nhtsa toneIndigo
```

## Components

### Application and voice

- [Application entry](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/app.py): `app.py`
- [Voice command handling](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/voice_recognition.py): `voice/voice_recognition.py`
- [ELM voice handling](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/voice/elm327.py): `voice/elm327.py`
- [Command definitions](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/commands.py): `utils/commands.py`
- [Runtime configuration](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/config.py): `config.py`

### Vehicle diagnostics

- [OBD commands and reports](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/serial_commands.py): `utils/serial_commands.py`
- [VIN decoding](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/nhtsa_functions/vin_decoder.py): `api/nhtsa_functions/vin_decoder.py`
- [Live OBD stream](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/datastreams/flask_air_fuel_datastream.py): `datastreams/flask_air_fuel_datastream.py`

### AI and speech

- [OpenAI chat](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/openai_functions/gpt_chat.py): `api/openai_functions/gpt_chat.py`
- [Google custom search](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/utils/functions.py): `utils/functions.py`
- [Speech output](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/audio/audio_output.py): `audio/audio_output.py`

### Connected services

- [Google email and calendar](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/google_functions/google_api.py): `api/google_functions/google_api.py`
- [Microsoft authorization](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/microsoft_functions/ms_authserver.py): `api/microsoft_functions/ms_authserver.py`
- [Microsoft Graph services](https://github.com/eloquent-algorithmics/automotive-ai/blob/main/api/microsoft_functions/graph_api.py): `api/microsoft_functions/graph_api.py`

### Other components

- **Driver**
- **ELM327 device**
- **Speech services**
- **Google APIs**
- **Microsoft Graph**
- **NHTSA vehicle data**

## Connections

- Driver → Application entry: starts (evidence: `README.md`)
- Application entry → OpenAI chat: greets with (evidence: `app.py`)
- Application entry → Speech output: speaks greeting (evidence: `app.py`)
- Application entry → Voice command handling: starts voice mode (evidence: `app.py`)
- Application entry → ELM voice handling: starts device mode (evidence: `app.py`)
- Application entry → Microsoft authorization: gets authorization (evidence: `app.py`)
- Application entry → Microsoft Graph services: initializes Graph (evidence: `app.py`)
- Voice command handling → Command definitions: uses commands (evidence: `voice/voice_recognition.py`)
- Voice command handling → OpenAI chat: handles conversation (evidence: `voice/voice_recognition.py`)
- Voice command handling → Speech output: speaks responses (evidence: `voice/voice_recognition.py`)
- Voice command handling → Google email and calendar: dispatches Google tasks (evidence: `voice/voice_recognition.py`)
- Voice command handling → Microsoft Graph services: dispatches Microsoft tasks (evidence: `voice/voice_recognition.py`)
- ELM voice handling → Voice command handling: uses common commands (evidence: `voice/elm327.py`)
- ELM voice handling → OBD commands and reports: sends vehicle commands (evidence: `voice/elm327.py`)
- ELM voice handling → Live OBD stream: starts data stream (evidence: `voice/elm327.py`)
- ELM voice handling → ELM327 device: communicates over serial (evidence: `voice/elm327.py`)
- OBD commands and reports → ELM327 device: sends diagnostic queries (evidence: `utils/serial_commands.py`)
- OBD commands and reports → VIN decoding: decodes VIN (evidence: `utils/serial_commands.py`)
- OBD commands and reports → NHTSA vehicle data: requests vehicle data (evidence: `utils/serial_commands.py`)
- OBD commands and reports → Microsoft Graph services: emails diagnostic report (evidence: `utils/serial_commands.py`)
- Live OBD stream → ELM327 device: queries sensors (evidence: `datastreams/flask_air_fuel_datastream.py`)
- OpenAI chat → Google custom search: calls search tool (evidence: `api/openai_functions/gpt_chat.py`)
- OpenAI chat → Speech output: returns spoken response (evidence: `voice/voice_recognition.py`)
- Speech output → Speech services: synthesizes audio (evidence: `audio/audio_output.py`)
- Google email and calendar → Google APIs: calls email and calendar APIs (evidence: `api/google_functions/google_api.py`)
- Microsoft authorization → Microsoft Graph: authorizes account (evidence: `api/microsoft_functions/ms_authserver.py`)
- Microsoft Graph services → Microsoft Graph: requests mail and calendar (evidence: `api/microsoft_functions/graph_api.py`)
