thruflo

thruflo

Hi,

I’d like to introduce IntegrateDB – Intro — IntegrateDB v0.1.0 – a database sharing toolkit project that I’ve made in Elixir.

I’d love for some feedback and any thoughts on it. The idea is inspired by projects like React, Tailwind and LiveView, in that it aims to boost developer productivity by deliberately coupling concerns that “received wisdom” holds should be kept separate.

Basically integrating services directly through the database is usually seen as a smell, so we all build APIs and loosely coupled SOAs. But in many cases this can be overkill and actually if you could integrate through the database you could eliminate layers and go much faster. Especially if you’re making LiveView apps where you don’t need an API and you have Ecto at your disposal …

The problem is that having multiple services using the same data is a recipe for disaster – unless you have some way of declaring and controlling data dependencies whilst enabling schema evolution. Which (as you may have guessed!) is exactly what IntegrateDB does :wink:

It’s a Phoenix-based web application that sits alongside a Postgres database. You interact with a JSON API to declare data dependencies and generate scoped db user credentials (which you then give to your applications for them to connect directly to the database — they don’t talk to IntegrateDB at all, it’s not a proxy or an extension).

It then adds a user defined function to your database which you can call from your migrations to validate that they don’t break any of your declared data dependencies. It also sets up and consumes a logical replication feed (hence being Postgres only for now), with the idea being to convert events that you register for into higher level notifications for your apps.

All of which is designed to allow you to break the rules and integrate straight through the database without shooting yourself in the foot.

The code is at GitHub - integratedb/integrate: Core IntegrateDB source code repository. · GitHub, the docs are at IntegrateDB v0.1.0 — Documentation and the website is https://integratedb.org

I’d love to get some feedback on the project.

Thanks,

James.

Showing Posts 1 to 10

halostatue

halostatue

This seems really good. The only comment I have on reading is that when you are able to move more toward security, it might be worth looking at what Hashicorp Vault does regarding temporary credentials for access so that the stakeholder bootstrapping process might be able to not have setup configurations that are wholly manual.

thruflo

thruflo OP

@halostatue yup, that’s a great suggestion, thank you.

I have been thinking about some kind of more automatic bootstrapping, for example accepting an env var with a pub key for the the root user. Maybe a config file for stakeholders. Would be very interesting to think about pushing stakeholder creds to a secure store automatically. Could be vault, or perhaps into a k8s secret?

Exadra37

Exadra37

Example - integrate a reporting application

Imagine that you have a primary web application with a Postgres database and that you want to integrate a reporting system. Assume you’ve installed IntegrateDB and bootstrapped a root user. You then start by creating a Stakeholder representing your secondary reporting application:

curl -X POST -H "..." -d '{"name": "reporter"}' /api/v1/stakeholders

This creates a Postgres database user (reporter) with access scoped to its own private DDL schema (reporter.*) and returns the database user credentials in the response data:

{
  "data": {
    "credentials": {
      "username": "reporter", 
      "password": "... randomly generated ...",
    }
  }
}

Save the credentials (somewhere safe!) and provide them to your reporting application as the database user and password it should use to connect directly to the Postgres database.

Unless I misunderstood you want to give the user and password to a client in the web to access the database directly?

Also, the cURL request can be done from a client in the internet?

thruflo

thruflo OP

Unless I misunderstood you want to give the user and password to a client in the web to access the database directly?

Yup, I think it’s a slight misunderstanding in that the user and password are meant to be given to an application, not to a client. I.e.: think a Phoenix app which you would typically provide a DATABASE_URL to, not a React client that might typically talk to an API endpoint.

Thanks for flagging up as I should make that clear. You definitely shouldn’t expose the db user credentials publicly :slight_smile:

Also, the cURL request can be done from a client in the internet?

IntegrateDB is an application you would deploy on your infrastructure (server / cloud / cluster) fairly close to / alongside your database. So you can lock down access as you prefer – network firewall, RBAC, reverse proxy, etc.

The API is also envisaged as something more for an operator to talk to (a CLI is on the roadmap) or to use as part of an provisioning workflow. It would be unusual for your application to talk to it.

Hope that makes sense :slight_smile:

Exadra37

Exadra37

It makes more sense now, but from a security point of view I am always suspicious when databases are being exposed directly as an API.

You should strive to make clear that the API is internal and should be on a private network, but even so I would require authentication to the internal API.

thruflo

thruflo OP

Yup, maybe a “security considerations” section in the docs.

I’m conscious that there’s more that could be done to make access to the IntegrateDB app more fine grained – right now any user can do anything to any stakeholder including claiming access to any arbitrary data. That’s definitely an area for improvement.

It’s also interesting to consider whether it needs to be a running application service at all. Perhaps it could be spun up and down, or just run locally or even just be reimagined as a CLI tool?!

Exadra37

Exadra37

Why just not a library that other applications can use programmatically?

brightball

brightball

It’s an often overlooked and under appreciated need. I once had a project where I needed to connect two systems and my options were to either build an API so one application could read from the other…or connect the databases so I could just query both at the same time.

Went with door #2 and the entire urgent project was done in 2 weeks. Not a single hiccup was experienced.

thruflo

thruflo OP

Exactly :slight_smile:

There are some nuances. Particularly the replication consumer and notifications system as envisaged need to be a running service. However, it may well be possible to refactor out so these are different tools in the box – a library / local ops client and a notification service. The latter could run with just replication permission and wouldn’t expose the db in the same way.

Thanks for the suggestion, much to ruminate on!

thruflo

thruflo OP

@brightball could I use this as a quote if I get round to posting some?!

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews