Skip to content

shamshodbekdevops/weather_app

Repository files navigation

🌀️ Django Weather Application

Real-time ob-havo ma'lumotlari va havo sifatini kuzatish ilovasi

Python Django Railway License

🌐 Live Demo: https://shamshod-weather.up.railway.app


πŸ“‹ Mundarija


✨ Xususiyatlari

🌑️ Joriy Ob-havo

  • Real-time harorat va his etilgan harorat
  • Shamol tezligi va yo'nalishi
  • Namlik va atmosfera bosimi
  • Osmon holati (bulutlilik, yomg'ir, qor va h.k.)
  • Mahalliy vaqt (timezone-aware)

πŸ’¨ Havo Ifloslanish Monitoringi

  • Air Quality Index (AQI) real-time
  • PM2.5 va PM10 zarralar miqdori
  • CO, NOβ‚‚, O₃, SOβ‚‚ gazlar konsentratsiyasi
  • Niqob tavsiyalari AQI asosida
  • Rang kodlangan xavf darajalari

πŸ“… 5 Kunlik Prognoz

  • Kunlik minimal/maksimal harorat
  • O'rtacha namlik
  • Ob-havo tavsifi (o'zbekcha)
  • Kun nomlari (o'zbekcha)
  • Ikonali vizual ko'rinish

🎨 Foydalanuvchi Tajribasi

  • Responsive dizayn (mobile, tablet, desktop)
  • Bootstrap 5 UI framework
  • Real-time shahar qidiruv
  • Session-based shahar eslab qolish
  • Xatoliklarni qulay ko'rsatish

πŸŽ₯ Demo Screenshots

Joriy Ob-havo Sahifasi

🌐 https://shamshod-weather.up.railway.app/

Havo Ifloslanish

🌐 https://shamshod-weather.up.railway.app/pollution/

5 Kunlik Prognoz

🌐 https://shamshod-weather.up.railway.app/forecast/

πŸ› οΈ Texnologiyalar

Backend

  • Django 5.2.7 - Python web framework
  • Gunicorn - WSGI HTTP server (production)
  • Requests - HTTP library for API calls
  • dj-database-url - Database configuration

Frontend

  • Bootstrap 5 - CSS framework
  • Django Templates - Server-side rendering
  • Font Awesome - Icons

Database

  • SQLite - Local development
  • PostgreSQL - Production (Railway optional)
  • Cookie-based Sessions - Railway-compatible

API

  • OpenWeather API - Weather data provider
    • Current Weather API
    • Air Pollution API
    • 5 Day Forecast API
    • Geocoding API

Deployment

  • Railway.app - Cloud platform
  • WhiteNoise - Static files serving
  • GitHub - Version control

πŸš€ Lokal O'rnatish

Talablar

  • Python 3.12 yoki yuqori
  • pip (Python package manager)
  • Git

1️⃣ Repository Klonlash

git clone https://github.com/shamshodbekdevops/weather_app.git
cd weather_app

2️⃣ Virtual Environment Yaratish

Windows:

python -m venv venv
venv\Scripts\activate

macOS/Linux:

python3 -m venv venv
source venv/bin/activate

3️⃣ Dependencies O'rnatish

pip install -r requirements.txt

4️⃣ Environment Variables Sozlash

.env fayli yaratish (yoki mavjud fayldagi qiymatlarni o'zgartirish):

# Django Settings
SECRET_KEY=django-insecure-your-secret-key-here
DEBUG=True

# OpenWeather API
OPENWEATHER_API_KEY=your_api_key_here

# Allowed Hosts
ALLOWED_HOSTS=127.0.0.1,localhost

⚠️ Eslatma: .env fayli .gitignore'da β€” hech qachon commit qilmang!

5️⃣ Database Migration

python manage.py migrate

6️⃣ Static Files Yig'ish

python manage.py collectstatic --noinput

7️⃣ Development Server Ishga Tushirish

python manage.py runserver

πŸ“± Brauzerda: http://127.0.0.1:8000


🌐 Railway Deploy

Quick Deploy (5 daqiqa)

1️⃣ GitHub Repository Push:

git add .
git commit -m "Ready for deployment"
git push origin main

2️⃣ Railway Setup:

  • railway.app ga o'ting
  • GitHub bilan login qiling
  • "New Project" β†’ "Deploy from GitHub repo"
  • Repository tanlang: weather_app

3️⃣ Environment Variables:

Railway Dashboard β†’ Variables:

Variable Value
SECRET_KEY Yangi secure key (generator)
OPENWEATHER_API_KEY OpenWeather API key
DEBUG False
RAILWAY_PUBLIC_DOMAIN shamshod-weather.up.railway.app

πŸ’‘ SECRET_KEY generatsiya qilish:

python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

4️⃣ Deploy!

  • Railway avtomatik build va deploy qiladi
  • Logs'ni kuzating
  • App URL'ni oching

PostgreSQL Qo'shish (Ixtiyoriy)

Railway β†’ Add Service β†’ PostgreSQL

  • DATABASE_URL avtomatik sozlanadi
  • Redeploy qiling

πŸ”‘ API Konfiguratsiya

OpenWeather API Key Olish

  1. OpenWeatherMap ga o'ting
  2. Account yarating (bepul)
  3. API Keys bo'limiga o'ting
  4. Default API key'ni ko'ching
  5. .env faylga qo'ying:
    OPENWEATHER_API_KEY=your_api_key_here

Limitlar (Free Plan)

  • βœ… 60 calls/minute
  • βœ… 1,000,000 calls/month
  • βœ… Current weather
  • βœ… 5 day forecast
  • βœ… Air pollution data

πŸ“ Loyiha Strukturasi

WeatherAPPNew/
β”œβ”€β”€ πŸ“‚ core/                      # Django proyekt sozlamalari
β”‚   β”œβ”€β”€ settings.py              # Asosiy konfiguratsiya
β”‚   β”œβ”€β”€ urls.py                  # URL routing
β”‚   β”œβ”€β”€ wsgi.py                  # WSGI entry point
β”‚   └── asgi.py                  # ASGI entry point
β”‚
β”œβ”€β”€ πŸ“‚ weather/                   # Weather application
β”‚   β”œβ”€β”€ views.py                 # Business logic
β”‚   β”œβ”€β”€ urls.py                  # App URL patterns
β”‚   β”œβ”€β”€ models.py                # Database models
β”‚   β”œβ”€β”€ admin.py                 # Admin panel config
β”‚   └── migrations/              # Database migrations
β”‚
β”œβ”€β”€ πŸ“‚ templates/                 # HTML templates
β”‚   β”œβ”€β”€ base.html               # Base template
β”‚   β”œβ”€β”€ current_weather.html    # Current weather view
β”‚   β”œβ”€β”€ air_pollution.html      # Air pollution view
β”‚   └── five_day_forecast.html  # Forecast view
β”‚
β”œβ”€β”€ πŸ“‚ static/                    # Static files (auto-created)
β”‚   └── (CSS, JS, images)
β”‚
β”œβ”€β”€ πŸ“‚ staticfiles/               # Collected static files (production)
β”‚
β”œβ”€β”€ πŸ“„ manage.py                  # Django CLI
β”œβ”€β”€ πŸ“„ requirements.txt           # Python dependencies
β”œβ”€β”€ πŸ“„ Procfile                   # Railway deployment config
β”œβ”€β”€ πŸ“„ runtime.txt                # Python version specification
β”œβ”€β”€ πŸ“„ .env                       # Environment variables (local)
β”œβ”€β”€ πŸ“„ .gitignore                 # Git ignore patterns
β”œβ”€β”€ πŸ“„ db.sqlite3                 # SQLite database (local)
└── πŸ“„ README.md                  # Documentation (shu fayl)

βš™οΈ Environment Variables

Local Development (.env)

# Django Core
SECRET_KEY=django-insecure-your-secret-key-here
DEBUG=True

# OpenWeather API
OPENWEATHER_API_KEY=your_openweather_api_key

# Network
ALLOWED_HOSTS=127.0.0.1,localhost

Production (Railway)

Variable Tavsif Misol
SECRET_KEY Django secret key (50+ belgi) django-insecure-abc123...
OPENWEATHER_API_KEY OpenWeather API key 259afab76ef42e09f45...
DEBUG Debug mode (FALSE!) False
RAILWAY_PUBLIC_DOMAIN Railway public domain shamshod-weather.up.railway.app
DATABASE_URL PostgreSQL URL (ixtiyoriy) postgresql://user:pass@...

πŸ”§ Troubleshooting

❌ ModuleNotFoundError

Sabab: Dependencies o'rnatilmagan

Yechim:

pip install -r requirements.txt

❌ Static Files Yuklanmayapti

Sabab: Static files yig'ilmagan

Yechim:

python manage.py collectstatic --noinput --clear

❌ CSRF Verification Failed

Sabab: Railway domeni trusted origins'da yo'q

Yechim: Railway Variables'da qo'shing:

RAILWAY_PUBLIC_DOMAIN=shamshod-weather.up.railway.app

❌ Invalid API Key

Sabab: OpenWeather API key noto'g'ri yoki faol emas

Yechim:

  1. OpenWeatherMap ga o'ting
  2. API key'ni tekshiring (faol bo'lishi kerak)
  3. Railway Variables'da yangilash
  4. Redeploy qiling

❌ 500 Internal Server Error

Sabab: Server xatosi (settings, database, yoki kod xatosi)

Yechim:

  1. Railway Logs'ni tekshiring: Deployments β†’ Logs
  2. DEBUG=True (faqat test uchun!) qilib xatoni ko'ring
  3. Error traceback asosida tuzatish

❌ Database Migration Error

Sabab: Migrations o'tkazilmagan

Yechim:

# Local
python manage.py migrate

# Railway (avtomatik - Procfile'da)
# Agar ishlamasa, Railway console'dan:
python manage.py migrate --noinput

πŸ›‘οΈ Xavfsizlik

Production Checklist

  • DEBUG = False production'da
  • SECRET_KEY yangi va uzoq (50+ belgi)
  • .env fayling .gitignore'da
  • HTTPS (Railway avtomatik)
  • CSRF protection enabled
  • ALLOWED_HOSTS to'g'ri sozlangan
  • Secure cookies (production'da)
  • HSTS headers enabled

API Key Xavfsizligi

  • ⚠️ Hech qachon API key'ni GitHub'ga commit qilmang
  • βœ… Environment variables ishlatish
  • βœ… .env fayling .gitignore'da
  • βœ… Railway'da Variables orqali sozlash
  • βœ… OpenWeather free plan cheklovlarini bilish (60 req/min)

πŸ“Š Ishlash Metrikalari

OpenWeather API Limitlar (Free Tier)

Metric Limit
Calls/Minute 60
Calls/Month 1,000,000
Response Time ~200-500ms
Data Update Har 10 daqiqa

Railway Resources (Free Tier)

Resource Limit
RAM 512MB (default)
CPU Shared
Bandwidth 100GB/month
Deploy Time ~2-5 daqiqa

πŸ”„ Update va Maintenance

Kodni Yangilash

# 1. Lokal o'zgarishlar
git add .
git commit -m "Feature: yangi funksiya"

# 2. GitHub'ga push
git push origin main

# 3. Railway avtomatik deploy qiladi
# Logs'ni kuzatish: Railway Dashboard β†’ Deployments

Dependency Yangilash

# Dependencies'ni tekshirish
pip list --outdated

# Ma'lum paketni yangilash
pip install --upgrade django

# requirements.txt yangilash
pip freeze > requirements.txt

🀝 Contributing

Loyihaga hissa qo'shishni xohlaysizmi? Xush kelibsiz!

Qadamlar:

  1. Fork qiling
  2. Feature branch yarating (git checkout -b feature/YangiFunksiya)
  3. Commit qiling (git commit -m 'Add: Yangi funksiya')
  4. Push qiling (git push origin feature/YangiFunksiya)
  5. Pull Request oching

Code Style

  • Python: PEP 8
  • Django: Django Style Guide
  • Comments: O'zbekcha yoki Inglizcha
  • Naming: Snake_case (Python), kebab-case (HTML/CSS)

πŸ“ To-Do / Roadmap

  • User authentication & profiles
  • Sevimli shaharlar ro'yxati
  • Email/SMS xabarnomalar (haddan tashqari AQI)
  • Historical weather data charts
  • Multi-language support (πŸ‡ΊπŸ‡Ώ πŸ‡¬πŸ‡§ πŸ‡·πŸ‡Ί)
  • PWA (Progressive Web App)
  • Dark mode theme
  • Weather alerts & warnings
  • UV Index tracking
  • Hourly forecast (24 soatlik)

πŸ“š Resurslar va Havolalar

Dokumentatsiya

Qo'shimcha


πŸ“§ Aloqa

Developer: Shamshodbek
GitHub: @shamshodbekdevops
Project: weather_app
Live Demo: shamshod-weather.up.railway.app


πŸ“œ Litsenziya

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2026 Shamshodbek

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

🌟 Minnatdorchilik


⭐ Star Us!

Agar bu loyiha sizga yoqsa, ⭐ star bosishni unutmang!

GitHub stars GitHub forks


Made with ❀️ in Uzbekistan πŸ‡ΊπŸ‡Ώ

🌐 Live Demo β€’ πŸ“– Documentation β€’ πŸ› Report Bug β€’ ✨ Request Feature

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors