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
32 changes: 32 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# API Keys
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Database
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/search_platform

# Redis
REDIS_URL=redis://localhost:6379

# Milvus
MILVUS_HOST=localhost
MILVUS_PORT=19530

# Application
ENVIRONMENT=development
DEBUG=true
API_HOST=0.0.0.0
API_PORT=8000

# Security
SECRET_KEY=your_secret_key_here_change_in_production
JWT_SECRET=your_jwt_secret_here_change_in_production
CORS_ORIGINS=http://localhost:3000,http://localhost:5173

# Rate Limiting
RATE_LIMIT_PER_MINUTE=60

# LLM Configuration
DEFAULT_LLM_PROVIDER=openai
DEFAULT_EMBEDDING_MODEL=text-embedding-ada-002
DEFAULT_CHAT_MODEL=gpt-4
189 changes: 189 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
name: CI/CD Pipeline

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

jobs:
backend-tests:
name: Backend Tests
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: search_platform_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v4

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

- name: Cache Python dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('backend/requirements.txt') }}

- name: Install dependencies
working-directory: backend
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Run linter
working-directory: backend
run: |
pip install flake8 black
flake8 app --max-line-length=120
black --check app

- name: Run tests
working-directory: backend
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/search_platform_test
REDIS_URL: redis://localhost:6379
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
pytest tests/ -v --cov=app --cov-report=xml

- name: Upload coverage
uses: codecov/codecov-action@v3
with:
file: ./backend/coverage.xml
flags: backend

widget-build:
name: Widget Build & Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Cache Node modules
uses: actions/cache@v3
with:
path: widget/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('widget/package-lock.json') }}

- name: Install dependencies
working-directory: widget
run: npm ci

- name: Lint
working-directory: widget
run: npm run lint

- name: Build
working-directory: widget
run: npm run build

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: widget-dist
path: widget/dist

dashboard-build:
name: Dashboard Build & Test
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Cache Node modules
uses: actions/cache@v3
with:
path: dashboard/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('dashboard/package-lock.json') }}

- name: Install dependencies
working-directory: dashboard
run: npm ci

- name: Lint
working-directory: dashboard
run: npm run lint

- name: Build
working-directory: dashboard
run: npm run build

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dashboard-dist
path: dashboard/dist

docker-build:
name: Docker Build
runs-on: ubuntu-latest
needs: [backend-tests, widget-build, dashboard-build]

steps:
- uses: actions/checkout@v4

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

- name: Build backend image
uses: docker/build-push-action@v5
with:
context: ./backend
push: false
tags: search-platform-backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build dashboard image
uses: docker/build-push-action@v5
with:
context: ./dashboard
push: false
tags: search-platform-dashboard:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build widget image
uses: docker/build-push-action@v5
with:
context: ./widget
push: false
tags: search-platform-widget:latest
cache-from: type=gha
cache-to: type=gha,mode=max
61 changes: 61 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
environment: production

steps:
- uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push backend image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: search-platform-backend
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./backend
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Build and push dashboard image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: search-platform-dashboard
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./dashboard
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Build and push widget
working-directory: widget
run: |
npm ci
npm run build

- name: Deploy widget to S3/CDN
run: |
aws s3 sync widget/dist s3://your-cdn-bucket/widget/ --delete
aws cloudfront create-invalidation --distribution-id YOUR_DISTRIBUTION_ID --paths "/widget/*"

- name: Deploy to ECS
run: |
# Update ECS service with new image
aws ecs update-service --cluster search-platform --service backend --force-new-deployment
aws ecs update-service --cluster search-platform --service dashboard --force-new-deployment
55 changes: 55 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Environment variables
.env
.env.local
.env.*.local

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
venv/
env/
ENV/
.venv
*.egg-info/
dist/
build/
.pytest_cache/
.coverage
htmlcov/

# Node
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
dist/
build/
.vite/
.next/
out/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store

# Docker
*.log

# Data
*.db
*.sqlite
data/
uploads/

# Misc
.cache/
tmp/
temp/
Loading
Loading