How murtuzaalisurti/better works
Project type and purpose
• This is an open-source GitHub Action (a reusable automation component) written in Node.js.
• Its purpose is to run on pull_request events, call an external AI service to review code, and post feedback back to the PR.
File structure
• Top level:
• action.yml – Action metadata (inputs, outputs, runs-on, main entrypoint)
• index.js – Entrypoint in source (used in dev), which is bundled into dist/
• dist/ – Transpiled, production-ready JS that the Action actually runs
• utils/ – Shared code (constants, types) used by index.js
• assets/ – Images for documentation
• .github/ – Contains any workflow templates (not this repo’s workflows)
• Packaging: package.json defines dependencies; build step compiles source into dist/.
Extract architectural insights from README
• Trigger: on pull_request events (opened, synchronized, etc.)
• Inputs: repo-token, ai-model-api-key, platform, rules, filesToIgnore, etc.
• Flow: GitHub CI → Action code (Node) → AI platform API → GitHub REST API to post a review
Main components
a. Developer Repository
• .github/workflows/your-workflow.yml (defines “uses: murtuzaalisurti/better@v3”)
• Secrets: GITHUB_TOKEN, MODEL_API_KEY
b. GitHub Actions Service
• Receives the pull_request event and spins up a runner
c. GitHub Actions Runner (VM/Container)
• Checks out code
• Installs action code (dist/ + node_modules)
• Executes Action (dist/index.js)
d. Action Code (Node.js)
• utils/constants.js, utils/types.js
• business logic: read changed files, filter by glob, assemble prompt, call AI
e. External AI Platform(s)
• OpenAI, Anthropic, Google Gemini, Mistral, OpenRouter
• Receives prompt, returns suggestions
f. GitHub REST API
• Used by Action to delete old reviews and post new comments
Architectural patterns & design principles
• Event-driven architecture: reacts to GitHub events
• Modular code: utils folder for constants/types, single entrypoint in index.js
• External service integration: pluggable AI platform via the platform input
• Idempotency: deletes previous bot review before posting new comments
Essential elements to capture
• Inputs (repo-token, secrets) flowing into Runner
• Decision logic for ignoring files (glob filter)
• Retry logic on AI failures (max-retries)
• Deletion of previous bot reviews (delete-existing-review-by-bot)
Final advice
• Be detailed but keep it high-level: group related modules under “Action Code”
• Event flows and data flows
• Component with key technologies: Node.js, micromatch, GitHub Actions, OpenAI API