A comprehensive AI-powered GitHub repository analysis tool built with Mastra framework that provides deep insights into project complexity, resource requirements, and server capacity planning.
- Repository Analysis: Deep scan of GitHub repositories including file structure, dependencies, and codebase metrics
- Project Heaviness Assessment: Intelligent analysis of resource-intensive dependencies and complexity scoring
- Resource Estimation: Estimates RAM, CPU, and disk usage based on project characteristics
- Concurrent User Capacity Planning: Provides realistic user capacity ranges based on server specifications
- Dependency Risk Assessment: Categorizes and scores dependencies by resource impact (AI/ML, Browser Automation, etc.)
- Infrastructure Detection: Identifies Docker, Kubernetes, and other deployment configurations
- Automated README Generation: Creates comprehensive documentation for repositories
- Multi-language Support: Analyzes projects in TypeScript, JavaScript, Python, Java, Go, Rust, and C/C++
src/
βββ agents/
β βββ github-agent.ts # Main agent orchestrator
βββ tools/
β βββ analyzeDependencies.ts # Dependency analysis with weight scoring
β βββ getFileContent.ts # File content retrieval
β βββ getFilePaths.ts # Repository structure analysis
β βββ getRepoSize.ts # Repository size calculation
β βββ getRepositoryCommits.ts # Commit history analysis
β βββ generateReadmeFromRepo.ts # README generation
β βββ project-heaviness-analyzer.ts # Main analysis engine
βββ lib/
βββ utils.ts # GitHub API utilities
| Tool | Purpose | Input | Output |
|---|---|---|---|
analyzeDependencies |
Scans package.json for heavy dependencies | Package.json content | Risk level, categories, weights |
getFileContent |
Retrieves file content from GitHub | Owner, repo, file path | File content or error |
getFilePaths |
Lists all files in repository | Owner, repo, branch | Array of file paths |
getRepoSize |
Calculates repository size | Owner, repo | Size in MB |
getRepositoryCommits |
Fetches commit history | Owner, repo | Commit details array |
generateReadmeFromRepo |
Creates README from repo analysis | Owner, repo | Markdown README |
projectHeavinessAnalyzer |
Main analysis engine | Owner, repo, server specs | Comprehensive analysis report |
- Node.js 18+
- npm or yarn
- GitHub Personal Access Token
- Mastra framework
- Clone the repository
git clone https://github.com/Nika-HISK/deploy-calculator.git
cd deploy-calculator- Install dependencies
npm install
# or
yarn install- Set up environment variables
Add your credentials to
.env:
GITHUB_TOKEN=your_github_personal_access_token
ANTHROPIC_API_KEY=your_anthropic_api_key- Start the agent
npm run start- Interact with the Agent Once running, you can chat with the GitHub agent:
# Example conversation
You: "Tell me how heavy is this project {github link}"
Agent: [Analyzes repository heavyness and returns content]
You: "Tell me what kind of server specifications i need for this project {github link}"
Agent: [Generates comprehensive guide for your project]import { githubAgent } from './src/agents/github-agent';
// Analyze a repository
const analysis = await githubAgent.text({
messages: [{
role: 'user',
content: 'Analyze the project heaviness for facebook/react with 4 CPU cores and 8GB RAM'
}]
});
console.log(analysis);import { projectHeavinessAnalyzer } from './src/tools/project-heaviness-analyzer';
const result = await projectHeavinessAnalyzer.execute({
context: {
owner: 'facebook',
repo: 'react',
serverSpecs: {
cpuCores: 4,
ramGB: 8
}
},
runtimeContext: {}
});| Risk Level | Weight Range | Description | Example Packages |
|---|---|---|---|
| LOW | 0-5 | Minimal resource impact | Standard utilities |
| MEDIUM | 6-15 | Moderate resource usage | Build tools, frameworks |
| HIGH | 16-30 | Significant resource requirements | Database drivers, crypto |
| CRITICAL | 31+ | Extreme resource demands | AI/ML, browser automation |
- ** AI/ML**: TensorFlow, OpenCV, MediaPipe
- ** Browser Automation**: Puppeteer, Playwright, Selenium
- ** Image Processing**: Sharp, Canvas, JIMP
- ** Video Processing**: FFmpeg, Node-FFmpeg
- ** Database**: MySQL2, PostgreSQL, MongoDB, Redis
- ** Build Tools**: Webpack, Vite, Rollup
- ** Frameworks**: Next.js, Nuxt, Electron
- ** Crypto**: bcrypt, Argon2
- ** File Processing**: PDF-parse, XLSX, Archiver
- ** Testing**: Jest, Cypress, Storybook
- Dependency Detection: Excellent at identifying resource-intensive packages
- Relative Comparison: Very good for comparing project complexity
- Risk Assessment: Effective at flagging potential issues
- Initial Sizing: Good ballpark estimates for development planning
- Runtime Behavior: Cannot detect actual code execution patterns
- Architecture Gaps: Misses clustering, microservices, caching strategies
- Production Reality: Doesn't account for real-world traffic patterns
- Database Impact: Cannot analyze database query efficiency
- Initial project assessment
- Dependency auditing
- Development environment sizing
- Risk awareness and planning
- Relative project comparison
- Production capacity planning
- SLA commitments
- Critical system sizing
- Performance optimization decisions
| Variable | Description | Required |
|---|---|---|
ANTHROPIC_API_KEY |
Your Anthropic API key for Claude access | Yes |
GITHUB_TOKEN |
GitHub personal access token for API access | Yes |
The GitHub agent is configured with:
- Model: Claude 3.5 Sonnet (claude-3-5-sonnet-20241022)
- Memory: LibSQL-based persistent storage
- Tools: File analysis, content fetching, commit tracking, README generation
Add or modify heavy dependencies in analyzeDependencies.ts:
const heavyPackagesList = {
"your-package": { weight: 5, category: "Custom Category" },
// ... other packages
};- Visit Anthropic Console
- Create an account or sign in
- Generate an API key
- Add it to your
.envfile
- Go to GitHub Settings β Developer settings β Personal access tokens
- Generate a new token with repository access permissions
- Add it to your
.envfile
Main agent class with integrated tools and memory.
const githubAgent = new Agent({
name: "Github Agent",
instructions: "GitHub repository analysis assistant",
model: anthropic("claude-3-5-sonnet-20241022"),
memory: new Memory({
storage: new LibSQLStore({
url: "file:../mastra.db",
}),
}),
tools: {
getFilePaths,
getFileContent,
getRepositoryCommits,
generateReadmeFromRepo,
projectHeavinessAnalyzer,
getRepoSize,
analyzeDependencies
},
});Input:
{
owner: string; // Repository owner
repo: string; // Repository name
serverSpecs?: { // Optional server specifications
cpuCores: number; // Default: 2
ramGB: number; // Default: 4
};
}Output:
string // Markdown report with resource analysisInput:
{
packageJson: string; // Package.json content as string
}Output:
{
heavyPackages: string[]; // List of heavy package names
totalWeight: number; // Combined weight score
categories: Record<string, number>; // Weight by category
riskLevel: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
analysis: {
hasBrowserAutomation: boolean;
hasAI: boolean;
hasImageProcessing: boolean;
hasVideoProcessing: boolean;
hasDatabase: boolean;
totalDependencies: number;
};
}# π Project Resource Analysis
## π― Project Classification
- **Type**: Web Application
- **Complexity**: High
- **Resource Profile**: Heavy
## πΎ Resource Estimates
- **Base RAM**: ~200 MB
- **Peak RAM**: ~800 MB (with heavy operations)
- **CPU Usage**: High
- **Disk Usage**: 45.2 MB
- **Dependency Load**: HIGH
## π₯ Concurrent User Capacity
- **Server Specs**: 4 cores, 8GB RAM
- **Estimated Range**: 50-200 concurrent users
- **Limiting Factors**: Image processing, browser automation
## β οΈ Risk Factors
- Heavy browser automation (Puppeteer)
- Image processing dependencies (Sharp)
- Multiple database connections
## π Optimization Suggestions
- Implement connection pooling
- Use image processing queues
- Consider microservices architecture
- Add caching layer- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Add tests if applicable
- Commit your changes
git commit -m 'Add amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request