{"id":26154398,"url":"https://github.com/rcdmk/shortest-flight-path","last_synced_at":"2026-04-19T18:33:45.502Z","repository":{"id":57617321,"uuid":"499642836","full_name":"rcdmk/shortest-flight-path","owner":"rcdmk","description":"Go API that computes and returns the shortest flight path between two airports","archived":false,"fork":false,"pushed_at":"2022-06-03T20:44:54.000Z","size":4135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T15:47:03.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcdmk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-03T20:28:43.000Z","updated_at":"2024-06-19T04:19:31.000Z","dependencies_parsed_at":"2022-08-29T05:40:32.014Z","dependency_job_id":null,"html_url":"https://github.com/rcdmk/shortest-flight-path","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fshortest-flight-path","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fshortest-flight-path/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fshortest-flight-path/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fshortest-flight-path/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcdmk","download_url":"https://codeload.github.com/rcdmk/shortest-flight-path/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242999836,"owners_count":20219577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-11T08:29:28.016Z","updated_at":"2026-04-19T18:33:40.471Z","avatar_url":"https://github.com/rcdmk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shortest flight route\n\nThis application provides an API for searching the shortest routes between airports.\n\n### User Stories (Requirements)\n\n- As a user I can make a GET request to an endpoint with an `origin` and `destination` query parameter, and receive back the shortest route between the two, as an array of connecting flights. A shortest route is defined as the route with the fewest connections. If there are mulitple routes with the same number of connections, you may choose any of them. \n- As a user I am provided meaningful feedback should no route exist between the airports.\n- As a user I am provided meaningful feedback if an error occurred with my request.\n\n\u003e NOTE: THE SHORTEST PATH FUNCTIONALITY MAY NOT RELY ON AN EXTERNAL LIBRARY. YOU MUST DEVELOP THIS ON YOUR OWN.\n\n### Testing\n\nWithin the `data` folder you will find two subdirectories, `test` and `full`. `test` offers a small subset of the data found in `full` which you may use when developing your solution. Your final solution however must be performant with the `full` set.\n\nSome test cases to consider on the `test` data set.\n\n| Origin | Destination | Expected Result          |\n|--------|-------------|--------------------------|\n| YYZ    | JFK         | YYZ -\u003e JFK               |\n| YYZ    | YVR         | YYZ -\u003e JFK -\u003e LAX -\u003e YVR |\n| YYZ    | ORD         | No Route                 |\n| XXX    | ORD         | Invalid Origin           |\n| ORD    | XXX         | Invalid Destination      |\n\n## Running and testing the app\n\n### Requirements\n\n1. Docker\n2. Docker compose\n3. Go 1.12+\n\n### Building and executing\n\nOpen a terminal window, navigate to the source root and run the following command:\n\n```sh\ndocker-compose up\n```\n\nThis will spin up a MySQL container, populate the database, build the application and execute it.\n\nTo stop the application run the following command:\n\n```sh\ndocker-compose down\n```\n\nIt is also possible to execute the application alone, or targeting another db host or container, updating the config file and executing the application as follows:\n\n```sh\ndocker build --tag sfp-api .\ndocker run -d sfp-api\n```\n\n### Testing the app\n\nThe server listens on port `5000` by default. You can change this in `config.toml` file.\n\nThe app contains unit tests for the core logic. Those tests can be run from the source root path with:\n\n```sh\ngo test ./...\n```\n\n#### Routes\n\nAll routes are prefixed using the prefix option in the server section of the config file.\n\n##### `GET /v1/routes`\n\nThis route returns the shortest route between two airports if one exists.\n\n##### Params\n\n**origin:** (query) The route origin airport IATA 3 code\n**destination:** (query) The route destination airport IATA 3 code\n\n###### Results\n\n**200 OK:** Success\n\n```json\n{\"flights\": [{\"origin\":\"JFK\",\"destination\":\"YYZ\",\"airline\":\"AA\"}]}\n```\n\n**404 Not Found:** No route exists\n\n```json\n{\"error\":true,\"message\":\"no route exists between origin and destination\"}\n```\n\n**422 Unprocessable Entity:** Validation error\n\n```json\n{\"error\":true,\"message\":\"invalid origin\"}\n```\n\n**503 Service Unavailable:** Other errors, like database connections, etc.\n\n```json\n{\"error\":true,\"message\":\"Service Unavailable\"}\n```\n\n### Configuration\n\n\u003e ***Note:** This application uses a single configuration file `config.toml` to run. Although there are secrets in the config file, kept there for simplicity in this project, this is not suitable for production. A better way of handling that is to use environment variables or a configuration service, storing only configuration keys in the config file.*\n\nThe config file contains options for setting DB connection and server options.\n\nThe server also supports loading configuration values from environment variables, overriding the config file values. For example, it is possible to override the database password with an environment variable named `API_DB_PASSWORD`. It is also possible to change the server prefix with `API_SERVER_PREFIX`. This feature is available for all configuration options.\n\n### TODO: Improvements\n\n- [ ] Add integration tests\n- [x] Add caching on services\n- [ ] Add caching on API results\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Fshortest-flight-path","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcdmk%2Fshortest-flight-path","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Fshortest-flight-path/lists"}