Skip to content

Project that defines the interface between a database and Reveaal

License

Notifications You must be signed in to change notification settings

Ecdar/Ecdar-API

Repository files navigation

Ecdar-API

Description

Ecdar-API serves as the intermediary between the Ecdar frontend and the Ecdar backend (Reveaal). Its core functionality revolves around storing and managing entities such as users and projects, allowing the backend to focus solely on computations.

The API exposes two GRPC services, namely EcdarBackend and EcdarApi, both defined in the Ecdar protobuffers:

  • The frontend application can contact the backend application as normally, through the EcdarBackend service.
  • The frontend application can use the EcdarApi service to manage entities.

Entities

The following ER diagram encapsulates the high-level description of entities, driven by these specific requirements:

  • Users possess a unique email, a unique username, and a hashed password.
  • Users can create projects that they own.
  • Owners can share projects with other users, granting different access rights.
  • User login initiates a session with a token and creation time.
  • Sessions expire or are deleted when users log off.
  • Projects can only be edited by one user session at a time.
  • Inactivity during project editing allows other users to take over.
  • A project comprises a name, a JSON/XML component representation, and multiple queries.
  • Queries store strings and results, marking them as outdated if the associated project is edited.

ER Diagram

Leading to the following schema diagram.

DB Diagram

Ecdar-API offers implementations for both postgreSQL and sqlite databases.

Development

Prerequisites:

  • Install rust/cargo.
  • Install Docker and Docker Compose (both come with Docker Desktop).
  • Install sea-orm-cli (cargo install sea-orm-cli).
  • Set up an .env file by copying and configuring .env.example.

Set up Docker PostgreSQL DB:

  • Run docker-compose up -d to create two PostgreSQL databases (one for testing).
  • Run sea-orm-cli migrate up to migrate the db-schema (requires DATABASE_URL in .env).

After modifying migration files:

  • Run sea-orm-cli migrate fresh to drop and reapply all migrations.
  • Run sea-orm-cli generate entity -o src/entities to regenerate the files in src/entities.

Run tests:

  • Execute cargo test -- --test-threads=1.

Generating documentation

  • Execute cargo doc --no-deps --open

Simulating Frontend:

  • Ecdar-API can be contacted via GRPC from Postman.
  • Useful for integration testing.
  • No shared Postman collection currently exists.
  • Follow this guide to create custom requests.

About

Project that defines the interface between a database and Reveaal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages