How tonikiri666/gitdiagram works
Project Type & Purpose
• Frontend: Next.js + TypeScript + Tailwind CSS (deployed on Vercel)
• Backend: FastAPI + Python (deployed on EC2, behind Nginx)
• Database: PostgreSQL via Drizzle ORM
• External integrations: GitHub API, PostHog analytics
File Structure
• Top-level:
– backend/ – FastAPI app, routers, services, Dockerfile, Nginx config
– src/ – Next.js app (app directory, components, hooks, providers)
– src/server/db/ – Drizzle schema & index
– Docker & compose configs (docker-compose.yml, start-database.sh)
• Patterns:
– API layer: Next.js Server Actions call the FastAPI backend.
– Micro-services style: Frontend and backend in separate containers.
– ORM: Drizzle for schema & migrations.
– Rate-limiter: backend/app/core/limiter.py.
README for Technical Stack & Architectural Insights
• CI/CD: GitHub Actions (see .github/workflows/deploy.yml)
• Caching & rate-limits: implemented at backend router level
• Prompt engineering: backend/app/prompts.py
• Self-hosting: Docker Compose spins up FastAPI + Postgres + Nginx
Main Components & Interactions
a. Client (Browser)
b. Next.js Frontend
– Pages & Server Actions (src/app/_actions)
– UI Components (src/components/)
c. API Gateway / Reverse Proxy
– Nginx container forwarding /api to FastAPI
d. FastAPI Backend
– Routers: generate, modify
– Services: calls to Anthropic/OpenAI (o4-mini), GitHub API, GitDiagram processing
– Utilities: formatting messages
e. Database
– PostgreSQL container, Drizzle ORM for schema & queries
f. External Services
– OpenAI (o4-mini) / Anthropic
– GitHub API (private & public repos)
– PostHog / Api-Analytics
Architectural Patterns & Design Principles
• Separation of concerns: UI vs business logic vs data layer
• Server Actions: leverage Next.js for SSR & API calls
• Containerization: isolates backend + database + reverse proxy
• Labels: Name each component clearly (e.g., “FastAPI: generate router”).
• Annotations: Note key frameworks or files (e.g., prompts.py, schema.ts).