Skip to content

Latest commit

 

History

History
137 lines (82 loc) · 5.74 KB

File metadata and controls

137 lines (82 loc) · 5.74 KB

Photography Site

This sample app demonstrates a photography site by using Astra Vector DB, JSON API, stargate-mongoose, express.

App blog is in medium, dzone.

📋 How to

1 - Create your DataStax Astra account

ℹ️ Account creation tutorial is available in awesome astra

click the image below or go to https://astra.datastax./com

2 - Create an Astra Token

ℹ️ Token creation tutorial is available in awesome astra

  • Locate Settings (#1) in the menu on the left, thenToken Management` (#2)

  • Select the role Organization Administrator before clicking [Generate Token]

The Token is in fact three separate strings: a Client ID, a Client Secret and the token proper. You will need some of these strings to access the database, depending on the type of access you plan. Although the Client ID, strictly speaking, is not a secret, you should regard this whole object as a secret and make sure not to share it inadvertently (e.g. committing it to a Git repository) as it grants access to your databases.

{
  "ClientId": "ROkiiDZdvPOvHRSgoZtyAapp",
  "ClientSecret": "fakedfaked",
  "Token":"AstraCS:fake"
}

3 - Create a Database

If you are creating a new account, you will be brought to the DB-creation form directly.

Otherwise, get to the databases dashboard (by clicking on Databases in the left-hand navigation bar, expanding it if necessary), and click the [Create Database] button on the right.

Take a moment to fill the form:

  • ℹ️ Fields Description
Field Description
Vector Database vs Serverless Database PICK VECTOR In june 2023, Cassandra introduced the support of vector search to enable Generative AI use cases. You might consume your credit faster with a vector database.
database name It does not need to be unique, is not used to initialize a connection, and is only a label (keep it between 2 and 50 characters). It is recommended to have a database for each of your applications. The free tier is limited to 5 databases.
keyspace photography
Cloud Provider Choose whatever you like. Click a cloud provider logo, pick an Area in the list and finally pick a region. We recommend choosing a region that is closest to you to reduce latency. In free tier, there is very little difference.

4 - Register to OpenAI

  • In your profile, go to View API KEYS, create a new key and copy the value in your clipboard. You have a free trial for a month of so.

5 - Setup project

detailed instructions in Photography App README

  • Setting up .env file to run against AstraDB
  1. Copy the .env.example file to .env and fill in the values for the environment variables.
  2. Set IS_ASTRA to true
  3. Set OPENAI_API_KEY to your openAI api key
  4. Set ASTRA_DBID to your AstraDB vector database ID
  5. Set ASTRA_REGION to your AstraDB vector database region
  6. Set ASTRA_KEYSPACE to your AstraDB vector database keyspace (should be 'photography')
  7. Set ASTRA_APPLICATION_TOKEN to your AstraDB application token

6 - Run the project

detailed instructions in Photography App README

  • Install Python and google-mediapipe

Make sure you have a local python (3.8 - 3.11) environment and install google-mediapipe

pip install mediapipe
  • Make sure you have Node.js 17 or higher
node --version
  • Build the application
npm install
  • Populate the database
npm run seed
  • Start the application
npm start
  • Visit http://127.0.0.1:3000 to see the UI