Skip to content
/ InfDB Public

A comprehensive database system of energy infrastructure components with integrated geospatial and time-series capabilities.

License

Notifications You must be signed in to change notification settings

tum-ens/InfDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repo logo

infDB - Infrastructure and Energy Database

The infDB is a user-friendly, platform-independent, and open-source data infrastructure as a foundation for energy system analyses. It enables complex evaluations by combining various tools through standardized interfaces, fostering an open and interoperable ecosystem.

Category Badges
License License
Documentation Documentation
Development Open Issues Closed Issues Open MRs Closed MRs
Community Contributing Contributors Repo Count

Table of Contents

Purpose

infDB (Infrastructure Database) offers a flexible and easy-to-configure data infrastructure with essential services, minimizing the effort required for data management. By providing standardized interfaces and APIs, infDB streamlines collaboration in energy modeling and analysis, enabling users to focus on insights rather than data handling.

For instance, it can be used for the following applications:

  • Energy System Modeling
  • Infrastructure Planning
  • Scenario Analysis
  • Geospatial Analysis

How it works?

The infDB architecture is composed of three coordinated layers as shown in the figure below:

  1. 3D City Database – foundational geospatial and semantic building data (center)
  2. Services – preconfigured platform services (top)
  3. Tools – external connected software and scripts. (right)

The 3D City Database is the basis and extended by services and tools. More information of each layer is described below. The 3D City Database and all services are dockerized for a modular and flexible application. alt text

3D City Database

The 3D City Database is developed by the Chair of Geoinformatics at Technical University of Munich (TUM) and the basis for infDB. It is a solution for managing, analyzing, and utilizing virtual 3D city models on top of a spatial database system. More information on http://www.3dcitydb.org/

Services

Integrated, preconfigured services extending the 3D City Database:

  • TimescaleDB: Scalable time-series storage (weather, load, generation) with hypertables, compression, optional continuous aggregates.
  • pgAdmin: Web UI for inspecting schemas, running SQL, managing roles; auto-configured credentials.
  • FastAPI: REST endpoints (/city, /weather) with OpenAPI docs and validated access to 3D, geospatial, and time-series data.
  • Jupyter: Notebook environment (dependencies and env vars preloaded) for exploratory queries, ETL prototypes, reproducible analysis.
  • QWC2: Web mapping client for 2D/3D visualization, layer styling, spatial inspection, quick dataset validation.
  • PostgREST: Auto-generated REST API over PostgreSQL schemas (tables, views, RPC) using DB roles for auth; rapid, lightweight data access without extra backend code.
  • pygeoapi: OGC API (Features/Coverages/Processes) server exposing PostGIS data via standards-based JSON & HTML endpoints for interoperable geospatial discovery and querying.

These services provide core functionalities and support a seamless path from ingestion to analysis and visualization.

Tools

Tools are external software that is already adopted to the infDB.

Currently integrated tools include:

  • infDB-loader: Containerized automated loading public open data for Germany
  • infDB-processor: Containerized data transformation and enrichment
  • pylovo: Tool for generating synthetic low-voltage distribution grids

More community or domain-specific tools can be attached through the standardized APIs and database schemas.

Getting Started

To get started, follow these steps below. For more information in detail read the https://infdb.readthedocs.io/.

If you are happy with the preconfiguration and default passwords, then just follow these four steps (see detailed instructions in the corresponding sections below):

  1. Clone infDB
  2. Setup infDB
  3. Run infDB
  4. Optional: Run infDB-loader

Suggested folder structure of infDB

The folder structure of the infdb as shown is recommend since all of the data of all instances are stored in 'data' automatically by default:

  • infdb
    • data
    • instance1
    • ...
    • instanceN
# linux
mkdir infdb
cd infdb

Clone infDB

# ssh
# Replace "demo" by name of instance 
git clone git@gitlab.lrz.de:tum-ens/need/infdb.git demo 

# https
# Replace "demo" by name of instance 
git clone https://gitlab.lrz.de/tum-ens/need/infdb.git demo

# Change directory into repo
cd demo

Setup infDB

The configuration can be done via configs/config-infdb.yml

base:
    name: demo
    path:
        base: "../data/{base/name}/"
    network_name: "infdb-{base/name}_network"
services:
    citydb:
        user: citydb_user
        password: infdb
        db: citydb
        host: citydb
        exposed_port: 5432
        epsg: 25832 # 3035 (Europe)
        path: 
            base: "{base/path/base}/{base/name}/citydb/"
            compose_file: "services/3dcitydb/compose.yml"
        status: active

        ...

After doing the configuration you need to generate the configurations files with the following command:

# on linux and macos
docker compose -f services/setup/compose.yml up

# on windows

Once you generated the configuration files with the command above, you need to finally start the infDB:

Run infDB

# on linux and macos
  docker compose -f compose.yml up -d

# on windows

The infDB will be run as long as you stop it manually as described below even when the machine is restarted.

Hint: If compose.yml is not found, you either forgot to run the command above or something went wrong. Please check the logs of the setup service.

Hint: The infDB will be run as long as you stop it manually as described below even when the machine is restarted.

Stop infDB

# on linux and macos
docker compose -f compose.yml down -v

# on windows

Setup infDB-loader

The configuration can be done via configs/config-loader.yml

loader:
    name: demo-sonthofen
    scope:  # AGS (Amtlicher GemeindeschlĂĽssel)
        # - 09162000  # Munich
        - "09780139"  # Sonthofen
        # - "09780116"  # Bolsterlang
        # - "09162000" # M
        # - "09185149" # ND
        # - "09474126" # FO
        # - "09261000" # LA
    multiproccesing: 
        status: active
        max_cores: 4    # max cores since of memory limitations to 2
    config-infdb: "config-infdb.yml" # only filename - change path in ".env" file "CONFIG_INFDB_PATH"
    path:
        base: "data" # only foldername - change path in ".env" file "LOADER_DATA_PATH"
        opendata: "{loader/path/base}/opendata/"
        processed: "{loader/path/base}/{loader/name}"
    logging:
        path: "{loader/path/base}/loader.log"
        level: "DEBUG" # ERROR, WARNING, INFO, DEBUG
    hosts:
        citydb:
            user: None
            password: None
            db: None
            host: None
            exposed_port: None
            epsg: None # 3035 (Europe)
        timescaledb:
            user: None
            password: None
            db: None
            host: None
            exposed_port: None
    sources:
        package:
            status: active
            url: http://ds1.need.energy:8123/opendata.zip
            path: 
                base: "{loader/path/base}"
                processed: "{loader/path/opendata}"

        lod2:
            status: not-active
            url:
                - "https://geodaten.bayern.de/odd/a/lod2/citygml/meta/metalink/#scope.meta4"    #scope placeholder for AGS
            path:
                lod2: "{loader/path/opendata}/lod2/"
                gml: "{loader/path/opendata}/lod2/{loader/name}"
        ...

Hint: In case you move the infdb-loader source folder outside of the folder tools in repo or want to change the location where the downloaded data is stored, the paths to data and to configs folder need to be defined in .env

CONFIG_INFDB_PATH=../infdb/configs  # Change if you moved the "configs" folder
LOADER_DATA_PATH=./     # Change if you moved the "data" folder

Once you adjusted the configuration files with the command above, you need to finally start the infDB-loader and start importing:

Run infDB-loader

# on linux and macos
  docker compose -f tools/infdb-loader/compose.yml up

# on windows

Run infDB-preprocessor

# on linux and macos
  docker compose -f tools/infdb-preprocessor/compose.yml up

# on windows

Remove LOD2 data

# on linux and macos
docker run --rm --add-host=host.docker.internal:host-gateway 3dcitydb/citydb-tool delete --delete-mode=delete -H host.docker.internal -d citydb -u citydb_user -p citydb_password -P 5432

# on windows

PSQL Connection to infDB

# on linux and macos
PGPASSWORD='citydb_password' psql -h localhost -p 5432 -U citydb_user -d citydb

# on windows

Configurations (only in addition for QGIS Desktop)

.pg_service.conf for QGIS to connect to InfDB via service

[infdb]
host=localhost
port=5432
dbname=citydb
user=citydb_user
password=citydb_password
sslmode=disable

For Developers

Local development environment for InfDB for developers

# on linux and macos by installation script
curl -LsSf https://astral.sh/uv/install.sh | sh
# or by pip
pip install uv

Create environment (only once)

# linux and macos
uv sync

Activate environment

# linux and macos
source .venv/bin/activate
# windows
venv\Scripts\activate

Clean repo

# linux and macos
git fetch origin
git reset --hard origin/develop
git clean -fdx
# windows

Repository Structure

  • src/: Main application package
    • api/: API endpoints (cityRouter.py, weatherRouter.py)
    • core/: Core application code (dbConfig.py, etc.)
    • db/: Database models and repositories
      • models/: SQLModel classes for database entities
      • repositories/: Data access layer for database operations
    • exceptions/: Custom exception classes
    • externals/: External API integrations (e.g., weather API)
    • schemas/: Data schemas and validation
    • services/: Business logic services
    • main.py: Application entry point
  • docs/: Documentation
    • architecture/: System architecture documentation
    • contributing/: Contribution guidelines and code of conduct
    • development/: Developer guides and workflows
    • guidelines/: Project guidelines and standards
    • operations/: Operational guides and CI/CD documentation
    • source/: Source files for documentation
    • img/: Images used in documentation
  • dockers/: Docker configuration files
  • tests/: Test suite
    • unit/: Unit tests for individual components
    • integration/: Tests for component interactions
    • e2e/: End-to-end tests for the application
    • conftest.py: Pytest configuration and fixtures

Development Workflow

  1. Set up the environment following the installation instructions.
  2. Open an issue to discuss new features, bugs, or changes.
  3. Create a new branch for each feature or bug fix based on an issue.
  4. Implement the changes following the coding guidelines.
  5. Write tests for new functionality or bug fixes.
  6. Run tests to ensure the code works as expected.
  7. Create a merge request to integrate your changes.
  8. Address review comments and update your code as needed.
  9. Merge the changes after approval.

CI/CD Workflow

The CI/CD workflow is set up using GitLab CI/CD. The workflow runs tests, checks code style, and builds the documentation on every push to the repository. You can view workflow results directly in the repository's CI/CD section. For detailed information about the CI/CD workflow, see the CI/CD Guide.

Development Resources

The following resources are available to help developers understand and contribute to the project:

Coding Guidelines

The Coding Guidelines document outlines the coding standards and best practices for the project. Start here when trying to understand the project as a developer.

Architecture Documentation

The Architecture Documentation provides an overview of the system architecture, including the database schema, components, and integration points.

Developer Guides

Contribution Guidelines

Operations Documentation

  • CI/CD Guide: Detailed information about the CI/CD workflow

Contribution and Code Quality

Everyone is invited to develop this repository with good intentions. Please follow the workflow described in the CONTRIBUTING.md.

Coding Standards

This repository follows consistent coding styles. Refer to CONTRIBUTING.md and the Coding Guidelines for detailed standards.

Pre-commit Hooks

Pre-commit hooks are configured to check code quality before commits, helping enforce standards.

Changelog

The changelog is maintained in the CHANGELOG.md file. It lists all changes made to the repository. Follow instructions there to document any updates.

License and Citation

The code of this repository is licensed under the MIT License (MIT).
See LICENSE for rights and obligations.
See the Cite this repository function or CITATION.cff for citation of this repository.
Copyright: TU Munich - ENS | MIT

About

A comprehensive database system of energy infrastructure components with integrated geospatial and time-series capabilities.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 16