Skip to content
Open
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
60 changes: 60 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# ─────────────────────────────────────────────────────────────────────────────
# TAP Voice Agent — Environment Variables Reference
# Copy this file to .env and fill in real values.
# NEVER commit your .env file — it is git-ignored.
# ─────────────────────────────────────────────────────────────────────────────

# ── App identity ──────────────────────────────────────────────────────────────
APP_NAME=tap-voice-agent
VERSION=0.1.0
ENVIRONMENT=development # development | staging | production
DEBUG=false

# ── Server ────────────────────────────────────────────────────────────────────
HOST=0.0.0.0
PORT=8000
WORKERS=1

# ── Logging ───────────────────────────────────────────────────────────────────
LOG_LEVEL=INFO # DEBUG | INFO | WARNING | ERROR
LOG_FORMAT=console # console (dev) | json (prod)

# ── CORS (comma-separated list of allowed origins) ────────────────────────────
CORS_ORIGINS=*

# ── VAPI (voice platform) — leave blank to use mock ──────────────────────────
VAPI_API_KEY=
VAPI_BASE_URL=https://api.vapi.ai
VAPI_PHONE_NUMBER_ID=

# ── Twilio (fallback calling) — leave blank to use mock ──────────────────────
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_FROM_NUMBER=

# ── WhatsApp / Meta ───────────────────────────────────────────────────────────
META_WHATSAPP_TOKEN=
META_PHONE_NUMBER_ID=
META_VERIFY_TOKEN=tap_verify_token

# ── TAP LMS (Frappe REST) ─────────────────────────────────────────────────────
TAP_LMS_BASE_URL=https://lms.theapprenticeproject.org
TAP_LMS_API_KEY=
TAP_LMS_API_SECRET=
TAP_LMS_USE_MOCK=true # Set to false when real credentials are available

# ── Language detection ────────────────────────────────────────────────────────
DEFAULT_LANGUAGE=en
SUPPORTED_LANGUAGES=hi,mr,pa,en

# ── Nudge engine ──────────────────────────────────────────────────────────────
NUDGE_INACTIVITY_DAYS=3 # Days of LMS inactivity before nudge fires
NUDGE_MAX_PER_WEEK=2 # Max calls per learner per week

# ── Metrics ───────────────────────────────────────────────────────────────────
ENABLE_METRICS=true
METRICS_EXPORT_INTERVAL=60

# ── Database (SQLite default, swap to Postgres in production) ─────────────────
DATABASE_URL=sqlite+aiosqlite:///./tap_agent.db
# DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/tap_agent
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

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

- name: Lint with ruff
run: |
ruff check .

- name: Type check with mypy
run: |
mypy app

- name: Test with pytest
run: |
pytest --cov=app --cov-report=xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
170 changes: 170 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.pyverse
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# VS Code
.vscode/

# MacOS
.DS_Store

# Application specific
tap_agent.db
*.db
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ── Stage 1: dependency builder ───────────────────────────────────────────────
FROM python:3.11-slim AS builder

WORKDIR /build

# Install pip tools
RUN pip install --upgrade pip

# Copy dependency manifests first for layer caching
COPY requirements.txt requirements-dev.txt ./

# Install production deps into /build/venv
RUN python -m venv /build/venv \
&& /build/venv/bin/pip install --no-cache-dir -r requirements.txt


# ── Stage 2: production image ──────────────────────────────────────────────────
FROM python:3.11-slim AS runtime

LABEL org.opencontainers.image.title="TAP Voice Agent" \
org.opencontainers.image.description="Multilingual Voice Agent — C4GT 2026" \
org.opencontainers.image.source="https://github.com/SuryaPratapIIIT/C4GT_2026" \
org.opencontainers.image.licenses="MIT"

ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PATH="/venv/bin:$PATH"

# Non-root user for security
RUN addgroup --system appgroup && adduser --system --ingroup appgroup appuser

WORKDIR /app

# Copy virtual environment from builder
COPY --from=builder /build/venv /venv

# Copy application source
COPY app/ ./app/

# Ownership
RUN chown -R appuser:appgroup /app

USER appuser

EXPOSE 8000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health/live')"

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