
- Implemented FastAPI application structure - Added OpenWeatherMap API integration - Created SQLite database with SQLAlchemy - Setup Alembic for database migrations - Added health check endpoint - Created comprehensive README generated with BackendIM... (backend.im)
69 lines
1.4 KiB
Markdown
69 lines
1.4 KiB
Markdown
# Weather Data API
|
|
|
|
A FastAPI application that retrieves weather data from OpenWeatherMap and stores it in a SQLite database.
|
|
|
|
## Features
|
|
|
|
- Fetch current weather data from OpenWeatherMap
|
|
- Store weather data in a SQLite database
|
|
- Track weather history for cities
|
|
- RESTful API with FastAPI
|
|
- Database migrations with Alembic
|
|
- Health check endpoint
|
|
|
|
## Setup
|
|
|
|
1. Clone the repository
|
|
2. Install dependencies:
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. Run the application:
|
|
|
|
```bash
|
|
uvicorn main:app --reload
|
|
```
|
|
|
|
## API Endpoints
|
|
|
|
### Weather Endpoints
|
|
|
|
- `GET /api/v1/weather/current/{city_name}` - Get current weather for a city
|
|
- `POST /api/v1/weather/current` - Get current weather using request body
|
|
- `GET /api/v1/weather/cities` - List all cities
|
|
- `GET /api/v1/weather/cities/{city_id}` - Get city details
|
|
- `GET /api/v1/weather/history/{city_id}` - Get weather history for a city
|
|
|
|
### Health Check
|
|
|
|
- `GET /health` - Check application health
|
|
|
|
## Database
|
|
|
|
The application uses SQLite with SQLAlchemy. The database is stored in `/app/storage/db/db.sqlite`.
|
|
|
|
### Migrations
|
|
|
|
Database migrations are managed with Alembic:
|
|
|
|
```bash
|
|
# Apply migrations
|
|
alembic upgrade head
|
|
|
|
# Create a new migration
|
|
alembic revision -m "description"
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
- `OPENWEATHERMAP_API_KEY` - Your OpenWeatherMap API key (default: `bd5e378503939ddaee76f12ad7a97608`)
|
|
|
|
## Documentation
|
|
|
|
The API documentation is available at:
|
|
|
|
- Swagger UI: `/docs`
|
|
- ReDoc: `/redoc`
|