How u22-2025/wip works
Project Type and Purpose
• This is a distributed, protocol‐based networking project implementing the Weather Information Protocol (WIP).
• It provides:
• Client libraries/CLIs (C++, Python, Rust)
• Four UDP-based microservices (Weather/Proxy, Location, Query, Report)
• Data ingestion from external JMA (Japan Meteorological Agency) sources
• Caching layers (Redis), databases (PostgreSQL + PostGIS)
File Structure Analysis
• Top-level language folders:
• cpp/ → C++20 client library, tools, CLIs
• python/ → Python server implementations (map, weather_api, tools, mock server)
• Rust/ → Rust client and binary CLIs (deprecated and current)
• src/ → Pure Python packages: WIPClientPy, WIPCommonPy, WIPServerPy
• Config and build:
• CMakeLists.txt, build‐win/, build‐wsl/ (C++ builds)
• pyproject.toml, requirements.txt, yml/env311.yml (Python packaging)
• .env, dotenv for environment variables
• Documentation:
• Lua dissector (Wireshark plugin)
• Cache & memories: internal AI/system caches (.serena, .claude) – not part of runtime
README Insights
• Clearly defines 4 server roles (Weather, Location, Query, Report) each listening on different UDP ports.
• Describes protocol stack (Application → UDP → IP → Ethernet).
• Describes external dependencies: PostgreSQL + PostGIS, Redis, external JMA XML/JSON data.
• Illustrates high-level flow: Client ↔ Weather Proxy ↔ Location & Query servers ↔ JMA data source.
a. Main Components
1) Clients:
• C++ CLI (cpp/build/.../wip_client_cli)
• Python client library (src/WIPClientPy)
• Rust client binaries (Rust/src/bin/*)
2) Weather Server (UDP/4110) – Proxy service
3) Location Server (UDP/4109)
4) Query Server (UDP/4111)
5) Report Server (UDP/4112)
6) Data Stores:
• PostgreSQL + PostGIS (for geocoding)
• Redis instances (request cache, log cache)
7) External Data Source:
• 気象庁 (JMA) XML/JSON endpoints
8) Supporting Tools:
• Mock servers, scripts (python/tools/*, cpp/tools/*)
• Wireshark Lua dissector
b. Relationships & Data Flows
1) Client → Weather Server (UDP request on port 4110)
2) Weather Server inspects packet type:
• If coordinate lookup → forward to Location Server → returns area code
• If weather/data request → forward to Query Server → returns weather packet
• If report packet → forward to Report Server
3) Location Server → PostgreSQL/PostGIS (coordinate → area code) + Redis cache
4) Query Server → fetch/process JMA source → Redis cache → packet build → reply
5) Report Server → validate/ingest sensor data → persistent store (DB)
6) All responses travel back via Weather Server → Client
c. Architectural Patterns / Design Principles
• Microservice-style separation per logical function (Proxy vs. Resolution vs. Data Retrieval vs. Reporting)
• UDP request-response, stateless services
• Shared caching (Redis) for performance
• Language-agnostic service endpoints (Rust/Python implementations interchangeable on same ports)
• Extensibility via protocol’s variable extension fields
d. Key Technologies
• Transport: UDP on distinct ports (4110–4112, 4109)
• Protocol: Custom 128-bit header + optional extension fields
• Servers: Python (FastAPI for map UI, custom UDP handlers), Rust (high-performance clients), C++ (packet codec & CLI)
• Databases: PostgreSQL (+PostGIS), Redis (Dragonfly)
• Build: CMake, pip/conda, Cargo
Detail Level
• Shared Redis cluster.
• Call out the protocol stack (Application → UDP) in a sidebar or footnote.
• Both runtime flow and data dependencies (caching, persistence).