Sample Serverless AI chat gateway built on AWS AppSync Events API and Amazon Bedrock. Features real-time streaming chat with multiple AI models, user authentication, token usage tracking, response caching, and content safety guardrails. Includes React frontend, Python Lambda backend, and CDK infrastructure. Designed for secure, scalable AI interactions with built-in rate limiting and comprehensive monitoring.
- Install pyenv to manage python versions: https://github.com/pyenv/pyenv
- Install nvm to manage nodejs versions: https://github.com/nvm-sh/nvm
- Run
pyenv install(reads the python version from .python-version). Note that if you already have the version of python installed, you must runpyenv localto update your shell to use that python. - Run
nvm install(reads the nodejs version from .nvmrc) - Install pnpm:
npm install -g pnpm - Run
pip install poetry setuptools - Run
pnpm installto install dependencies (this will install npm dependencies and python dependencies via poetry install from the submodules) - To update the region
- Open
.projenrc.tswith your text editor - Update the region constant near the top of the file,
const region = "us-east-1"; - Run
pnpm projento update the configuration across the repository
- Open
- Define the
ARCHvariable in your shell:export ARCH=$(arch). The value should be eitheraarch64orx86_64and should match your system architecture so that the lambda functions are deployed to an architecture matching your build environment. - To build the packages:
npx nx run deploy:build- this must precede the next step - To deploy to your own account, run
ARCH=$(arch) npx nx run deploy:deploy --require-approval never --all
% npx nx show projects
This build all the projects according to their dependency structure
npx nx run deploy:build
To deploy, first deploy the base env stack. This includes all the resources that are slow to deploy and not likely to change in development iterations: application load balancer, relational database, cognito.
npx nx run deploy:deploy --require-approval=never --all
npx nx graph
Modify .projenrc.ts with the dependencies you wish to use and then run npx pdk to update project files.
To run an audit and remediate CVEs, first...
- Run
pnpm audit. - Select one package to update
- Update the
pnpmOverridesin.projenrc.ts - Run
pnpm projento update dependencies and install the change. - Then repeat these steps.
Note, when updating aws-cdk-lib, update the cdkVersion variable also.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.