MemorAI is a Spaced Repetition System (SRS) application designed to help you master new languages through its unique, audio-focused learning experience. It transforms your daily review queue into a personalized podcast, allowing you to learn on the go—during your commute, at the gym, or whenever you can listen.
This repository contains the full-stack source code for the MemorAI application, built on Next.js and a serverless AWS backend managed by AWS Amplify Gen 2.
- MemorAI Introduction (3-min overview): Watch on YouTube
- UI Tutorial & Feature Walkthrough: Watch on YouTube
AWS Lambda is the serverless compute engine at the heart of this project, acting as the "backend brain" that runs all custom logic without needing to manage any servers. Its use is split into two main areas:
- Asynchronous Audio Generation: A chain of Lambda functions orchestrates the complex, long-running task of generating audio reviews. This event-driven workflow ensures the user interface remains fast and responsive while the heavy lifting happens reliably in the background.
- Custom API Logic: Lambda also powers simple, direct API queries. For example, the
translatefunction in our GraphQL API is a Lambda that takes text, calls Amazon Bedrock to get a translation, and returns the result directly to the user.
We send all Lambda logs to CloudWatch and create one CloudWatch alarm for each Lambda function to track the number of errors in 5-minute windows. If the number of errors exceeds 1, we send a notification email to ensure rapid response to any issues.
MemorAI is built on a modern, fully serverless architecture on AWS.
- Frontend: Next.js, React, TypeScript, Amplify UI
- Backend:
- Framework: AWS Amplify Gen 2, AWS CDK
- API: AWS AppSync (GraphQL)
- Authentication: AWS Cognito
- Database: Amazon DynamoDB
- Compute: AWS Lambda
- Messaging & Orchestration: Amazon SQS, Amazon SNS
- Generative AI: Amazon Bedrock (Anthropic Claude)
- Text-to-Speech: Amazon Polly
- Storage: Amazon S3
The diagram below illustrates the event-driven architecture that powers MemorAI's core features.
- A user's request from the Next.js app to generate a review file triggers the
start-review-generationLambda via an AppSync mutation. - This function validates the request, claims the due cards in DynamoDB, and places a job message into the
GenerateReviewFilesQueue(SQS). - The SQS queue triggers the
process-card-setLambda, which is our main workhorse. - This function calls the Anthropic Claude API directly twice: first, to generate a creative story from the card content, and second, to convert that story into a structured SSML file.
- It then starts an asynchronous synthesis task with Amazon Polly, telling it to save the final MP3 and speech mark files to an S3 bucket and to publish a status update to an SNS topic upon completion.
- The SNS topic triggers the
notify-completionLambda. - This final function updates the database record with the S3 file paths and a 'ready' status, and creates a notification that is instantly delivered to the user via the AppSync GraphQL subscription.
During testing with Claude Sonnet 4 on AWS Bedrock, I encountered output token limits that appeared to be account-level restrictions requiring AWS support intervention. Due to hackathon deadline constraints, I implemented the story and SSML generation tasks using the Anthropic Claude API directly while awaiting AWS support feedback. The translation function continues to use Amazon Bedrock as originally planned.
You can find all AI prompts used in this application in the prompts directory in the root of this repository.
This application is designed to be deployed to AWS Amplify Hosting, which provides a git-based CI/CD workflow.
- Install the Amplify CLI:
npm install -g @aws-amplify/cli - Install project dependencies:
npm install
- Fork this repository to your own GitHub, GitLab, or Bitbucket account.
- Connect your app to Amplify Hosting. Follow the official Amplify Hosting Quickstart Guide. Amplify will detect the build settings for a Next.js application automatically.
- Configure Environment Variables (Secrets):
- After your application is created in the Amplify Console, navigate to App settings > Environment variables.
- Click Manage variables.
- Click Add variable. You must create a secret variable with the following name and value:
- Variable name:
ANTHROPIC_API_KEY - Variable value: [Your API key from the Anthropic platform]
- Variable name:
- Save the changes.
- Trigger a build. Go to your app in the Amplify Console and click Redeploy this version to start a new build that includes the secret environment variable.
Your application will now be live and accessible at the URL provided by Amplify Hosting.
