The Personal AI Diary is a coding project I implemented incorporating journal-type user input and AI. The system facilitates users to log their thoughts, which then generates a related AI response powered by OpenAI's GPT-3 model. Currently, the application doesn't store any user data, ensuring absolute privacy.
In essence, it's a programming sandbox for introspection, where users input their thoughts and receive insightful machine-generated responses that can provide new perspectives. A key point to note is that on refresh, entries are not retained.
For the future iterations of this project, I aim to include a feature to store user sessions and diary entries in a database, giving users a seamless and more interactive experience. As it already uses Stytch's login and authentication process, hopefully this won't be too much trouble beyond setting up a db (or at the very least storing in a user's local browser storage).
This project was initialized using the Stytch + Next.js demo project, derived from create-next-app
.
Check out a live version of this site here.
For user authentication, I've used the SDK with React component from Stytch integrating the OAuth logins auth flow.
You'll need your Project's project_id
, secret
, and public_token
. You can find these in the API keys tab.
You will also need an OpenAI API key to make calls to OpenAI. Make sure you add that in as well.
Once you've gathered these values, add them to a new .env.local
file.
cp .env.template .env.local
Next we'll configure the appropriate redirect URLs for your project, you'll set these magic link URLs for your project in the Redirect URLs section of your Dashboard. Add http://localhost:3000/authenticate
as both a login and sign-up redirect URL.
Install dependencies by running
npm install
You can then run a development server using:
npm run dev
Open http://localhost:3000 with your browser to see the result.
Note: By default this example app enables Google for OAuth. If you haven't set up Google OAuth in your Dashboard, you'll receive a redirect error when you attempt to login via those providers.
Learn more about some of Stytch's products used in this example app: