# nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning architecture

> Architecture diagram of the GitHub repository nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning
- Repository: https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning

## Overview

This repository presents a smart-bus routing simulation using reinforcement learning. In Q_Learning.py, the simulation creates a route network, bus and passengers; the bus selects routes, passenger pickups and elapsed time produce rewards for Q-table updates, and the loop renders the result. Environment.py is a separate Pygame route visualizer. The README also describes Deep Q-Learning, and DQN_Final_Train_Test.py is named accordingly, but its implementation and connections were not sampled. The diagram therefore shows that capability without guessing its runtime wiring.

Main entry points: [`Q_Learning.py`](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py) (Bus Agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sim["Bus Simulation"]
  node_route_network["Route Network<br/>[Q_Learning.py]"]
  node_bus_agent["Bus Agent<br/>[Q_Learning.py]"]
  node_passengers["Passengers<br/>[Q_Learning.py]"]
  node_simulation_loop["Simulation Loop<br/>[Q_Learning.py]"]
end

subgraph group_learning["Learning Approaches"]
  node_q_learning["Q-Learning<br/>[Q_Learning.py]"]
  node_dqn["DQN Training/Test"]
end

subgraph group_visual["Route Visualization"]
  node_environment_view["Environment Viewer<br/>[Environment.py]"]
end

node_simulation_loop -->|"updates"| node_bus_agent
node_simulation_loop -->|"updates"| node_passengers
node_simulation_loop -->|"rewards"| node_bus_agent
node_bus_agent -->|"follows"| node_route_network
node_bus_agent -->|"checks pickups"| node_passengers
node_bus_agent -->|"updates values"| node_q_learning

click node_route_network "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py"
click node_bus_agent "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py"
click node_passengers "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py"
click node_simulation_loop "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py"
click node_q_learning "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py"
click node_dqn "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/DQN_Final_Train_Test.py"
click node_environment_view "https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Environment.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_route_network,node_bus_agent,node_passengers,node_simulation_loop toneBlue
class node_q_learning,node_dqn toneAmber
class node_environment_view toneMint
```

## Components

### Bus Simulation

- [Route Network](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py): `Q_Learning.py`
- [Bus Agent](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py): `Q_Learning.py`
- [Passengers](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py): `Q_Learning.py`
- [Simulation Loop](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py): `Q_Learning.py`

### Learning Approaches

- [Q-Learning](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Q_Learning.py): `Q_Learning.py`
- [DQN Training/Test](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/DQN_Final_Train_Test.py): `DQN_Final_Train_Test.py`

### Route Visualization

- [Environment Viewer](https://github.com/nithin0702/smart-bus-route-optimization-using-deep-reinforcement-learning/blob/main/Environment.py): `Environment.py`

## Connections

- Simulation Loop → Bus Agent: updates (evidence: `Q_Learning.py`)
- Simulation Loop → Passengers: updates (evidence: `Q_Learning.py`)
- Simulation Loop → Bus Agent: rewards (evidence: `Q_Learning.py`)
- Bus Agent → Route Network: follows (evidence: `Q_Learning.py`)
- Bus Agent → Passengers: checks pickups (evidence: `Q_Learning.py`)
- Bus Agent → Q-Learning: updates values (evidence: `Q_Learning.py`)
