Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
50ab489
Setup repo and added bearer token based auth. #2
rkritika1508 Dec 18, 2025
a85ed62
Added .env.example file and updated the documentation #2
rkritika1508 Dec 18, 2025
e792dfa
Resolved comments #2
rkritika1508 Dec 18, 2025
1c6e74e
updated env in config #2
rkritika1508 Dec 18, 2025
3f1d2b1
Added validators
rkritika1508 Dec 18, 2025
a55d032
Added 3 validators and input guardrail api
rkritika1508 Dec 18, 2025
464da1c
Removed validator_cls from validator config and simplified code
rkritika1508 Dec 19, 2025
7a57b94
Fixed BanList issue and refactored code
rkritika1508 Dec 19, 2025
7043a5e
feat: add GET endpoint for validatorS
dennyabrain Dec 19, 2025
518e066
Refactored API to get list of all validators
rkritika1508 Dec 19, 2025
d7828b2
Added docker setup
rkritika1508 Dec 19, 2025
a5a1bf1
Resolved comments
rkritika1508 Dec 22, 2025
e89ae6a
Fixed few comments
rkritika1508 Jan 5, 2026
f306ce9
Removed redundant files and fixed comments
rkritika1508 Jan 5, 2026
4b88f4b
Added unit tests
rkritika1508 Jan 5, 2026
56c0d32
feat: configure alembic; add db models and migration for request and …
dennyabrain Jan 7, 2026
a6ced05
Added more unit tests
rkritika1508 Jan 7, 2026
9183140
Made minor fixes
rkritika1508 Jan 7, 2026
8e0b61d
Added Guardrails AI setup steps in backend readme
rkritika1508 Jan 7, 2026
00f2f8a
Added integration tests and refactored file structure
rkritika1508 Jan 7, 2026
954d939
Added more integration tests
rkritika1508 Jan 7, 2026
8b24c43
Addressed documentation comments
rkritika1508 Jan 7, 2026
cd95c8d
Updated test scripts
rkritika1508 Jan 7, 2026
d66de4b
chore: testing session data in controller
dennyabrain Jan 7, 2026
8785bb5
feat: add crud class for request log (wip)
dennyabrain Jan 7, 2026
76a05cf
fixed env file
rkritika1508 Jan 7, 2026
9bffe5c
feat: database changes to log request and response to /input endpoint
dennyabrain Jan 8, 2026
01b10f7
feat: add db logging for /output
dennyabrain Jan 8, 2026
ea4c348
updated config
rkritika1508 Jan 8, 2026
41bb7a0
Fixed unit tests based on new schema
rkritika1508 Jan 8, 2026
0847c37
Updated gitignore
rkritika1508 Jan 8, 2026
3932717
Updated PII remover
rkritika1508 Jan 12, 2026
dc3024d
Resolved comments
rkritika1508 Jan 13, 2026
e06dc86
Resolved comment
rkritika1508 Jan 13, 2026
f6df183
Updated unit tests
rkritika1508 Jan 13, 2026
4c64be5
Updated env fetching
rkritika1508 Jan 13, 2026
f5bb4be
updated route
rkritika1508 Jan 13, 2026
42f1817
updated setup
rkritika1508 Jan 13, 2026
86834a8
Resolved comments
rkritika1508 Jan 13, 2026
415c02b
updated ut
rkritika1508 Jan 13, 2026
966c0f3
Addressed comments
rkritika1508 Jan 15, 2026
5fbaa53
Resolved comment
rkritika1508 Jan 15, 2026
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
31 changes: 31 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DOMAIN=localhost

ENVIRONMENT=development

PROJECT_NAME="Kaapi-Guardrails"
STACK_NAME=Kaapi-Guardrails

# API Base URL for cron scripts (defaults to http://localhost:8000 if not set)
API_BASE_URL=http://localhost:8000

# Postgres
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=kaapi-guardrails
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

SENTRY_DSN=

# Configure these with your own Docker registry images

DOCKER_IMAGE_BACKEND=kaapi-guardrails-backend

# Callback Timeouts (in seconds)
CALLBACK_CONNECT_TIMEOUT=3
CALLBACK_READ_TIMEOUT=10

# require as a env if you want to use doc transformation
OPENAI_API_KEY="<ADD-KEY>"
GUARDRAILS_HUB_API_KEY="<ADD-KEY>"
AUTH_TOKEN="<ADD-TOKEN>"
31 changes: 31 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DOMAIN=localhost

ENVIRONMENT=testing

PROJECT_NAME="Kaapi-Guardrails"
STACK_NAME=Kaapi-Guardrails

# API Base URL for cron scripts (defaults to http://localhost:8000 if not set)
API_BASE_URL=http://localhost:8000

# Postgres
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=kaapi-guardrails
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

SENTRY_DSN=

# Configure these with your own Docker registry images

DOCKER_IMAGE_BACKEND=kaapi-guardrails-backend

# Callback Timeouts (in seconds)
CALLBACK_CONNECT_TIMEOUT=3
CALLBACK_READ_TIMEOUT=10

# require as a env if you want to use doc transformation
OPENAI_API_KEY="<ADD-KEY>"
GUARDRAILS_HUB_API_KEY="<ADD-KEY>"
AUTH_TOKEN="<ADD-TOKEN>"
31 changes: 31 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
DOMAIN=localhost

ENVIRONMENT=testing

PROJECT_NAME="Kaapi-Guardrails"
STACK_NAME=Kaapi-Guardrails

# API Base URL for cron scripts (defaults to http://localhost:8000 if not set)
API_BASE_URL=http://localhost:8000

# Postgres
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=kaapi-guardrails
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres

SENTRY_DSN=

# Configure these with your own Docker registry images

DOCKER_IMAGE_BACKEND=kaapi-guardrails-backend

# Callback Timeouts (in seconds)
CALLBACK_CONNECT_TIMEOUT=3
CALLBACK_READ_TIMEOUT=10

# require as a env if you want to use doc transformation
OPENAI_API_KEY="<ADD-KEY>"
GUARDRAILS_HUB_API_KEY="<ADD-KEY>"
AUTH_TOKEN="<ADD-TOKEN>"
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__pycache__
app.egg-info
*.pyc
.mypy_cache
.coverage
htmlcov
.cache
.venv
.DS_Store
.env
.env.test
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,84 @@
# kaapi-guardrails
A repo for our experiments with Guardrails so can be integrated with Kaapi

# Kaapi Guardrails

[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
![](https://github.com/ProjectTech4DevAI/ai-platform/workflows/Continuous%20Integration/badge.svg)
![GitHub issues](https://img.shields.io/github/issues-raw/ProjectTech4DevAI/kaapi-guardrails)
[![Commits](https://img.shields.io/github/commit-activity/m/ProjectTech4DevAI/kaapi-guardrails)](https://img.shields.io/github/commit-activity/m/ProjectTech4DevAI/kaapi-guardrails)

## Pre-requisites

- [docker](https://docs.docker.com/get-started/get-docker/) Docker
- [uv](https://docs.astral.sh/uv/) for Python package and environment management.

## Project Setup

You can **just fork or clone** this repository and use it as is.

✨ It just works. ✨

### Configure

Create env file using example file

```bash
cp .env.example .env
```

You can then update configs in the `.env` files to customize your configurations.

⚠️ Some services depend on these environment variables being set correctly. Missing or invalid values may cause startup issues.

## Bootstrap & development mode

You have two options to start this dockerized setup, depending on whether you want to reset the database:
### Option A: Run migrations & seed data (will reset DB)

Use the prestart profile to automatically run database migrations and seed data.
This profile also resets the database, so use it only when you want a fresh start.
```bash
docker compose --profile prestart up
```

### Option B: Start normally without resetting DB

If you don't want to reset the database, start the project directly:
```bash
docker compose watch
```
This will start all services in watch mode for development — ideal for local iterations.

### Rebuilding Images

```bash
docker compose up --build -d
```

This is also necessary when:
- Dependencies change in `pyproject.toml` or `uv.lock`
- You modify Dockerfile configurations
- Changes aren't being reflected in the running containers

## Backend Development

Backend docs: [backend/README.md](./backend/README.md).

## Deployment

Deployment docs: [deployment.md](./deployment.md).

## Development

General development docs: [development.md](./development.md).

This includes using Docker Compose, custom local domains, `.env` configurations, etc.

## Release Notes

Check the file [release-notes.md](./release-notes.md).

## Credits

This project was created using [full-stack-fastapi-template](https://github.com/fastapi/full-stack-fastapi-template). A big thank you to the team for creating and maintaining the template!!!
49 changes: 49 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM python:3.10

ENV PYTHONUNBUFFERED=1

WORKDIR /app/

# Install uv
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
COPY --from=ghcr.io/astral-sh/uv:0.5.11 /uv /uvx /bin/

# Place executables in the environment at the front of the path
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#using-the-environment
ENV PATH="/app/.venv/bin:$PATH"

# Compile bytecode
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
ENV UV_COMPILE_BYTECODE=1

# uv Cache
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
ENV UV_LINK_MODE=copy

# Install dependencies
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project

ENV PYTHONPATH=/app
RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/*

COPY ./scripts /app/scripts
RUN chmod +x /app/scripts/*.sh

COPY ./pyproject.toml ./uv.lock ./alembic.ini /app/

COPY ./app /app/app
COPY ./tests /app/tests

# Sync the project
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync

# -------------------------------
# Entrypoint (runtime setup)
# -------------------------------
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
Loading