This repository holds the following components:
api
- the proto API definition in the CampusService.proto
.client
- example client for how to connect to the backend.server
- the actual server implementation serving both REST at api.tum.app
and gRPC endpoints at api-grpc.tum.app.The API is publicly available for anyone, but most notably, it's the main backend system for the TUM Campus Apps (Android, iOS, and Windows).
The backend uses MySQL as its backend for storing data. While it is possible to install mysql natively (instructions are on their website), we recommend the following:
docker run
To setup the DB, connect to your DB server or use mysql
to connect to it locally.
DROP DATABASE campus_backend; -- Drop an eventually existing old DB
CREATE DATABASE campus_backend; -- Create a new DB for the backend
CREATE USER 'gorm'@'localhost' IDENTIFIED BY 'gorm'; -- Create a new user called `gorm`.
GRANT ALL PRIVILEGES ON campus_backend.* TO 'gorm'@'localhost'; -- Garant our `gorm` user access to the `campus_backend` DB.
ALTER USER 'gorm'@'localhost' IDENTIFIED BY 'GORM_USER_PASSWORD'; -- Set a password for the `gorm` user.
FLUSH PRIVILEGES;
To start the server there are environment variables, as well as command line options available for configuring the server behavior.
cd server
export DB_DSN="Your gorm DB connection string for example: gorm:GORM_USER_PASSWORD@tcp(localhost:3306)/campus_db?charset=utf8mb4&parseTime=True&loc=Local"
export DB_NAME="The DB-name from above string for example: campus_backend"
go run ./main.go
There are a few environment variables available:
DB_DSN
: The GORM DB connection string for connecting to the MySQL DB. Example: gorm@tcp(localhost:3306)/campus_db?charset=utf8mb4&parseTime=True&loc=Local
DB_NAME
: The name of the database from above connection string. Example: campus_backend
SENTRY_DSN
: The Sentry Data Source Name for reporting issues and crashes.docker compose -f docker-compose.local.yml up -d
The docker compose will start the server and a mysql instance (=> without routing/certificates to worry about)
The server will be available at localhost:50051
and the mysql instance at localhost:3306
.
Additionally, docker creates the volume campus-db-data
to persist the data of the mysql instances.
The following environment variables need to be set for the server to work properly:
DB_NAME
: The name of the database to use.DB_USER_PASSWORD
: The password of the user.DB_USER_NAME
: Name of the user to connect as. Defaults to root
.DB_PORT
: The port of the database server. Defaults to 3306
.SENTRY_DSN
: The Sentry Data Source Name for reporting issues and crashes.OMDB_API_KEY
: The key to get more information for tu-film movies from omdbapi. See omdbapi for a key.Our service uses prometheus to collect metrics to display in grafana.
To see the metrics we aggregate, head over to http://localhost:50051/metrics
The iOS Push Notifications Service can be used to send push notifications to iOS devices.
There are already predefined Visual Studio Code launch tasks for debugging the client and server.
Take a look at the launch.json
file for more details.
Please be respectful with its usage!
To ensure that that common pitfalls which can be automated are not done, we recommend you to install pre-commit
.
You can do so via
python -m venv venv
source venv/bin/activate
pip install pre-commit
pre-commit install
Certain pre-commit
hooks will now be run on every commit where you change specific files.
If you want to run all files instead, run pre-commit run -a