Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
99c094e
initial upload
Igboke Oct 31, 2025
02cb756
feat: create app function
Igboke Oct 31, 2025
da23d36
feat: Context manager for fast api
Igboke Oct 31, 2025
8a0c124
fix: database
Igboke Oct 31, 2025
02193d6
feat: added config files
Igboke Oct 31, 2025
ad9ace3
feat: configuration fixes
Igboke Nov 1, 2025
902ff1a
feat: created the models, set up alembic and made first migration
Igboke Nov 1, 2025
19177a9
feat: set up upload document endpoint
Igboke Nov 1, 2025
e7682e1
feat: added logging in json for easy filter, search, and analyze logs…
Igboke Nov 1, 2025
51fd52c
feat: added aiofiles dependency and type hint to a field in settings
Igboke Nov 1, 2025
b7a32e6
feat: tested the upload mechanism
Igboke Nov 1, 2025
567ee7b
feat: set up celery
Igboke Nov 8, 2025
c52825d
feat: tested the configuration
Igboke Nov 8, 2025
118a43a
feat: implemented the unpack_zip_task with tests
Igboke Nov 8, 2025
5de05b6
feat: ingestion and embedding using fastembed
Igboke Nov 8, 2025
8bfa72f
feat: query endpoint with services
Igboke Nov 8, 2025
49d06f8
feat: query implementation
Igboke Nov 9, 2025
d85b3f9
fix: model usage is faster now due to lazy loading, moved the initial…
Igboke Nov 9, 2025
b3d9010
feat: request limitter
Igboke Nov 9, 2025
cf96479
feat: added error handling
Igboke Nov 9, 2025
9e9d95f
feat: added monitoring
Igboke Nov 10, 2025
6163f3d
feat: added caching, fixed database type issues
Igboke Nov 10, 2025
d0fb890
feat: dockerfile
Igboke Nov 10, 2025
32ecb48
fix: db connection for docker
Igboke Nov 10, 2025
39c7b86
feat: Add GitHub Actions CI pipeline
Igboke Nov 11, 2025
5bb775f
feat: test
Igboke Nov 11, 2025
828593e
fix: Update GitHub Actions branch pattern to match all branches
Igboke Nov 11, 2025
5cf2c3e
fix: Update GitHub Actions to use v4 of upload-artifact and cache act…
Igboke Nov 11, 2025
046ff35
fix: Run pytest as module to match local development workflow
Igboke Nov 11, 2025
5bdec82
fix: changed test database url to database url
Igboke Nov 11, 2025
9624cc5
fix: Add API key authentication to test clients
Igboke Nov 11, 2025
44ff01f
fix: removed redundant tests
Igboke Nov 11, 2025
4ce0286
feat: Readme
Igboke Nov 11, 2025
e4d3c4a
feat: improve large file handling by increasing the chunk size and us…
Igboke Nov 28, 2025
ec3080e
chore: testing large file uploads
Igboke Nov 28, 2025
8f987bd
fix: hotfix for CI pipeline
Igboke Nov 28, 2025
4c6ddf2
fix:
Igboke Nov 30, 2025
3db1ffc
refactor: simplify database session management by removing Unit of Wo…
Igboke Nov 30, 2025
ed9ce8a
fix: celery function
Igboke Nov 30, 2025
2453635
fix: use pytest and removed print statements
Igboke Nov 30, 2025
3874165
refactor: implement proper dependency injection for API endpoints
Igboke Dec 1, 2025
8f117fc
refactor: centralize dependencies and make health check into a service
Igboke Dec 4, 2025
3238da1
refactor: use pgvector ORM methods instead of raw SQL
Igboke Dec 4, 2025
7a8c544
refactor: replace create_test_zip.py with pytest fixture
Igboke Dec 4, 2025
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
21 changes: 21 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
GOOGLE_API_KEY="your-google-api-key-here"

# API Security
# Generate a secure API key for your application
API_KEY="your-secure-api-key-here"

# Database Configuration
DB_USER="marketting"
DB_PASSWORD="password" # Add password for production
DB_HOST="localhost" # Use "db" for Docker Compose
DB_PORT=5432
DB_NAME="docuquery_db"

# Redis Configuration (for Celery)
REDIS_HOST="localhost" # Use "redis" for Docker Compose
REDIS_PORT=6379

# Note: When using Docker Compose, the following environment variables
# are automatically overridden in docker-compose.yml:
# - DB_HOST=db (for containers to connect to PostgreSQL service)
# - REDIS_HOST=redis (for containers to connect to Redis service)
162 changes: 162 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
name: CI Pipeline

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: docuquery_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

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

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install uv
run: |
pip install --upgrade pip
pip install uv

- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-

- name: Cache model files
uses: actions/cache@v4
with:
path: |
~/.cache/huggingface
./model_cache
key: ${{ runner.os }}-models-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-models-

- name: Install dependencies
run: |
uv pip install --system ".[test]"

- name: Set up environment variables
run: |
cat > .env <<EOF
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
DB_NAME=docuquery_db
REDIS_HOST=localhost
REDIS_PORT=6379
API_KEY=test-api-key-for-ci
GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY || 'test-google-api-key' }}
EOF

- name: Wait for PostgreSQL
run: |
for i in {1..30}; do
if pg_isready -h localhost -p 5432 -U postgres; then
echo "PostgreSQL is ready"
break
fi
echo "Waiting for PostgreSQL..."
sleep 1
done

- name: Enable pgvector extension
env:
PGPASSWORD: postgres
run: |
psql -h localhost -p 5432 -U postgres -d docuquery_db -c "CREATE EXTENSION IF NOT EXISTS vector;"

- name: Run database migrations
run: |
alembic upgrade head

- name: Start API server in background
run: |
nohup uvicorn app.main:app --host 0.0.0.0 --port 8000 > api.log 2>&1 &
echo $! > api.pid
sleep 5 # Wait for server to start

- name: Start Celery worker in background
run: |
nohup celery -A app.worker.celery worker --loglevel=info > worker.log 2>&1 &
echo $! > worker.pid
sleep 5 # Wait for worker to start

- name: Check API health
run: |
for i in {1..30}; do
if curl -f http://localhost:8000/docs > /dev/null 2>&1; then
echo "API is ready"
break
fi
echo "Waiting for API..."
sleep 1
done
curl -f http://localhost:8000/docs || (echo "API failed to start" && cat api.log && exit 1)

- name: Run tests
run: |
python -m pytest -v --tb=short

- name: Upload API logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: api-logs
path: api.log

- name: Upload worker logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: worker-logs
path: worker.log

- name: Stop services
if: always()
run: |
if [ -f api.pid ]; then
kill $(cat api.pid) || true
fi
if [ -f worker.pid ]; then
kill $(cat worker.pid) || true
fi
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,12 @@ cython_debug/
marimo/_static/
marimo/_lsp/
__marimo__/

design_docs/

# Model cache directory
model_cache/

models/

*.lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12-slim

WORKDIR /app

ENV PYTHONUNBUFFERED=1

RUN pip install --no-cache-dir uv

COPY . .

RUN uv pip install --system ".[test]"

EXPOSE 8000

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
Loading