A FastAPI-based AI customer service system using Google's Gemini API.
- AI-powered customer service agents
- Rate limiting with tier support
- JWT-based authentication
- Structured logging and monitoring
- Environment-specific configurations
- Docker containerization
- Google Cloud Run deployment
- Clone the repository:
git clone https://github.com/yourusername/chromapages-ai.git
cd chromapages-ai
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp app/core/environments/development.env .env
# Edit .env with your settings
- Run the application:
uvicorn app.main:app --reload
Build and run locally:
docker build -t chromapages-ai .
docker run -p 8080:8080 chromapages-ai
- Google Cloud Project with billing enabled
- Google Cloud CLI installed
- Docker installed
- GitHub account
- Create a Google Cloud project:
gcloud projects create PROJECT_ID
gcloud config set project PROJECT_ID
- Enable required APIs:
gcloud services enable \
run.googleapis.com \
containerregistry.googleapis.com \
cloudbuild.googleapis.com \
secretmanager.googleapis.com
- Create service account for GitHub Actions:
gcloud iam service-accounts create github-actions \
--display-name="GitHub Actions"
- Grant necessary permissions:
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:github-actions@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/run.admin"
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:github-actions@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/storage.admin"
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:github-actions@PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
- Create and download service account key:
gcloud iam service-accounts keys create key.json \
--iam-account=github-actions@PROJECT_ID.iam.gserviceaccount.com
-
Add the following secrets to your GitHub repository:
GCP_PROJECT_ID
: Your Google Cloud project IDGCP_SA_KEY
: Content of the downloadedkey.json
file
-
Add required secrets to Google Cloud Secret Manager:
# Create secrets
echo "your-google-api-key" | gcloud secrets create GOOGLE_API_KEY --data-file=-
echo "your-jwt-secret-key" | gcloud secrets create JWT_SECRET_KEY --data-file=-
# Grant access to Cloud Run service account
gcloud secrets add-iam-policy-binding GOOGLE_API_KEY \
--member="serviceAccount:[email protected]" \
--role="roles/secretmanager.secretAccessor"
gcloud secrets add-iam-policy-binding JWT_SECRET_KEY \
--member="serviceAccount:[email protected]" \
--role="roles/secretmanager.secretAccessor"
- Push to main branch to trigger deployment:
git push origin main
-
Monitor deployment in GitHub Actions tab
-
Get the service URL:
gcloud run services describe chromapages-ai-service \
--platform managed \
--region us-central1 \
--format 'value(status.url)'
See app/core/environments/
for environment-specific configurations:
development.env
: Local developmentproduction.env.template
: Production templatecloud_run.env.template
: Cloud Run specific
Once deployed, visit:
- Swagger UI:
https://YOUR-SERVICE-URL/docs
- ReDoc:
https://YOUR-SERVICE-URL/redoc
- Logs are available in Google Cloud Console
- Metrics are collected using OpenTelemetry
- Custom metrics are stored in
/metrics
directory - Structured logging with JSON format in production
Run tests:
pytest -v
Run with coverage:
pytest --cov=app tests/
MIT License - see LICENSE file for details