Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

AWS Agentic Architectures.

Python AWS Bedrock FastAPI Docker License

A production-ready framework implementing 17 advanced agentic patterns powered by AWS Bedrock and Claude 3.


Table of Contents


Features

17 Production-Ready Agentic Patterns

See detailed documentation in each pattern folder:

Enterprise-Grade Infrastructure

  • AWS Bedrock Integration with Claude 3 Sonnet
  • FastAPI REST API with authentication & rate limiting
  • Docker & Kubernetes deployment ready
  • Multi-database Support: PostgreSQL, Redis, ChromaDB
  • Infrastructure as Code: Terraform, CloudFormation, CDK
  • Prometheus & Grafana monitoring stack
  • Structured Logging with audit trails
  • Comprehensive Testing: Unit, Integration, E2E
  • CI/CD Ready with GitHub Actions support

Security & Compliance

  • API Key authentication
  • Role-based access control (RBAC)
  • Encryption at rest and in transit
  • Audit logging for compliance
  • AWS IAM integration
  • Secrets management

Evaluation Framework

  • Performance benchmarking
  • Accuracy testing
  • Cost analysis (per pattern)
  • Quality metrics (precision, recall, F1)
  • Reliability metrics (uptime, error rate)
  • Efficiency metrics (throughput, latency)

Patterns Overview

# Pattern Use Case Complexity
01 Reflection Self-improving essay writing Medium
02 Tool Using Web search, API calls Low
03 ReAct Complex Q&A with reasoning Medium
04 Planning Multi-step task execution Medium
05 PEV Validated task completion High
06 Tree of Thoughts Creative problem solving High
07 Multi-Agent Team collaboration High
08 Meta-Controller Dynamic agent routing Medium
09 Blackboard Shared knowledge systems High
10 Ensemble Model consensus Medium
11 Memory Long-term context Medium
12 Graph Memory Relationship tracking High
13 Self-Improvement Continuous learning High
14 Dry-Run Risk mitigation Low
15 Simulator Scenario testing High
16 Metacognitive Self-awareness High
17 Cellular Automata Emergent patterns High

Quick Start

Prerequisites

# Required
- Python 3.10+
- AWS Account with Bedrock access
- Docker & Docker Compose (optional)
- Git

# Optional
- Kubernetes cluster
- Terraform CLI

5-Minute Setup

# 1. Clone the repository
git clone https://github.com/swsarancodes/AWS-AGENTIC-ARCHITECTURES.git
cd AWS-AGENTIC-ARCHITECTURES

# 2. Set up environment
Copy-Item .env.example .env
# Edit .env with your AWS credentials

# 3. Install dependencies
pip install -r requirements.txt

# 4. Run the API
uvicorn api.main:app --reload

# 5. Open your browser
start http://localhost:8000/docs

Docker Quick Start

# Start all services
docker-compose up -d

# Access services
# API: http://localhost:8000
# Grafana: http://localhost:3000
# Prometheus: http://localhost:9090

Installation

Standard Installation

# Create virtual environment
python -m venv venv
.\venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Alternatively, use UV for faster installs
pip install uv
uv pip install -r requirements.txt

Development Installation

# Install with development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run tests
pytest tests/ -v

API Documentation

Start the API Server

uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload

Interactive Documentation

Core Endpoints

Health Check

GET /health

List All Patterns

GET /patterns

Execute Pattern

POST /patterns/{pattern_name}/run
Content-Type: application/json
X-API-Key: your-api-key-here

{
  "input": "Your task description",
  "config": {
    "max_iterations": 3,
    "temperature": 0.7
  }
}

Get Pattern Details

GET /patterns/{pattern_name}

Example cURL Request

curl -X POST "http://localhost:8000/patterns/reflection/run" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "input": "Explain quantum computing",
    "config": {"max_iterations": 2}
  }'

Docker Deployment

Using Docker Compose (Recommended)

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f api

# Stop services
docker-compose down

# Rebuild and restart
docker-compose up --build -d

Services Included

  • API: FastAPI application (port 8000)
  • PostgreSQL: Primary database (port 5432)
  • Redis: Cache layer (port 6379)
  • ChromaDB: Vector store (port 8001)
  • Prometheus: Metrics collection (port 9090)
  • Grafana: Visualization (port 3000)
  • Nginx: Reverse proxy (port 80)

Standalone Docker

# Build image
docker build -t agentic-patterns:latest .

# Run container
docker run -d \
  -p 8000:8000 \
  -e AWS_REGION=us-east-1 \
  -e BEDROCK_MODEL_ID=anthropic.claude-3-sonnet-20240229-v1:0 \
  --name agentic-api \
  agentic-patterns:latest

AWS Deployment

CloudFormation

cd infrastructure/aws/cloudformation

# Deploy Bedrock setup
aws cloudformation create-stack \
  --stack-name agentic-bedrock \
  --template-body file://bedrock-setup.yaml \
  --capabilities CAPABILITY_IAM

# Deploy Lambda functions
aws cloudformation create-stack \
  --stack-name agentic-lambda \
  --template-body file://lambda-functions.yaml \
  --capabilities CAPABILITY_IAM

Terraform

cd infrastructure/aws/terraform

# Initialize
terraform init

# Plan deployment
terraform plan -out=tfplan

# Apply
terraform apply tfplan

AWS CDK

cd infrastructure/aws/cdk

# Install dependencies
pip install -r requirements.txt

# Deploy
cdk deploy

Kubernetes

# Apply manifests
kubectl apply -f infrastructure/kubernetes/namespace.yaml
kubectl apply -f infrastructure/kubernetes/deployment.yaml
kubectl apply -f infrastructure/kubernetes/service.yaml
kubectl apply -f infrastructure/kubernetes/ingress.yaml

# Check status
kubectl get pods -n agentic-architectures

Security

Authentication

# API Key authentication (default)
headers = {
    "X-API-Key": "your-secure-api-key",
    "Content-Type": "application/json"
}

Role-Based Access Control

from security.access_control import AccessControl

ac = AccessControl()
ac.check_permission(user="analyst", resource="pattern", action="execute")

Encryption

from security.encryption import Encryption

enc = Encryption()
encrypted = enc.encrypt("sensitive data")
decrypted = enc.decrypt(encrypted)

Audit Logging

from security.audit_logger import AuditLogger

logger = AuditLogger()
logger.log_action(
    user="user@example.com",
    action="pattern_execution",
    resource="reflection_pattern",
    result="success"
)

Monitoring & Evaluation

Prometheus Metrics

Access metrics at: http://localhost:9090

from monitoring.metrics import pattern_execution_counter

# Metrics automatically tracked:
# - pattern_execution_total
# - pattern_duration_seconds
# - pattern_error_rate
# - active_requests_gauge

Grafana Dashboards

Access dashboards at: http://localhost:3000 (admin/admin)

  • Pattern execution trends
  • Performance metrics
  • Error rates and alerts
  • Cost analysis

Performance Benchmarking

# Run benchmarks
python -m evaluation.benchmarks.performance_tests

# Cost analysis
python -m evaluation.benchmarks.cost_analysis

# Accuracy testing
python -m evaluation.benchmarks.accuracy_tests

Evaluation Dashboard

from evaluation.reports.evaluation_dashboard import EvaluationDashboard

dashboard = EvaluationDashboard()
report = dashboard.generate_report({
    "reflection": {"accuracy": 0.95, "latency": 2.3},
    "react": {"accuracy": 0.92, "latency": 3.1}
})

Testing

Run All Tests

pytest tests/ -v --cov=patterns --cov=api --cov-report=html

Run Specific Test Suites

# Unit tests
pytest tests/unit/ -v

# Integration tests
pytest tests/integration/ -v

# End-to-end tests
pytest tests/e2e/ -v

# Performance tests
pytest tests/performance/ -v

Test Individual Pattern

pytest tests/unit/patterns/test_reflection.py -v

Documentation

Comprehensive Guides

Pattern Documentation

Each pattern includes:

  • Detailed README with use cases
  • Example implementations
  • Configuration options
  • Performance characteristics
  • Best practices

Example: patterns/01_reflection/README.md

Interactive Examples

  • Jupyter Notebooks: examples/notebooks/
  • Streamlit Demo: examples/demos/streamlit_app.py
  • CLI Tool: examples/demos/cli_demo.py

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Contribution Steps

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-pattern)
  3. Make your changes
  4. Add tests
  5. Run tests (pytest tests/ -v)
  6. Commit (git commit -m 'feat: add amazing pattern')
  7. Push (git push origin feature/amazing-pattern)
  8. Open a Pull Request

Development Setup

# Clone your fork
git clone https://github.com/your-username/AWS-AGENTIC-ARCHITECTURES.git

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run formatting
black patterns/ api/ utils/
flake8 patterns/ api/ utils/

Support


About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages