This project contains the source code of the backend of the smart city dashboard. It fetches data from different sources and serves as a relay for the frontend.
cd smart-city-dashboard-backend
cp docker-compose.example.yml docker-compose.yml
app
services
docker-compose up -d
The same as "Running the Project" but instead of steps 5 do the following:
yarn
or npm install
docker-compose up -d redis
to run the redis dbyarn start
or npm start
The backend is written in typescript and uses express. For intermediate data store, we are using a redis DB.
We are using typescript for type safety. In order to have consistend formatting / styling of the code, we are using husky, lint-staged and prettier.
src
Source code. This also includes the main entry point
controllers
Controllers fetch data from different sources periodically (format them) and store them into the redis DB (splitted for each data source)lib
Libraries (e.g. redis client)routes
Routes of the API
utils
Helper functionsIf your data source is not behind an api key, you might not need to add the data source to the backend project. You can just access it directly from the frontend. Here you can find more information: https://github.com/reedu-reengineering-education/smart-city-dashboard#how-to-add-a-new-data-source
Otherwise follow these steps:
src/controllers
(you can extend the HTTP Controller) and implement data fetching for your data sourcesrc/routes
on which you want to distribute your datasrc/app.ts
After creating a new file in the src
directory, please run the license-header
script to prepend a comment with license information to the file. You can simply run
yarn license-header # or npm run license-header
which automatically updates the file
Copyright (C) 2022 Reedu GmbH & Co. KG
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.