Skip to content

Commit bae2832

Browse files
committed
updated Readme
1 parent bbc7aa8 commit bae2832

File tree

2 files changed

+93
-21
lines changed

2 files changed

+93
-21
lines changed

samples/repo-base/README.md

Lines changed: 92 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,107 @@
1-
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
1+
# Repo Base
22

3-
## Getting Started
3+
[![1-click-deploy](https://raw.githubusercontent.com/DefangLabs/defang-assets/main/Logos/Buttons/SVG/deploy-with-defang.svg)](https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3Dsample-repo-base-template%26template_owner%3DDefangSamples)
44

5-
First, run the development server:
5+
This sample shows how to deploy an AI-powered GitHub repository chat tool using [Mastra](https://mastra.ai/), a TypeScript AI framework. Repo Base allows you to chat with and understand any GitHub repository by fetching file trees, contents, pull requests, and issues, making it easy to navigate and understand codebases of any size.
6+
7+
## Features
8+
9+
- **Repository Analysis**: Enter a GitHub repository URL and instantly start a conversation about it
10+
- **Code Exploration**: Navigate file trees, view file contents, and understand code structure
11+
- **PR & Issue Access**: Query information about pull requests and issues directly in chat
12+
- **Large Codebase Support**: Powered by Google's Gemini Flash model with its large context window
13+
- **Intuitive UI**: Built with assistant-UI for a seamless chat experience with retries, copy, and message branching
14+
15+
## Prerequisites
16+
17+
1. Download [Defang CLI](https://github.com/DefangLabs/defang)
18+
2. (Optional) If you are using [Defang BYOC](https://docs.defang.io/docs/concepts/defang-byoc) authenticate with your cloud provider account
19+
3. (Optional for local development) [Docker CLI](https://docs.docker.com/engine/install/)
20+
21+
## Development
22+
23+
To run the application locally for development, use the development compose file:
624

725
```bash
8-
npm run dev
9-
# or
10-
yarn dev
11-
# or
12-
pnpm dev
13-
# or
14-
bun dev
26+
docker compose -f compose.dev.yaml up
1527
```
1628

17-
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
29+
This will:
30+
31+
- Start PostgreSQL with volume persistence for local development
32+
- Expose PostgreSQL on port 5432 for direct access if needed
33+
- Start the Next.js application on port 3000 with hot reload
34+
35+
You can access Repo Base at `http://localhost:3000` once the containers are running.
36+
37+
## Configuration
38+
39+
For this sample, you will need to provide the following [configuration](https://docs.defang.io/docs/concepts/configuration). Note that if you are using the 1-click deploy option, you can set these values as secrets in your GitHub repository and the action will automatically deploy them for you.
40+
41+
### `GOOGLE_GENERATIVE_AI_API_KEY`
42+
43+
Your Google Generative AI API key for accessing the Gemini Flash model. You can get this from the [Google AI Studio](https://aistudio.google.com/).
44+
45+
### `DB_URL`
46+
47+
The PostgreSQL database connection string. This will be automatically configured when using Defang's managed database services.
48+
49+
### `DB_SSL`
50+
51+
Set to `true` to enable SSL. Set to `false` to disable SSL. (Can be set directly in the docker compose file)
52+
53+
### `GITHUB_TOKEN` (Optional)
54+
55+
A GitHub personal access token to increase API rate limits when fetching repository data. This is optional but recommended for better performance.
56+
57+
## Usage
58+
59+
1. Enter a GitHub repository URL in the input field (e.g., `https://github.com/facebook/react`)
60+
2. Start chatting with Repo Base about the repository
61+
3. Use commands like:
62+
- "Show me the file structure"
63+
- "What are the recent pull requests?"
64+
- "Explain the purpose of [filename]"
65+
- "How many open issues are there?"
66+
67+
## How It Works
68+
69+
Repo Base uses a tool-based approach rather than traditional RAG systems, making it more efficient for large codebases. When you provide a repository URL, Repo Base uses tools to:
70+
71+
1. Fetch the repository's file tree
72+
2. Access file contents on demand
73+
3. Retrieve information about pull requests and issues
74+
4. Store conversation history using Mastra's memory package
75+
76+
The large context window of Gemini Flash allows the agent to hold more code in memory, making the conversation more coherent and informed.
77+
78+
## Deployment
79+
80+
> [!NOTE]
81+
> Download [Defang CLI](https://github.com/DefangLabs/defang)
82+
83+
### Defang Playground
84+
85+
Deploy your application to the Defang Playground by opening up your terminal and typing:
86+
87+
```bash
88+
defang compose up
89+
```
1890

19-
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
91+
### BYOC (Deploy to your own AWS or GCP cloud account)
2092

21-
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
93+
If you want to deploy to your own cloud account, you can [use Defang BYOC](https://docs.defang.io/docs/tutorials/deploy-to-your-cloud).
2294

23-
## Learn More
95+
> [!WARNING] > **Extended deployment time:** This sample creates a managed PostgreSQL database which may take upwards of 20 minutes to provision on first deployment. Subsequent deployments are much faster (2-5 minutes).
2496
25-
To learn more about Next.js, take a look at the following resources:
97+
This sample was base off of mastra's [repo-chat sample](https://github.com/mastra-ai/repo-base).
2698

27-
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
28-
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
99+
---
29100

30-
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
101+
Title: Repo Base
31102

32-
## Deploy on Vercel
103+
Short Description: An AI-powered tool for chatting with GitHub repositories using Mastra and Google Gemini.
33104

34-
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
105+
Tags: AI, GitHub, Mastra, Next.js, PostgreSQL, TypeScript
35106

36-
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
107+
Languages: TypeScript, JavaScript, Docker

samples/repo-base/compose.dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
dockerfile: Dockerfile
66
environment:
77
DB_URL: postgres://postgres:password@database:5432/postgres
8+
DB_SSL: false
89
GOOGLE_GENERATIVE_AI_API_KEY: xxx
910
GITHUB_TOKEN: xxx
1011
volumes:

0 commit comments

Comments
 (0)