Skip to content

Commit

Permalink
Merge branch 'main' into neo4j-starter-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
johnymontana authored Jan 8, 2025
2 parents 091672a + 4c85398 commit 570b80d
Show file tree
Hide file tree
Showing 45 changed files with 6,786 additions and 620 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- ready_for_review
paths:
- "**.go"
- "**.mod"
- "**.sum"
- "**.ts"
- "**.json"
- .github/workflows/*
Expand Down
120 changes: 60 additions & 60 deletions dgraph-101/api-as/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dgraph-101/api-as/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"pretty:check": "prettier --check ."
},
"dependencies": {
"@hypermode/modus-sdk-as": "^0.15.0",
"@hypermode/modus-sdk-as": "^0.16.0",
"assemblyscript-json": "^1.1.0",
"json-as": "0.9.26"
},
Expand Down
138 changes: 138 additions & 0 deletions dgraph-modus-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Movie Recommendation App

This project demonstrates the power of **Modus** and **Dgraph** by integrating a graph database with
a large language model (LLM) to provide AI-driven movie recommendations. The app consists of a
backend (powered by Modus and Dgraph) and a frontend (built with Next.js and tailwind).

## Why Use Modus with Dgraph?

**Modus** simplifies the integration of internal data (from sources like Dgraph) with cutting-edge
LLMs. Here's why this combination is powerful:

- **Rich Data Queries**: Dgraph enables complex queries across interconnected datasets like movies,
genres, actors, and directors. This makes it ideal for graph-based recommendations.
- **Seamless AI Integration**: Modus abstracts the complexity of using LLMs, allowing you to feed
internal data into models and retrieve actionable insights tailored to your data.
- **Rapid Prototyping**: With Modus, you can quickly build and test serverless functions that
combine graph-based querying and AI recommendations.
- **Customizability**: Dynamically construct prompts for LLMs using Dgraph's query results to
generate personalized outputs, such as movie recommendations.

---

## Backend Setup

The backend is written in Go using **Modus** and **Dgraph**.

### Features

- Functions powered by Modus are integrated with a read-only Dgraph database and an LLM from Hugging
Face.
- Provides a GraphQL endpoint for querying data locally.
- Demonstrates how to use Modus to create powerful, serverless APIs that leverage Dgraph's
capabilities and LLM-driven insights.

### Prerequisites

- Install **Modus CLI**: Follow the
[Modus installation guide](https://docs.hypermode.com/modus/installation).
- Ensure **Dgraph** is available or connected to the backend (the project uses a read-only Dgraph
database).

### Running Backend Locally

Move into the `backend` directory:

```bash
cd backend
```

Install dependencies (if required):

```bash
go mod tidy
```

Start the backend using Modus:

```bash
modus dev
```

Access the local endpoint:

- GraphQL API Explorer: `http://localhost:8686/graphql`
- Query APIs or explore the auto-generated schema directly in the explorer.

Key Notes - Functions are defined in Go and connected to a read-only Dgraph database. - The backend
integrates with an LLM to generate movie recommendations dynamically. - Check the Modus logs to see
which endpoints and functions are exposed.

---

## Frontend Setup

The frontend is built with **Next.js** and **Tailwind**.

### Frontend Features

- Search for movies by title or related fields.
- View movie details, including release year, genres, and starring actors.
- Get AI-driven recommendations for similar movies.

### Running Frontend Locally

Move into the frontend directory:

```bash
cd frontend
```

Install dependencies:

```bash
npm install
```

Start the development server:

```bash
npm run dev
```

4. Open the app in your browser: `http://localhost:3000`.

### Important

- Ensure the backend is running locally for the frontend to fetch data and generate recommendations.
- The backend API endpoints are integrated into the frontend through `actions.ts`.

---

## How It Works

1. Backend:

- Queries Dgraph for movie data using GraphQL-like queries.
- Dynamically generates prompts for the LLM to fetch recommendations.
- Returns combined movie details and recommendations as a JSON response.

2. Frontend:

- Fetches data from the backend's GraphQL endpoints.
- Displays movie details and AI-generated recommendations.
- Provides a clean, user-friendly interface for exploring movies and related data.

---

## Learning More

- Modus Documentation:
[https://docs.hypermode.com/modus/overview](https://docs.hypermode.com/modus/overview)
- Dgraph Documentation: [https://dgraph.io/docs](https://dgraph.io/docs)
- Next.js Documentation: [https://nextjs.org/docs](https://nextjs.org/docs)

---

This project is an excellent starting point for understanding how to combine the strengths of
Dgraph, Modus, and LLMs to create powerful, data-driven applications. 🚀
Loading

0 comments on commit 570b80d

Please sign in to comment.