Git Index is a Next.js application designed to analyze Git repositories, providing detailed insights into repository structure, file contents, and estimated token counts. It supports efficient repository cloning, file exclusion, and analysis, with a modern UI and containerized deployment using Docker. The application integrates with AWS S3 for file storage and Upstash Redis for rate limiting, making it suitable for both local development and production environments.
- Repository Analysis: Clones Git repositories and generates detailed reports on file count, content, and directory structure.
- File Exclusion: Automatically removes excluded files (e.g.,
node_modules
,.git
) based on predefined patterns before analysis. - Token Estimation: Estimates token counts for repository files to assess content complexity.
- Directory Tree Visualization: Uses the
tree
command to generate a formatted directory structure. - Concurrency Management: Limits concurrent file operations with
p-limit
for optimized performance. - TypeScript Support: Built with TypeScript for type safety and maintainability.
- Modern UI: Leverages Tailwind CSS, Shadcn UI , Radix UI and Lucide React for a responsive, user-friendly interface.
- Code Quality: Enforces linting and formatting with Biome and Husky for consistent code standards.
- Dockerized Deployment: Multi-stage Docker builds for production using the
oven/bun
image. - API Integration: Uses Hono for server-side routes, with support for rate limiting via Upstash Redis.
- File Storage: Integrates with AWS S3 for storing analysis outputs.
- Framework: Next.js 15.3.2 (with Turbopack for development)
- Language: TypeScript
- Runtime: Bun
- Styling: Tailwind CSS, tw-animate-css
- UI Components: Shadcn UI , Radix UI, Lucide React
- Form Handling: React Hook Form with Zod validation
- Git Operations: simple-git
- API: Hono
- File Processing: AWS SDK for S3, minimatch for pattern matching
- Rate Limiting: Upstash Redis and Ratelimit
- Linting/Formatting: Biome, Husky
- Animation: Motion
- Containerization: Docker with Bun
- Bun: Required for running scripts and local development.
- Git: Required for repository cloning.
- Docker: Required for containerized deployment.
- Node.js: Required for local development (version >= 20.x).
- AWS Account: Required for S3 integration.
- Upstash Redis Account: Required for rate limiting.
-
Clone the Repository:
git clone https://github.com/Nayanchandrakar/git-doc.git cd git-doc
-
Install Dependencies:
bun install
-
Set Up Environment Variables: Create a
.env
file in the root directory based on.env.example
:# File Storage (AWS S3) S3_ACCESS_KEY_ID=your_aws_access_key S3_SECRET_ACCESS_KEY=your_aws_secret_key S3_REGION=your_aws_region S3_BUCKET=your_bucket_name # Rate Limiting (Upstash Redis) UPSTASH_REDIS_REST_URL=your_upstash_url UPSTASH_REDIS_REST_TOKEN=your_upstash_token # App Configuration CLIENT_URL=http://localhost:3000
The project uses a multi-stage Dockerfile with the oven/bun
image for production.
-
Build the Docker Image:
docker build -t git-doc:latest .
-
Run in Production Mode: For production with optimized build:
docker run -p 3000:3000 --env-file .env git-doc:latest
-
Start the Development Server:
bun run dev
Access the app at
http://localhost:3000
. -
Analyze a Repository:
- Navigate to the UI and input:
- Git repository URL (e.g.,
https://github.com/userName/repoName
) - Username (e.g.,
userName
) - Repository name (e.g.,
repoName
)
- Git repository URL (e.g.,
- The app will:
- Clone the repository with a shallow clone (
--depth 1
). - Remove excluded files (e.g.,
node_modules
,.git
) based onEXCLUDED_PATTERNS
. - Generate a report including:
- Number of files analyzed
- Estimated token count
- Directory tree (using the
tree
command) - File contents
- Clone the repository with a shallow clone (
- Navigate to the UI and input:
-
Build for Production:
bun run build
-
Start the Production Server:
bun run start
-
Lint and Format Code:
- Lint:
bun run lint
- Format and check:
bun run format
- Lint:
- Fork the repository.
- Create a feature branch:
git checkout -b feat/your-feature
- Commit changes using Conventional Commits:
git commit -m 'feat: add new feature'
- Push to the branch:
git push origin feat/your-feature
- Open a pull request.
Husky and Biome enforce code quality and commit message standards.
This project is licensed under the MIT License. See the LICENSE file for details.
- Next.js for the framework
- Bun for the runtime
- Tailwind CSS for styling
- Lucide React for icons
- simple-git for Git operations
- Hono for API routes
- Docker for containerization