{"id":13826028,"url":"https://github.com/brakmic/OpenLok","last_synced_at":"2025-07-08T23:30:55.126Z","repository":{"id":83787352,"uuid":"52786481","full_name":"brakmic/OpenLok","owner":"brakmic","description":":light_rail: React.js app to access the Deutsche Bahn API (German Railway Corporation)","archived":true,"fork":false,"pushed_at":"2017-06-18T09:28:41.000Z","size":2979,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-05T09:14:48.619Z","etag":null,"topics":["bahn","german","hapi","react"],"latest_commit_sha":null,"homepage":"","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brakmic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-29T11:33:20.000Z","updated_at":"2023-04-17T22:00:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"a23d3d33-7953-4bff-a437-96b820260ac5","html_url":"https://github.com/brakmic/OpenLok","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brakmic%2FOpenLok","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brakmic%2FOpenLok/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brakmic%2FOpenLok/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brakmic%2FOpenLok/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brakmic","download_url":"https://codeload.github.com/brakmic/OpenLok/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225470631,"owners_count":17479366,"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":["bahn","german","hapi","react"],"created_at":"2024-08-04T09:01:30.993Z","updated_at":"2024-11-20T04:31:12.394Z","avatar_url":"https://github.com/brakmic.png","language":"CSS","funding_links":[],"categories":["CSS"],"sub_categories":[],"readme":"### OpenLok :train:\n\n\n  ![alt text](https://s32.postimg.org/jj6vsthth/ICE_Network.png \"Germany's Rail Network\")\n\n---\nA small project utilizing the [Deutsche Bahn API](http://www.bahn.de)\n\n[Wikipedia entry](https://en.wikipedia.org/wiki/Deutsche_Bahn) on DB (*German Railway Corporation*)\n\nDeutsche Bahn opened some of their APIs for public consumption and this project should serve as an API-playground.\n\nFor more detailed info on the API itself read [this article](http://www.heise.de/newsticker/meldung/Open-Data-Deutsche-Bahn-gibt-Schnittstelle-fuer-Fahrplandaten-frei-3118919.html) (in German)\u003c/a\u003e\n\nThe Homepage of the API is located [here](http://data.deutschebahn.com/index.html).\n\nThe API Descriptions can be found [here](http://data.deutschebahn.com/apis/fahrplan/Fpl-API-Doku-Open-Data-BETA-0_81.pdf) (pdf, in German)\u003c/a\u003e\n\n##### Structure\n\nThe Frontend is built with [React.js](https://facebook.github.io/react/) and supports hot-reloading via [WebPack](https://webpack.github.io/). More info regarding hot-reloading of React components can be found [here](https://gaearon.github.io/react-hot-loader/getstarted/).\n\nThe Backend is based on [Hapi.js](http://hapijs.com/) which is my favorite **node web server**. The Frontend uses this backend to avoid problems with CORS. Therefore, the App executes no direct calls against the real DB-API but instead against Hapi.js that is configured *to accept CORS*.\n\nThere's a special class called *BahnService** that's being used by both client and server to make API calls. *BahnService* runs either in _local_ or _remote_ mode. The Client runs on _local_ to dispatch the API calls to the local Hapi.js instance which in turn uses the _remote_ instance of *BahnService* to access the real [DB API](http://data.deutschebahn.com/).\n\nThis may sound unnecessarily complex but the strategy is rather simple: *a Client only wants to have a direct access to 'some API' without fiddling around with CORS etc.* Therefore, Hapi.js takes care of providing us an easy to use, **RESTful API** that returns plain JSONs.\n\nThe advantage is obvious: you can mock and test your API without dealing with CORS or any other implementation details.\n\nFor example, the client could send a GET request querying the location 'Cologne':\n\n``` shell\nhttp://localhost:3000/locations/Cologne\n```\nwhich on Hapi.js side would then be translated into a server-side GET request:\n``` shell\nhttps://open-api.bahn.de/bin/rest.exe/location.name?authKey=YOUR_AUTH_KEY\u0026lang=de\u0026input=Cologne\u0026format=json\n```\n\nFinally, you'd receive a plain JSON-structure containing the location data. The JSON-structure remains unchanged as Hapi.js only forwards the responses back to the client.\n\n##### Client\n\n\u003cimg src=\"https://i.imgsafe.org/d788893fe5.png\"/\u003e\n\n##### Local API Server\n\n\u003cimg src=\"https://i.imgsafe.org/d4787bc983.png\"/\u003e\n\n##### Current Status\n\nThe Client is rather primitive as it only contains a very bare-bones React component and a few \u003ca href=\"http://getbootstrap.com/\"\u003eBootstrap\u003c/a\u003e elements (button, input, panel etc.).\n\nThe Calendar Widgets are from [React Widgets Project](https://jquense.github.io/react-widgets/docs/#/datetime-picker).\n\nThe Server implements only the [Location.name API](http://data.deutschebahn.com/apis/fahrplan/) but soon they'll be more of them.\n\n##### Building \u0026 Running\n\n*Prerequisites*\n\n```\nnpm install\n```\n\n*Client*\n\n``` shell\nnpm run client\n```\n\nClient is located at [http://localhost:8080](http://localhost:8080/)\n\n*Local API*\n\n``` shell\nnpm run api\n```\n\nAPI-Server listens on [http://localhost:3000](http://localhost:3000/)\n\n##### Testing\n\n[Mocha](https://mochajs.org/) \u0026 [Chai](http://chaijs.com/) with ES6.\n\nMore info on testing ES6 code with Mocha can be found [here](http://jamesknelson.com/testing-in-es6-with-mocha-and-babel-6/).\n\n``` shell\nnpm test\n```\n\n##### FAQ\n\n- **What do 'BahnService' and 'OpenLok' mean?**\n\n*Bahn* is a German word and heavily context-dependent. In this case it means 'Train'.\n\nHowever, you can find it in a number of different locations, for example:\n\n- Auto*bahn*    = motorway\n- Flug*bahn*    = trajectory\n- Straßen*bahn* = tram (Br.), streetcar (Am.)\n\nand many others.\n\n*Lok* is an abbreviation of 'Lokomotive' which means `locomotive`.\n\nThere's also a similar English abbreviation `loco`.\n\nBuilding compound words is very easy in German. :speech_balloon:\n\nYou can learn it [here](https://www.goethe.de/en/spr/kup.html) :smile:\n\n- **Where to get the API-Key?**\n\nTo access the DB-API you'll need an API-Key. To get one use this email:  *dbopendata @ deutschebahn.com*\n\nThen put it into *authKey* in *BahnService.js*\n\n\u003cimg src=\"http://fs5.directupload.net/images/160229/fgxliqik.png\"/\u003e\n\n\n\n#### License\n\n[MIT](https://github.com/brakmic/OpenLok/blob/master/LICENSE)\n\n**Deutsche Bahn®** is a registered trademark of **Deutsche Bahn AG** in Germany and/or other countries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrakmic%2FOpenLok","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrakmic%2FOpenLok","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrakmic%2FOpenLok/lists"}