Why
An orientation map rather than a study: which layer each piece of this project actually lives at, and where the gaps are. Useful mostly for noticing that several cards which sound like different problems turn out to sit at the same layer — and that one or two layers have nothing on them at all.
How it works
A static five-layer diagram with the project's routes and demos placed on it. No code.
Related code
"""Web stack layers PoC -- a request flowing through a chain of middleware layers.
Illustrates the core mechanism: each layer wraps the next, adding something on the way
in and/or the way out, and the order in which layers run is visible in the output.
"""
from typing import Callable
Handler = Callable[[dict], dict]
def logging_layer(next_layer: Handler) -> Handler:
def handle(request: dict) -> dict:
print(f" [logging] in: {request['path']}")
response = next_layer(request)
print(f" [logging] out: status={response['status']}")
return response
return handle
def auth_layer(next_layer: Handler) -> Handler:
def handle(request: dict) -> dict:
print(f" [auth] checking token for {request['path']}")
request["user"] = "jay"
return next_layer(request)
return handle
def cache_layer(cache: dict) -> Callable[[Handler], Handler]:
def wrap(next_layer: Handler) -> Handler:
def handle(request: dict) -> dict:
if request["path"] in cache:
print(f" [cache] hit for {request['path']}")
return cache[request["path"]]
print(f" [cache] miss for {request['path']}")
response = next_layer(request)
cache[request["path"]] = response
return response
return handle
return wrap
def app_layer(request: dict) -> dict:
print(f" [app] handling {request['path']} for user={request.get('user')}")
return {"status": 200, "body": f"hello, {request.get('user')}"}
if __name__ == "__main__":
cache: dict = {}
# Layers compose from the outside in: logging -> auth -> cache -> app.
stack = logging_layer(auth_layer(cache_layer(cache)(app_layer)))
print("request 1 (/profile):")
stack({"path": "/profile"})
print("\nrequest 2 (/profile again -- cache should hit):")
stack({"path": "/profile"})
docs/code/pocs/web-stack-layers.py
Where it lands in Jayverse
- gitboard: build the same five-layer map for Jayverse's own services. Placing Rabbit, Verex, Wallet, Bridge, Number, and Devnet on one stack diagram the way this page does for its own project would surface which layers have nothing built on them yet.
- Devnet: use the map to spot the layer with the fewest services depending on it. An orientation diagram is cheap to build, and it would show whether Devnet is actually load-bearing for every service or just some of them.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| overlaid on | ~ 위에 겹쳐 놓인 · 프로젝트 구성요소를 기존 지도 위에 포개어 표시할 때. "with this project overlaid on it" |
| orientation map | 방향을 잡아주는 지도, 개요도 · 깊이 있는 학습 자료가 아니라 전체 구조를 훑어보는 자료임을 밝힐 때. "An orientation map rather than a study" |
| sit at the same layer | 같은 계층에 위치하다 · 겉으로 다른 문제처럼 보이는 것들이 실은 같은 층에 속할 때. "turn out to sit at the same layer" |
| have nothing on | ~에 아무것도 없다, 해당 항목이 비어 있다 · 지도의 특정 칸이 채워지지 않은 것을 가리킬 때. "one or two layers have nothing on them at all" |