


世界各地の降雪・積雪情報を取得してグラフで可視化するアプリ!
https://github.com/nao317/snow_cup
** 以下 README抜粋 **
世界中の降雪情報をAPIを叩いて取得するアプリ C3 Snowカップのためのプロダクト
┌─────────────────┐
│ ブラウザ │
│ (Next.js UI) │
└────────┬────────┘
│ HTTP/REST (内部API)
▼
┌─────────────────────────────┐
│ Go バックエンド (APIプロキシ) │
│ - キャッシュ層 │
│ - データ変換 │
│ - セキュリティ │
└────┬──────────────────┬─────┘
│ SQL │ HTTPS
▼ ▼
┌─────────────┐ ┌──────────────────┐
│ MySQL DB │ │ Open-Meteo API │
│ (キャッシュ) │ │ (外部天気API) │
└─────────────┘ └──────────────────┘
アーキテクチャのポイント:
/api/geocoding?name={地名} をリクエスト/api/weather?lat=xxx&lon=xxx¤t=true をリクエストcurrent_weather フィールドhourly フィールドhttps://geocoding-api.open-meteo.com/v1/searchname: 検索する地名(例: "Tokyo", "札幌", "New York")count: 返却する候補数(デフォルト: 10)language: 言語(ja, en 等)format: レスポンス形式(json)リクエスト例:
GET https://geocoding-api.open-meteo.com/v1/search?
name=Tokyo&
count=10&
language=ja&
format=json
レスポンス例:
{
"results": [
{
"id": 1850144,
"name": "Tokyo",
"latitude": 35.6895,
"longitude": 139.69171,
"country": "Japan",
"admin1": "Tokyo",
"timezone": "Asia/Tokyo"
}
]
}
https://api.open-meteo.com/v1/forecastlatitude, longitude: 緯度経度current: 現在の気象(temperature_2m,snowfall,snow_depth,weather_code)hourly: 時系列データ(temperature_2m,snowfall,snow_depth)past_days: 過去データ日数(例: 7)forecast_days: 予測日数(例: 7)timezone: タイムゾーン(auto または Asia/Tokyo)リクエスト例(現在 + 時系列):
GET https://api.open-meteo.com/v1/forecast?
latitude=35.68&
longitude=139.65&
current=temperature_2m,snowfall,snow_depth,weather_code&
hourly=temperature_2m,snowfall,snow_depth&
past_days=7&
forecast_days=7&
timezone=auto
レスポンス例:
{
"current": {
"time": "2026-03-04T15:00",
"temperature_2m": 8.5,
"snowfall": 0.0,
"snow_depth": 2.5,
"weather_code": 3
},
"hourly": {
"time": ["2026-02-26T00:00", ...],
"temperature_2m": [5.2, 6.1, ...],
"snowfall": [0.0, 0.5, ...],
"snow_depth": [0.0, 0.5, ...]
}
}
// example
AllowOrigins: []string{"http://localhost:3000", "https://yourdomain.com"}
golang.org/x/time/rate).env ファイルは .gitignore に追加snow_cup/
├── README.md
├── docker-compose.yml # 全サービスの統合管理
├── .gitignore
│
├── backend/ # Go バックエンド
│ ├── Dockerfile
│ ├── go.mod
│ ├── go.sum
│ ├── main.go # エントリーポイント
│ ├── cmd/
│ │ └── server/
│ │ └── main.go # サーバー起動
│ ├── internal/
│ │ ├── config/ # 設定管理
│ │ │ └── config.go
│ │ ├── handler/ # HTTPハンドラー
│ │ │ ├── weather.go # 気象データAPI
│ │ │ ├── geocoding.go # 場所検索API
│ │ │ └── health.go # ヘルスチェック
│ │ ├── middleware/ # ミドルウェア
│ │ │ ├── cors.go # CORS設定
│ │ │ ├── ratelimit.go # レート制限
│ │ │ └── logger.go # ロギング
│ │ ├── service/ # ビジネスロジック
│ │ │ ├── weather_service.go # 気象データ処理
│ │ │ ├── geocoding_service.go # 場所検索処理
│ │ │ ├── openmeteo.go # Open-Meteo API クライアント
│ │ │ └── cache_service.go # キャッシュロジック
│ │ ├── repository/ # データアクセス層
│ │ │ ├── snow_repository.go
│ │ │ ├── cache_repository.go # キャッシュDB操作
│ │ │ └── mysql.go # DB接続
│ │ └── model/ # データモデル
│ │ ├── weather.go # 気象データモデル
│ │ ├── location.go # 地点情報モデル
│ │ └── cache.go # キャッシュモデル
│ ├── pkg/ # 公開パッケージ
│ │ └── utils/
│ │ └── time.go
│ ├── migrations/ # DBマイグレーション
│ │ ├── 001_create_weather_data.sql
│ │ ├── 002_create_locations.sql
│ │ └── 003_create_cache.sql # キャッシュテーブル
│ └── .env.example # 環境変数サンプル
│
├── frontend/ # Next.js フロントエンド
│ ├── Dockerfile
│ ├── package.json
│ ├── package-lock.json
│ ├── next.config.js
│ ├── tsconfig.json
│ ├── .eslintrc.json
│ ├── public/
│ │ ├── favicon.ico
│ │ └── images/
│ ├── src/
│ │ ├── app/ # App Router
│ │ │ ├── layout.tsx # ルートレイアウト
│ │ │ ├── page.tsx # トップページ
│ │ │ ├── page.module.css
│ │ │ └── globals.css
│ │ ├── components/ # 再利用コンポーネント
│ │ │ ├── SearchBar/
│ │ │ │ ├── SearchBar.tsx
│ │ │ │ └── SearchBar.module.css
│ │ │ ├── CurrentWeather/
│ │ │ │ ├── CurrentWeather.tsx
│ │ │ │ └── CurrentWeather.module.css
│ │ │ ├── Map/
│ │ │ │ ├── Map.tsx
│ │ │ │ └── Map.module.css
│ │ │ ├── SnowChart/
│ │ │ │ ├── SnowChart.tsx
│ │ │ │ └── SnowChart.module.css
│ │ │ ├── WeatherCard/
│ │ │ │ ├── WeatherCard.tsx
│ │ │ │ └── WeatherCard.module.css
│ │ │ └── Header/
│ │ │ ├── Header.tsx
│ │ │ └── Header.module.css
│ │ ├── lib/ # ユーティリティ
│ │ │ ├── api.ts # API クライアント
│ │ │ └── utils.ts
│ │ ├── types/ # TypeScript型定義
│ │ │ ├── weather.ts # 気象データ型
│ │ │ └── location.ts # 地点情報型
│ │ └── hooks/ # カスタムフック
│ │ ├── useWeatherData.ts # 気象データ取得
│ │ ├── useGeocoding.ts # 場所検索
│ │ └── useMap.ts # マップ操作
│ └── .env.local.example # 環境変数サンプル
│
└── db/ # データベース設定
├── Dockerfile # MySQL初期化用
└── init/
└── init.sql # 初期データ投入
GET /api/geocoding?name={地名} - 場所検索(候補リスト取得)GET /api/weather?lat={lat}&lon={lon}¤t=true - 現在の気象 + 時系列データ取得GET /api/locations - 人気/プリセット地点一覧GET /health - ヘルスチェック1
投稿日時:
更新日時: