This document is the visual companion to CLAUDE.md and
REQUIREMENTS.md: four diagrams that show how a
cdk deploy in this repository turns into running (emulated) AWS
resources, how the optional floci consoles fit together, how the shared
config/tagging/naming modules wire into every modules/NN_service/stack.py,
and, concretely, how the resources of one module (modules/03_vpc, the
reference module every other module was written to match) relate to each
other.
Each diagram exists as a Mermaid source file
under docs/diagrams/ and a rendered SVG under
docs/images/ embedded below - see
section 5 for how the SVGs were produced
and validated, and how to regenerate them after editing a .mmd file.
What uv run cdk synth/deploy/destroy actually do, from editing a
stack.py to resources existing (in floci or in a real AWS account) and
back to nothing:
cdk synthonly ever reads your code and the sharedconfig/tagging/namingmodules - it needs no AWS credentials and cannot create anything, which is whyREQUIREMENTS.mdsection 0 recommends running it constantly while learning.cdk deployis the only command in this diagram that talks to an actual endpoint -http://localhost:4566(floci) whenAWS_ENDPOINT_URLis set per.env.example, or a real AWS account/region otherwise (seeshared/config.py'sget_environment()).cdk destroyreversescdk deployagainst whichever endpoint the terminal is currently pointed at - always run it before switching a module from floci to a real account, or vice versa.
docker-compose.yml runs one required service (floci) and two optional,
independent console profiles (floci-ui, floci-dash) - see
REQUIREMENTS.md section 5
for the full explanation of each:
- The AWS CDK CLI, the AWS CLI, and
boto3all talk to the same single endpoint,floci:4566, onceAWS_ENDPOINT_URL=http://localhost:4566is set - this is the only network call in the whole local setup that matters for actually creating resources. - The built-in console (
http://localhost:4566/_floci/ui) is enabled byFLOCI_SERVICES_UI_ENABLED: "true"on theflociservice itself and needs no extra profile - it is enough for every module in this learning path. floci-ui/floci-api(--profile floci-ui) andfloci-dash(--profile floci-dash) are two unrelated, optional projects that each point at this sameflocicontainer rather than running a second emulator - they can be enabled together or not at all.
How the module contract in
CLAUDE.md section 3 is actually
wired together in code - from a .env value to a tagged, named,
synthesized (and tested) resource:
app.pynever imports a module by name - it discovers everymodules/*/stack.pywithpkgutil.iter_modules()and instantiates itsSTACK_CLASSwith the one sharedAppConfigandcdk.Environment, which is what lets a new module be added without editingapp.py(seeCLAUDE.mdsection 3).shared/tagging.pyandshared/naming.pyare called from inside eachstack.py, not fromapp.py- every module applies the same 7 tags and the same naming scheme to its own resources (seeREQUIREMENTS.mdsections 7-8).- Each module's unit test (
tests/unit/test_NN_service.py) builds the stack from the sameconfigfixture and asserts against its synthesized template - not against a deployed floci/AWS resource - seedocs/TESTING.md.
modules/03_vpc is the reference module every other module was written to
match (see CLAUDE.md section 2).
This is exactly what its ec2.Vpc(..., max_azs=2, nat_gateways=0, subnet_configuration=[...])
call (modules/03_vpc/stack.py) creates and
how those resources relate to each other:
- One VPC, one Internet Gateway (created and attached automatically by the
ec2.VpcL2 construct - seemodules/03_vpc/README.md), 4 subnets (one public and one private-isolated subnet per Availability Zone,max_azs=2), and one security group scoped to the VPC. - Each subnet gets its own route table; only the two public subnets' route
tables have a route to the Internet Gateway - the private-isolated
subnets have no internet route at all, which is what
nat_gateways=0andPRIVATE_ISOLATED(instead ofPRIVATE_WITH_EGRESS) mean in practice. - The security group's only ingress rule allows TCP 443 from the VPC's own
CIDR block (
10.0.0.0/16) - nothing outside the VPC can reach it. - This same shape - one or two central resources with several dependent resources wired to them by the L2 construct - repeats throughout the other 45 modules; each module's own README documents its specific resources under "AWS services and CDK constructs used".
The .mmd files under docs/diagrams/ are the source of
truth; the .svg files under docs/images/ are generated from
them with the Mermaid CLI
(@mermaid-js/mermaid-cli), using Node.js/npm - already a prerequisite for
the AWS CDK Toolkit, see
REQUIREMENTS.md section 3 - so
no extra install is needed beyond npx:
# From the repository root, after editing any docs/diagrams/*.mmd file:
npx --yes @mermaid-js/mermaid-cli \
-i docs/diagrams/01-cdk-workflow.mmd \
-o docs/images/01-cdk-workflow.svg \
-b white -c docs/diagrams/mermaid-config.jsonRepeat for 02-floci-environment, 03-module-contract, and
04-vpc-resources, and for the diagrams embedded in other guides instead of this
file: CDK-API-REFERENCE-GUIDE.md
(05-construct-levels, 06-construct-tree,
07-import-to-reference-url),
DEPENDENCIES-LOOPS-AND-CONDITIONALS.md
(08-synth-time-vs-deploy-time, 09-resource-dependencies,
10-loop-to-resources), STACK-OUTPUTS.md
(11-attribute-to-output, 12-where-outputs-appear),
CROSS-STACK-AND-NESTED-STACKS.md
(13-cross-stack-reference, 14-nested-stack), and
CONSTRUCT-LIBRARIES-AND-SEMVER.md
(15-construct-library-release). docs/diagrams/mermaid-config.json pins Mermaid's
default theme (instead of the CLI's default hand-drawn "neo" theme,
which embeds a full variable font per file and inflates each SVG from
~20 KB to ~200 KB for no benefit in a git-tracked file). A .mmd file that
fails to render (a syntax error) makes mmdc exit non-zero and print the
parse error instead of writing an SVG - that failure is what "validating"
a diagram in this repository means; every SVG under docs/images/ was
produced by a successful run of the command above and visually reviewed
before being committed.