Skip to content

Commit

Permalink
chore: documenting proposal for solution to database ADR (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
gphorvath committed Apr 18, 2024
1 parent 7efcebf commit 7a3a0ad
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/e2e-shim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

# Catch docs and website things
- "**.md"
- "adr/**"
- "docs/**"
- "website/**"
- "netlify.toml"
Expand All @@ -17,7 +18,7 @@ on:
- "CODEOWNERS"
- ".gitignore"
- "LICENSE"
- "pre-comimt-config.yaml"
- "pre-commit-config.yaml"

# Catch pytests
- "tests/pytest/**"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
# Ignore docs and website things
- "!**.md"
- "!docs/**"
- "!adr/**"
- "!website/**"
- "!netlify.toml"

Expand Down
2 changes: 1 addition & 1 deletion adr/0000-adr-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
## Decision
[Describe the decision made]

## Consequences
## Rationale
[Describe the potential consequences and impacts of the decision]

## Alternatives
Expand Down
4 changes: 2 additions & 2 deletions adr/0001-vectordb-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- [VectorDB](#vectordb)
- [Table of Contents](#table-of-contents)
- [Summary](#summary)
- [Status](#status)
- [Issue](#issue)
- [Decision](#decision)
- [Rationale](#rationale)
Expand Down Expand Up @@ -35,7 +35,7 @@ We decided on ChromaDB due to it's simple implementation, performance, and Apach

### Status

Provisional
SUPERSEDED by [0003-database](0003-database.md)

## Context

Expand Down
61 changes: 61 additions & 0 deletions adr/0003-database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# LeapfrogAI Database

## Table of Contents

- [LeapfrogAI Database](#leapfrogai-database)
- [Table of Contents](#table-of-contents)
- [Status](#status)
- [Background](#background)
- [Decision](#decision)
- [Rationale](#rationale)
- [Alternatives](#alternatives)
- [Related ADRs](#related-adrs)
- [References](#references)

## Status

PROPOSED

## Context

LeapfrogAI began with a need for a basic vector store. As LeapfrogAI expands into providing a production ready front end the demands of the database expand to include authentication, user data, object storage, and additional data types for Retrieval Augmented Generation. This ADR proposes ***Supabase*** as a single database solution for all current LeapfrogAI needs.

## Decision

Move to Supabase for all current LeapfrogAI Database needs.

## Rationale

### General Features
- Open Source, Apache 2.0 license
- Integrates easily into frontend with SDK
- Easy to run Supabase locally for development
- Row Level Security with Postgres enables protection of data at the request level
- Supabase Auth system integrates with Keycloak to enable UDS SSO (OpenID)
- [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) is user friendly and feature rich. The CLI can be used for initializing and configuring the database, then saving schemas and migrations to make our configuration easily reproducible and deployable. It can also be used to [automate tests via GitHub Actions](https://supabase.com/docs/guides/cli/github-action/testing)
- Additional features built in if we need them in the future - like realtime subscriptions and edge functions
- Well supported and adopted in the community, also supports various frameworks (Svelte, Nuxt, Next.js, React, Flutter, etc...)
- Documentation provides lots of useful examples/recipes although documentation for self-hosted situations can be outdated

### As Vector Store:

- Supabase has a pgvector extension for supporting vector storage for RAG
- Because Supabase is Postgres/pgvector under the hood, is it is compatible with a multitude of Python libraries ([LangChain](https://python.langchain.com/docs/integrations/vectorstores/supabase), [LlamaIndex](https://docs.llamaindex.ai/en/stable/examples/vector_stores/SupabaseVectorIndexDemo/), [Vecs](https://github.com/supabase/vecs), [NeumAI](https://github.com/NeumTry/NeumAI), etc.)
- [Supabase Buckets](https://supabase.com/docs/guides/storage/buckets/fundamentals) provides object storage that is compatible with other Supabase security features. Buckets will be useful for storing and retrieving the source files used by our API (Files and Assistants endpoint).

## Alternatives

- Per our previous ADR, [0001-vectordb-backend](0001-vectordb-backend.md), ChromaDB is a lightweight offering, but we continued to grow we discovered it doesn't offer many of the security and scaling features that Supabase provides (Row Level Security, Auth, etc.).

## Related ADRs
* [0001-vectordb-backend (Superseded)](0001-vectordb-backend.md)

## References
- [Supabase Documentation](https://supabase.com/docs/)
- [Supabase CLI Documentation](https://supabase.com/docs/guides/cli/getting-started)
- [Supabase Buckets](https://supabase.com/docs/guides/storage/buckets/fundamentals)
- [LangChain Python Library](https://python.langchain.com/docs/integrations/vectorstores/supabase)
- [LlamaIndex Python Library](https://docs.llamaindex.ai/en/stable/examples/vector_stores/SupabaseVectorIndexDemo/)
- [Vecs Python Library](https://github.com/supabase/vecs)
- [NeumAI Python Library](https://github.com/NeumTry/NeumAI)
- [ChromaDB ADR](0001-vectordb-backend.md)

0 comments on commit 7a3a0ad

Please sign in to comment.