How cpiprint/gitdiagram-cpi works
Project type and purpose
• The README confirms it uses Next.js/TypeScript/Tailwind on the frontend, FastAPI/Python on the backend, PostgreSQL via Drizzle ORM for persistence, and Claude 3.5 Sonnet as the AI engine.
File structure
• Frontend: /src/app, /src/components, /src/hooks, /src/lib, /public, Tailwind/Next config files. Uses the Next.js App Router (app directory) with server actions (_actions).
• Backend: /backend contains a Dockerfile + entrypoint, FastAPI app under backend/app (with routers, services, core logic), an Nginx config, and deploy scripts.
• Database: Drizzle config and schema in /src/server/db (Next.js server-side), plus Docker Compose and start-database.sh to spin up Postgres.
• CI/CD: .github/workflows/deploy.yml.
• Misc: components.json, analytics integrations (PostHog), env templates.
Key insights from README
• Frontend is deployed on Vercel, backend on EC2 behind Nginx.
• CI/CD via GitHub Actions.
• External services: Anthropic (Claude), GitHub API, PostHog analytics.
• Database: Postgres (Docker) with Drizzle ORM.
a. Main components:
• Browser (User)
• Frontend (Next.js + ShadCN UI)
• CDN / Vercel layer
• Backend API (FastAPI + Nginx) on EC2
• PostgreSQL database (Docker container)
• AI Service (Anthropic Claude 3.5)
• External GitHub API
• Analytics (PostHog, Api-Analytics)
• CI/CD (GitHub Actions)
b. Relationships & data flow:
1. User’s browser → Vercel CDN → Next.js frontend
2. Frontend calls server actions or direct REST calls to FastAPI over HTTPS
4. FastAPI → GitHub service (via github_service.py) to fetch repo metadata/files
6. Analytics events from frontend/backend → PostHog
7. CI/CD pipeline (GitHub Actions) builds & deploys frontend to Vercel and backend to EC2
c. Architectural patterns & principles:
• Separation of concerns: Delta between Static/SSR/UI logic and API/microservice logic
• Dockerized backend + Nginx reverse proxy
• Next.js server actions for edge/serverless calls
• Schema-driven ORM (Drizzle)
• Rate limiter in FastAPI (limiter.py) to throttle requests
• Event-driven analytics hooks
d. Key technologies & libraries:
• Next.js (App Router), React + TypeScript + Tailwind + ShadCN UI
• FastAPI, Python 3, Uvicorn, Nginx
• Docker, docker-compose, EC2
• PostgreSQL, Drizzle ORM
• Anthropic Claude 3.5 Sonnet
• GitHub API (REST)
• GitHub Actions, Vercel
• PostHog analytics
Don’t overthink—capture every logical component
• Break apart the backend into Nginx, FastAPI app, services layer, and rate limiter.
• Next.js folder structure collapsed into “UI Components & Server Actions”.
• Entrypoints (Vercel → Next.js serverless functions or static pages).