Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

tigrisdata-archive/demo_relicx_search

Repository files navigation

Relicx session search demo with Next.js (REST API)

This example shows how to implement a fullstack app in TypeScript with Next.js using React and Tigris TypeScript SDK.

Getting started

1. Install the packages

npm install

2. Setup the environment variables

Setup the client credentials locally. You can grab the client credentials from the Application Keys page for your project. Copy the file .env.example to .env and fill in the values of the environment variables TIGRIS_CLIENT_ID and TIGRIS_CLIENT_SECRET.

3. Start the app in development mode

npm run dev

The app is now running, navigate to http://localhost:3000/ in your browser to explore its UI.

Expand for a code walkthrough

Deployment

The app is setup to be deployed to fly.io which is a modern application deployment platform.

The application can be deployed by using the following command:

fly deploy

👀 Code walkthrough

📂 File structure

├── package.json
├── lib
│   ├── tigris.ts
├── search
│   └── models
        └── sessionv3.ts
└── pages
    ├── index.tsx
    └── api
        └── items
            └── search-meta.ts
            └── searchv2.ts

🪢 Search model definition

models/sessionv3.ts - The app has a single search index sessionv3 that stores the relicx sessions.

🌐 Connecting to Tigris

lib/tigris.ts - Centralizes the Tigris client creation. This is beneficial for serverless environments like Vercel Serverless Functions, Netlify Functions, and AWS Lambda. It allows reusing the client across requests.

Next steps