# linkedconnections/query-server architecture

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

- Interactive diagram: https://gitdiagram.com/linkedconnections/query-server
- Repository: https://github.com/linkedconnections/query-server

## Overview

Query Server exposes a route-planning query over HTTP: a client supplies a departure time and optional stop identifiers, the route controller retrieves time-bounded connections, runs the CSA planner, and returns a path or a not-found response. The server wires middleware and starts only after connecting to MongoDB. MongoDBFixStream normalizes connection records before planning. The excerpts establish these runtime calls; the README documents the HTTP purpose but provides no further capability detail.

Main entry points: [`bin/server.js`](https://github.com/linkedconnections/query-server/blob/master/bin/server.js) (Express server), [`middlewares/MongoDBConnector.js`](https://github.com/linkedconnections/query-server/blob/master/middlewares/MongoDBConnector.js) (Mongo connector), [`controllers/RouteController.js`](https://github.com/linkedconnections/query-server/blob/master/controllers/RouteController.js) (Route controller), [`middlewares/ErrorHandler.js`](https://github.com/linkedconnections/query-server/blob/master/middlewares/ErrorHandler.js) (Error handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP server"]
  node_server["Express server<br/>[server.js]"]
  node_errors["Error handler<br/>[ErrorHandler.js]"]
end

subgraph group_planning["Route planning"]
  node_route["Route controller<br/>[RouteController.js]"]
  node_planner["CSA planner"]
end

subgraph group_storage["Connection storage"]
  node_connector["Mongo connector"]
  node_fixstream["Connection normalizer"]
end

node_client(("HTTP client"))
node_mongodb[("MongoDB")]

node_client -->|"queries over HTTP"| node_server
node_server -->|"installs middleware"| node_connector
node_server -->|"routes GET /"| node_route
node_server -->|"installs handler"| node_errors
node_server -->|"connects at startup"| node_connector
node_connector -->|"connects and queries"| node_mongodb
node_route -->|"requests connections"| node_connector
node_connector -->|"pipes records"| node_fixstream
node_route -->|"pipes into planner"| node_planner
node_route -->|"returns path or error"| node_client

click node_server "https://github.com/linkedconnections/query-server/blob/master/bin/server.js"
click node_errors "https://github.com/linkedconnections/query-server/blob/master/middlewares/ErrorHandler.js"
click node_route "https://github.com/linkedconnections/query-server/blob/master/controllers/RouteController.js"
click node_connector "https://github.com/linkedconnections/query-server/blob/master/middlewares/MongoDBConnector.js"
click node_fixstream "https://github.com/linkedconnections/query-server/blob/master/middlewares/MongoDBFixStream.js"

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_server,node_errors,node_client toneBlue
class node_route,node_planner,node_mongodb toneAmber
class node_connector,node_fixstream toneMint
```

## Components

### HTTP server

- [Express server](https://github.com/linkedconnections/query-server/blob/master/bin/server.js): `bin/server.js`
- [Error handler](https://github.com/linkedconnections/query-server/blob/master/middlewares/ErrorHandler.js): `middlewares/ErrorHandler.js`

### Route planning

- [Route controller](https://github.com/linkedconnections/query-server/blob/master/controllers/RouteController.js): `controllers/RouteController.js`
- **CSA planner**

### Connection storage

- [Mongo connector](https://github.com/linkedconnections/query-server/blob/master/middlewares/MongoDBConnector.js): `middlewares/MongoDBConnector.js`
- [Connection normalizer](https://github.com/linkedconnections/query-server/blob/master/middlewares/MongoDBFixStream.js): `middlewares/MongoDBFixStream.js`

### Other components

- **HTTP client**
- **MongoDB**

## Connections

- HTTP client → Express server: queries over HTTP (evidence: `README.md`)
- Express server → Mongo connector: installs middleware (evidence: `bin/server.js`)
- Express server → Route controller: routes GET / (evidence: `bin/server.js`)
- Express server → Error handler: installs handler (evidence: `bin/server.js`)
- Express server → Mongo connector: connects at startup (evidence: `bin/server.js`)
- Mongo connector → MongoDB: connects and queries (evidence: `middlewares/MongoDBConnector.js`)
- Route controller → Mongo connector: requests connections (evidence: `controllers/RouteController.js`)
- Mongo connector → Connection normalizer: pipes records (evidence: `middlewares/MongoDBConnector.js`)
- Route controller → CSA planner: pipes into planner (evidence: `controllers/RouteController.js`)
- Route controller → HTTP client: returns path or error (evidence: `controllers/RouteController.js`)
