Takeaways
By the end of this section, you will be ready to start using the starter repository by:- Cloning the repository and reviewing the project structure
- Installing dependencies
- Setting up environment variables and API keys
What’s included
Pre-built Components: Chat interface, database schema, API routes, and
basic RAG functionality
Development Tools: TypeScript, ESLint, Prettier, and development utilities
Deployment Ready: Configured for Vercel deployment with environment
variables
Get started
To set up the repository on your local machine, follow these steps:1
Clone the Repository
- Open your terminal and navigate to where you want to create the project
Terminal
- Clone the repository
Terminal
- Navigate into the project directory
Terminal
2
Install dependencies
Install Node.js dependencies and check for any errors in the console:
Package Manager: The project uses npm by default, but you can use yarn or
pnpm if preferred
Key dependencies
3
Verify your setup
- Ensure you’re using Node.js 18 or higher
Terminal
- Verify dependencies
Terminal
- Test build process
Console output of successful build
Console output of successful build
Terminal
Understand the project structure
Let’s explore the key directories and files in the starter project:Key Directories
app/
Next.js App
Router:
app/page.tsx
: Main application pageapp/layout.tsx
: Root layout componentapp/globals.css
: Global styles
components/
React Components
components/ui/
: Reusable UI components
lib/
Utility functions:
lib/db/index.ts
: Database configurationactions/resources.ts
: Server action to add resources to the databaseutils.ts
: Helper functions
lib/db/
Database Schema
lib/db/schema/
: Table definitionslib/db/migrations/
: Database migrations
References
Key Files
Troubleshooting common issues
npm install fails with permission errors
npm install fails with permission errors
Use
npm install --legacy-peer-deps
or check your Node.js versionTypeScript errors during build
TypeScript errors during build
Ensure you have the correct TypeScript version and all type definitions
Environment variables not recognized
Environment variables not recognized
Restart your development server after adding environment variables
Activity: Explore the Codebase with Cursor
Now that you have the repository set up, let’s explore the codebase using Cursor’s AI-powered features to understand the project structure and purpose.1
Open the repository in Cursor
You can open the repository in Cursor in two ways:Option 1: Using the command lineOption 2: Using the file menu
Terminal
- Open Cursor
- Go to
File
→Open Folder
- Navigate to and select the
ai-sdk-rag-starter
folder - Click
Open
2
Add the repository to Cursor Chat
- In the file explorer (left sidebar), right-click on the root folder
ai-sdk-rag-starter
- Select
Add to Cursor Chat
from the context menu - This will add the entire repository to your chat context
3
Add the README to Cursor Chat
- In the file explorer, find and right-click on the
README.md
file - Select
Add to Cursor Chat
from the context menu - This will add the README documentation to your chat context
4
Ask Cursor to analyze the codebase
In the Cursor Chat panel, ask the following prompt:
What to expect: Cursor will analyze the entire codebase and provide you:
- An overview of the project’s purpose
- Explanation of the main components and their relationships
- Code structure and architecture patterns
- Key files and their roles in the application
5
Explore further (optional)
Once you have the initial analysis, you can ask follow-up questions like:
How does the RAG functionality work in this codebase?
What database schema is being used?
What are the main React components and their purposes?
6
Save the analysis
- In the Cursor Chat panel, click the
Export chat
button - Save the analysis to a file named
codebase-analysis.md
- Paste the results in a slack message to the course channel
Learning Tip: This activity helps you understand the codebase from an AI
perspective, which can reveal patterns and relationships you might miss when
reading the code manually. Use this as a foundation for the hands-on
development work in the upcoming modules.