How cloudkim2025/ai-code-helper works
Project type and purpose
• This is a backend‐focused, AI-powered service (“AI 코드 헬퍼”) built with FastAPI. It exposes HTTP REST endpoints and WebSocket channels for real-time chat, and leverages Celery for background tasks (crawling, code analysis). It uses MongoDB to store sessions, crawled documents, logs, and Redis for caching. The system runs in Docker containers orchestrated by Kubernetes.
File structure
• Top level: Dockerfile, Kubernetes configs (k8s/), Celery schedules, CI workflow.
• app/ directory:
• db/ – MongoDB connection and CRUD modules
• routes/ – FastAPI routers for crawl, session, part, user_chat_sessions
• schemas/ – Pydantic models for request/response
• services/ – Business logic wrapping OpenAI GPT-4/GPT-3.5 calls
• utils/ – Crawlers, language detection, context detection, Redis caching
• websocket/ – Connection manager and WebSocket endpoint
• celery.py & tasks.py – Celery app and task definitions
• main.py – FastAPI application bootstrap
• k8s/: Deployment and Service YAMLs for API, Celery workers/beat, MongoDB, RabbitMQ, Redis, Ingress.
Extract architecture details from the README
• FastAPI handles synchronous HTTP and asynchronous WebSocket traffic.
• MongoDB for persistence, Redis for cache.
• RabbitMQ is the broker for Celery.
• Celery workers perform time-consuming tasks (crawl, analysis).
• Deployed via Docker + Kubernetes.
Main components & interactions
a. Components:
• Client (Browser/CLI)
• API Layer (FastAPI server)
• WebSocket Manager
• Celery Broker (RabbitMQ)
• Celery Workers & Beat Scheduler
• GPT Services (external OpenAI API)
• MongoDB (document store)
• Redis (cache)
• Kubernetes Cluster (pods, services, ingress)
b. Relationships & data flows:
1. Client → HTTP request → FastAPI → Routes → Business logic → MongoDB/Redis → Response
2. Client ↔ WebSocket → WebSocket endpoint → ConnectionManager → Session context → Redis/MongoDB → GPT Chat
3. FastAPI task endpoint → Celery.enqueue via RabbitMQ → Celery Worker → GPT Analysis or Crawler → write results to MongoDB → optional Redis cache
4. Celery Beat triggers scheduled crawling tasks → same task flow as above
5. FastAPI may read cached results from Redis for performance
6. All components run in Kubernetes (pods + services) behind an Ingress
c. Architectural patterns & principles:
– Asynchronous messaging (Celery + RabbitMQ) separates web layer from heavy processing
– Layered separation: API vs background workers vs data stores
– Dependency injection & Pydantic schemas for validation
– Real-time bi-directional communication via WebSocket
– Microservice-style isolation of stateful components in separate pods
d. Key technologies: FastAPI, Uvicorn, Celery, RabbitMQ, MongoDB, Redis, Pydantic, Docker, Kubernetes, OpenAI GPT APIs.