Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .env.prod.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Production Environment Configuration
# Copy this file to .env.prod and fill in the actual values

# Application
APP_NAME=rag7-langgraph
APP_ENV=production
APP_DEBUG=false
LOG_LEVEL=INFO

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
API_WORKERS=4
API_RELOAD=false

# LangGraph Configuration
LANGGRAPH_API_URL=http://langgraph:8123
LANGGRAPH_CHECKPOINT_STORE=postgres
LANGGRAPH_STREAM_MODE=values

# Database (PostgreSQL for LangGraph checkpoints)
# TODO: Replace with actual production database credentials
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=langgraph_checkpoints
POSTGRES_USER=langgraph
POSTGRES_PASSWORD=CHANGEME_SECURE_PASSWORD

# Redis (for caching and rate limiting)
# TODO: Replace with actual production Redis credentials
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PASSWORD=CHANGEME_SECURE_PASSWORD
REDIS_DB=0

# Authentication & Security
# TODO: Generate a secure secret key (e.g., using: openssl rand -hex 32)
SECRET_KEY=CHANGEME_GENERATE_SECURE_KEY
API_KEY_SALT=CHANGEME_GENERATE_SECURE_SALT
ALLOWED_ORIGINS=https://yourdomain.com,https://www.yourdomain.com

# Observability
ENABLE_METRICS=true
METRICS_PORT=9090
JAEGER_AGENT_HOST=jaeger
JAEGER_AGENT_PORT=6831
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318

# LangChain/LangSmith (optional)
# TODO: Add your LangSmith API key if using
LANGCHAIN_TRACING_V2=false
LANGCHAIN_API_KEY=
LANGCHAIN_PROJECT=rag7-production

# OpenAI API (if using OpenAI models)
# TODO: Add your OpenAI API key
OPENAI_API_KEY=

# Other LLM Providers (as needed)
# TODO: Add your API keys for other providers
ANTHROPIC_API_KEY=
COHERE_API_KEY=
HUGGINGFACE_API_KEY=

# Vector Store Configuration
VECTOR_STORE_TYPE=postgres # or 'pinecone', 'weaviate', 'qdrant'
VECTOR_DIMENSION=1536

# n8n Integration (if using)
N8N_WEBHOOK_URL=https://n8n.yourdomain.com/webhook
N8N_API_KEY=CHANGEME_N8N_API_KEY

# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_PER_MINUTE=60
RATE_LIMIT_BURST=10

# Feature Flags
ENABLE_ASYNC_PROCESSING=true
ENABLE_CACHING=true
CACHE_TTL_SECONDS=3600
73 changes: 73 additions & 0 deletions .github/workflows/cd-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CD - Deploy to Staging

on:
push:
branches: [develop]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
DEPLOYMENT_NAME: langgraph-api
NAMESPACE: staging

jobs:
deploy:
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4

- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.28.0'

- name: Configure kubeconfig
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG_STAGING }}" | base64 -d > $HOME/.kube/config
chmod 600 $HOME/.kube/config

- name: Verify cluster connection
run: |
kubectl cluster-info
kubectl get nodes

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set image tag
id: image
run: |
IMAGE_TAG="${{ github.sha }}"
echo "tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG}" >> $GITHUB_OUTPUT

- name: Update deployment image
run: |
kubectl set image deployment/${{ env.DEPLOYMENT_NAME }} \
langgraph=${{ steps.image.outputs.image }} \
-n ${{ env.NAMESPACE }}

- name: Wait for rollout
run: |
kubectl rollout status deployment/${{ env.DEPLOYMENT_NAME }} \
-n ${{ env.NAMESPACE }} \
--timeout=5m

- name: Verify deployment
run: |
kubectl get pods -n ${{ env.NAMESPACE }} -l app=langgraph
kubectl get service -n ${{ env.NAMESPACE }} -l app=langgraph

- name: Run smoke tests
run: |
# TODO: Add smoke test endpoint checks
# kubectl run smoke-test --image=curlimages/curl --rm -it --restart=Never \
# -- curl -f http://${{ env.DEPLOYMENT_NAME }}.${{ env.NAMESPACE }}.svc.cluster.local/health
echo "Smoke tests would run here"
109 changes: 109 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI Pipeline

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort mypy
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Check formatting with black
run: black --check .
continue-on-error: true

- name: Check import ordering with isort
run: isort --check-only .
continue-on-error: true

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pytest pytest-cov pytest-asyncio

- name: Run tests
run: |
pytest --cov=. --cov-report=xml --cov-report=term
continue-on-error: true

- name: Upload coverage reports
uses: codecov/codecov-action@v3
continue-on-error: true

build:
runs-on: ubuntu-latest
needs: [lint, test]
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix={{branch}}-

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*.pyc
__pycache__/
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info/
dist/
build/
.eggs/
*.log
.env
.venv
venv/
ENV/
.DS_Store
.idea/
.vscode/
*.swp
*.swo
*~
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# rag7
# rag7

> **📦 Production Templates Available**: This repository now includes production-ready deployment templates, CI/CD workflows, Kubernetes manifests, n8n workflows, and comprehensive documentation. See the `docs/` directory and related files to get started with deployment.
Loading