|
1 | 1 | # serverless-python-dev |
2 | 2 |
|
3 | | -Canonical source for [*Building Serverless Python Apps Using FastAPI and AWS*](https://www.amazon.com/dp/B09Z7CSDRX). Upload and maintain this repository on GitHub as **CloudBytesCollection/serverless-python-dev**. |
| 3 | +<p align="center"> |
| 4 | + <img src="./python_book.jpg" alt="Building Serverless Python Apps on AWS" width="360" /> |
| 5 | +</p> |
4 | 6 |
|
5 | | -The **Node.js** book uses a separate tree: `serverless-nodejs-dev/` with `sample-aws-starter-project` and `sample-aws-book-api`. Do not mix the two books’ folders. |
| 7 | +Companion code for **Building Serverless Python Apps on AWS** (Cloud Bytes Collection). Clone this repo and open the project that matches the chapter you are on. |
6 | 8 |
|
7 | | -## Projects in this repo |
| 9 | +## Which project should I use? |
8 | 10 |
|
9 | | -| Path | Use in the book | |
10 | | -|------|-----------------| |
11 | | -| [sample-fastapi-graphql-starter-project](./sample-fastapi-graphql-starter-project/) | Chapter 2 — FastAPI + Strawberry starter (`hello_world`, local GraphQL) | |
12 | | -| [sample-fastapi-graphql-book-api](./sample-fastapi-graphql-book-api/) | Main example — books/reviews API, MongoDB, Docker, CDK/Fargate, CI/CD | |
13 | | -| [sample-fastapi-graphql-book-api-mcp](./sample-fastapi-graphql-book-api-mcp/) | Book API + Chapter 9 MCP (`fastapi-mcp`, REST routes as tools) | |
| 11 | +| Folder | When to use it | |
| 12 | +|--------|----------------| |
| 13 | +| [sample-fastapi-graphql-starter-project](./sample-fastapi-graphql-starter-project/) | **Chapter 2** — FastAPI + Strawberry starter (`hello_world`, local GraphQL) | |
| 14 | +| [sample-fastapi-graphql-book-api](./sample-fastapi-graphql-book-api/) | **Chapters 3–8** — Books/reviews API, MongoDB, Docker, CDK/Fargate, CI/CD | |
| 15 | +| [sample-fastapi-graphql-book-api-mcp](./sample-fastapi-graphql-book-api-mcp/) | **Chapter 9** — Same API with MCP tools (`fastapi-mcp`, REST routes exposed to agents) | |
14 | 16 |
|
| 17 | +Each folder has its own `README` with environment variables, Docker notes, and deploy steps. |
15 | 18 |
|
16 | | -## Tooling |
| 19 | +## Prerequisites |
17 | 20 |
|
18 | 21 | - Python **3.12** (see each project’s `.python-version`) |
19 | | -- Dependencies via **[uv](https://docs.astral.sh/uv/)** (`uv.lock` in each project) |
20 | | -- AWS CDK CLI **>= 2.1124.1** where CDK is used |
| 22 | +- **[uv](https://docs.astral.sh/uv/)** for installs (`uv sync` in each project directory) |
| 23 | +- **Docker** (for MongoDB and container builds in the book API projects) |
| 24 | +- **AWS CDK CLI** `>= 2.1124.1` when you reach the deploy chapters |
21 | 25 |
|
22 | 26 | ## Quick start |
23 | 27 |
|
| 28 | +### Chapter 2 starter |
| 29 | + |
24 | 30 | ```bash |
25 | | -# Starter (Chapter 2) |
26 | 31 | cd sample-fastapi-graphql-starter-project |
27 | 32 | uv sync --all-groups |
28 | 33 | uv run pytest tests |
29 | 34 | uv run python main.py |
| 35 | +``` |
| 36 | + |
| 37 | +Open GraphiQL at `http://127.0.0.1:8000/graph` (see that project’s README). |
| 38 | + |
| 39 | +### Book API (main example) |
30 | 40 |
|
31 | | -# Book API |
| 41 | +```bash |
32 | 42 | cd sample-fastapi-graphql-book-api |
33 | 43 | uv sync --all-groups |
| 44 | +docker compose up mongo # in another terminal |
34 | 45 | uv run pytest tests |
| 46 | +uv run uvicorn main:app --reload |
| 47 | +``` |
| 48 | + |
| 49 | +Copy or create a `.env` file using the variables listed in [sample-fastapi-graphql-book-api/README.MD](./sample-fastapi-graphql-book-api/README.MD). |
| 50 | + |
| 51 | +### Book API + MCP (Chapter 9) |
| 52 | + |
| 53 | +```bash |
| 54 | +cd sample-fastapi-graphql-book-api-mcp |
| 55 | +uv sync --all-groups |
| 56 | +docker compose up mongo |
| 57 | +uv run uvicorn main:app --reload |
35 | 58 | ``` |
36 | 59 |
|
37 | | -## Publishing checklist |
| 60 | +See [sample-fastapi-graphql-book-api-mcp/README.MD](./sample-fastapi-graphql-book-api-mcp/README.MD) for MCP Inspector setup. |
| 61 | + |
| 62 | +## Related repos |
| 63 | + |
| 64 | +The **Node.js** book in this series uses a different repository: [serverless-nodejs-dev](https://github.com/CloudBytesCollection/serverless-nodejs-dev) (`sample-aws-starter-project`, `sample-aws-book-api`). Those projects are not part of this Python repo. |
| 65 | + |
| 66 | +## License |
38 | 67 |
|
39 | | -1. Push this directory to `github.com/CloudBytesCollection/serverless-python-dev`. |
40 | | -2. Ensure each subproject’s CI workflows pass on `main`. |
41 | | -3. Book **Resources** should link to this monorepo (not the Node `sample-aws-starter-project` repo). |
| 68 | +Each subproject includes its own license file (typically BSD 3-Clause). See the folder you are working in. |
0 commit comments