Turn any GitHub repository into an interactive diagram for visualization in seconds.
You can also replace hub with diagram in any Github URL to access its diagram.
- π Instant Visualization: Convert any GitHub repository structure into a system design / architecture diagram
- π¨ Interactivity: Click on components to navigate directly to source files and relevant directories
- β‘ Fast Generation: Powered by OpenAI o4-mini for quick and accurate diagrams
- π Customization: Modify and regenerate diagrams with custom instructions
- π API Access: Public API available for integration (WIP)
- Frontend: Next.js, TypeScript, Tailwind CSS, ShadCN
- Backend: FastAPI, Python, Server Actions
- Database: PostgreSQL (with Drizzle ORM)
- AI: OpenAI o4-mini
- Deployment: Vercel (Frontend), EC2 (Backend)
- CI/CD: GitHub Actions
- Analytics: PostHog, Api-Analytics
I created this because I wanted to contribute to open-source projects but quickly realized their codebases are too massive for me to dig through manually, so this helps me get started - but it's definitely got many more use cases!
Given any public (or private!) GitHub repository it generates diagrams in Mermaid.js with OpenAI's o4-mini! (Previously Claude 3.5 Sonnet)
I extract information from the file tree and README for details and interactivity (you can click components to be taken to relevant files and directories)
Most of what you might call the "processing" of this app is done with prompt engineering - see /backend/app/prompts.py. This basically extracts and pipelines data and analysis for a larger action workflow, ending in the diagram code.
You can simply click on "Private Repos" in the header and follow the instructions by providing a GitHub personal access token with the repo scope.
You can also self-host this app locally (backend separated as well!) with the steps below.
- Clone the repository
git clone https://github.com/ahmedkhaleel2004/gitdiagram.git
cd gitdiagram- Set up environment variables
cp .env.example .envEdit the .env file with your required API keys:
OPENAI_API_KEY- Your OpenAI API keyGITHUB_TOKEN- Optional GitHub personal access token for private reposDATABASE_URL- PostgreSQL connection stringNEXT_PUBLIC_POSTHOG_KEY- PostHog analytics key (optional)
- Start all services with Docker Compose
# Development mode (with hot-reload)
docker-compose -f docker-compose.dev.yml up
# Production mode
docker-compose up- Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Install dependencies
pnpm i- Run backend
docker-compose up --build -dLogs available at docker-compose logs -f
The FastAPI server will be available at localhost:8000
- Start local database
chmod +x start-database.sh
./start-database.shWhen prompted to generate a random password, input yes.
The Postgres database will start in a container at localhost:5432
- Initialize the database schema
pnpm db:pushYou can view and interact with the database using pnpm db:studio
- Run Frontend
pnpm devYou can now access the website at localhost:3000 and edit the rate limits defined in backend/app/routers/generate.py in the generate function decorator.
- Prepare your server
# Update system
sudo apt update && sudo apt upgrade -y
# Install Docker and Docker Compose
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose- Deploy the application
# Clone repository
git clone https://github.com/ahmedkhaleel2004/gitdiagram.git
cd gitdiagram
# Set up environment
cp .env.example .env
# Edit .env with your production values
# Start production services
docker-compose up -d
# Check service health
docker-compose ps
docker-compose logs -f- Configure reverse proxy (Nginx)
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/ {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}# Initialize swarm
docker swarm init
# Deploy stack
docker stack deploy -c docker-compose.yml gitdiagram
# Scale services
docker service scale gitdiagram_frontend=3 gitdiagram_api=2-
Frontend on Vercel
- Connect your GitHub repository
- Set environment variables in Vercel dashboard
- Deploy automatically on push
-
Backend on Railway/Render
- Connect your repository
- Set build command:
docker build -f backend/Dockerfile . - Configure environment variables
- Deploy
- Create ECS Cluster
aws ecs create-cluster --cluster-name gitdiagram- Build and push Docker images
# Build images
docker build -t gitdiagram-frontend .
docker build -t gitdiagram-api ./backend
# Tag for ECR
docker tag gitdiagram-frontend:latest your-account.dkr.ecr.region.amazonaws.com/gitdiagram-frontend:latest
docker tag gitdiagram-api:latest your-account.dkr.ecr.region.amazonaws.com/gitdiagram-api:latest
# Push to ECR
docker push your-account.dkr.ecr.region.amazonaws.com/gitdiagram-frontend:latest
docker push your-account.dkr.ecr.region.amazonaws.com/gitdiagram-api:latest- Create ECS Task Definitions and Services
Create a .env file with the following variables:
# Database
DATABASE_URL=postgresql://username:password@host:port/database
# GitHub Integration
GITHUB_TOKEN=your_github_personal_access_token
# AI Service
OPENAI_API_KEY=your_openai_api_key
# Analytics (Optional)
NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key
NEXT_PUBLIC_POSTHOG_HOST=https://app.posthog.com
# Environment
NODE_ENV=production
ENVIRONMENT=productionThe application includes health checks:
- Frontend:
GET /api/health - Backend:
GET /health
Monitor with:
# Check service health
curl http://localhost:3000/api/health
curl http://localhost:8000/health
# Docker health status
docker-compose ps# Scale frontend instances
docker-compose up --scale frontend=3
# Scale backend instances
docker-compose up --scale api=2Use Nginx or Traefik for load balancing multiple instances.
- Use connection pooling
- Configure PostgreSQL for production
- Set up database backups
-
Environment Variables
- Never commit
.envfiles - Use secrets management in production
- Rotate API keys regularly
- Never commit
-
Network Security
- Use HTTPS in production
- Configure firewall rules
- Implement rate limiting
-
Container Security
- Run containers as non-root users
- Keep base images updated
- Scan for vulnerabilities
# Create backup
docker exec gitdiagram_postgres pg_dump -U username database_name > backup.sql
# Restore backup
docker exec -i gitdiagram_postgres psql -U username database_name < backup.sql# Backup application data
docker-compose exec frontend tar -czf /backup/app-data.tar.gz /app/data- Services won't start
# Check logs
docker-compose logs -f
# Check resource usage
docker stats
# Restart services
docker-compose restart- Database connection issues
# Check database status
docker-compose exec postgres psql -U username -d database_name -c "SELECT 1;"- Memory issues
# Check memory usage
docker stats
# Adjust resource limits in docker-compose.yml# View all logs
docker-compose logs -f
# View specific service logs
docker-compose logs -f frontend
docker-compose logs -f api
# Follow logs in real-time
docker-compose logs -f --tail=100Contributions are welcome! Please feel free to submit a Pull Request.
Shoutout to Romain Courtois's Gitingest for inspiration and styling
I am currently hosting it for free with no rate limits though this is somewhat likely to change in the future.
- Implement font-awesome icons in diagram
- Implement an embedded feature like star-history.com but for diagrams. The diagram could also be updated progressively as commits are made.
