A-Cobble / Next13_Text_Similarity

Home Page:https://text-similarity-api-weld.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Text-Similarity API

Text-Similarity API is a Next.js 13 project bootstrapped with create-next-app@latest. The goal of this project was to create an API that can compare two pieces of text. Features include a light and dark mode, rate limitation for the created api. A functional table to display past requests that can hide, filter and sort. This application also includes Google authentication with sensitive routes protected.

Technologies:


Getting Started

First, install the dependencies:

npm install
# or
yarn add

Then run the development server:

npm run dev
# or
yarn dev

Environmental Variables

Some inormation will be uniqe to the environemnt in which this project is deployed or should not be shared publicly such as port numbers, api keys, etc.


Next.js uses a file named .env

Create the .env file in root directory of your project.

I have included a template (.env.template) to help you get started.


Create a project in the Google Cloud Console then navigate to APIs & Services -> Credentials. Once here configure your OAuth consent screen and then create a OAuth client ID (under create credentials) Copy the Google ClientID and Google Client Secret into the appropriate fields in the .env file
Following the Google console setup create a project on [PlanetScale](https://planetscale.com/). Once created click on the connect button, select Prisma in the Connect with field, and copy the DATABASE_URL value into the .env file. Once the environment variables have been input run:
npx prisma db push

npx prisma generate

#or

yarn prisma db push

yarn prisma generate

Next, generate your OpenAI key by proceeding to [OpenAI's](https://platform.openai.com/account/api-keys) website, loging in and creating a new secret key. Copy the newly generated key into the .env file.
Once, you have your OpenAI key create a randomly generated NEXTAUTH_SECRET and then enter http://localhost:3000 into NEXTAUTH_URL.
Finally, navigate to [upstash.com](https://upstash.com), log in and create a new database. Locate UPSTASH_REDIS_REST_TOKEN under the rest api section. Copy that value and add it to the .env file for REDIS_SECRET. Do the same for UPSTASH_REDIS_REST_URL but add it to the .env file for REDIS_URL. This completes all environment variables. (You may need to restart your server)

Acknowledgments

This project was inspired by Josh's Similarity-API project. If you have any questions check out his YouTube video here: https://www.youtube.com/watch?v=4lUkSgvmTYM&t=1238s

About

https://text-similarity-api-weld.vercel.app


Languages

Language:TypeScript 97.5%Language:JavaScript 2.1%Language:CSS 0.4%