{"id":31675026,"url":"https://github.com/dax-side/weather_forecast_service","last_synced_at":"2026-05-09T03:31:38.244Z","repository":{"id":316504692,"uuid":"1062891722","full_name":"dax-side/weather_forecast_service","owner":"dax-side","description":"A weather forecast API and web dashboard built with NestJS. Pulls real-time data from OpenWeatherMap, caches results in SQLite, and serves both JSON API endpoints and a clean web interface. Deployed on Railway for easy access.","archived":false,"fork":false,"pushed_at":"2025-09-25T00:37:46.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-08T04:59:14.309Z","etag":null,"topics":["nestjs","nestjs-api","openweathermap","railway","rest-api","sqlite","typescript","weather-api","weather-forecast"],"latest_commit_sha":null,"homepage":"https://weatherforecastservice-production.up.railway.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dax-side.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T21:59:29.000Z","updated_at":"2025-09-25T00:37:50.000Z","dependencies_parsed_at":"2025-09-25T02:41:35.046Z","dependency_job_id":"34eccea5-6fa8-433b-b3a4-c428c466d44e","html_url":"https://github.com/dax-side/weather_forecast_service","commit_stats":null,"previous_names":["dax-side/weather_forecast_service"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dax-side/weather_forecast_service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dax-side%2Fweather_forecast_service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dax-side%2Fweather_forecast_service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dax-side%2Fweather_forecast_service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dax-side%2Fweather_forecast_service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dax-side","download_url":"https://codeload.github.com/dax-side/weather_forecast_service/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dax-side%2Fweather_forecast_service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32805882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nestjs","nestjs-api","openweathermap","railway","rest-api","sqlite","typescript","weather-api","weather-forecast"],"created_at":"2025-10-08T04:59:09.491Z","updated_at":"2026-05-09T03:31:38.232Z","avatar_url":"https://github.com/dax-side.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Weather Forecast Service\n\nA comprehensive NestJS-based weather forecast API that provides current weather data and forecasts for cities worldwide using the OpenWeatherMap API.\n\n## Features\n\n- Real-time current weather data\n- 5-day weather forecasts with 3-hour intervals\n- City search tracking and statistics\n- Scheduled background data refresh\n- SQLite database with TypeORM\n- Comprehensive API documentation with Swagger\n- Input validation and error handling\n- CORS enabled for cross-origin requests\n\n## Tech Stack\n\n- **Framework**: NestJS with TypeScript\n- **Database**: SQLite with TypeORM\n- **External API**: OpenWeatherMap API\n- **Documentation**: Swagger/OpenAPI\n- **Validation**: class-validator\n- **Scheduling**: @nestjs/schedule\n- **HTTP Client**: Axios\n\n## Prerequisites\n\n- Node.js (v16 or higher)\n- npm or yarn\n- OpenWeatherMap API key\n\n## Installation\n\n1. Clone the repository\n```bash\ngit clone \u003crepository-url\u003e\ncd weather_forecast_service\n```\n\n2. Install dependencies\n```bash\nnpm install\n```\n\n3. Set up environment variables\nCreate a `.env` file in the root directory:\n```\nOPENWEATHER_API_KEY=your_openweathermap_api_key_here\nPORT=3000\n```\n\n4. Build the application\n```bash\nnpm run build\n```\n\n5. Start the application\n```bash\nnpm start\n```\n\nThe server will start on `http://localhost:3000`\n\n## API Endpoints\n\n### Weather Endpoints\n\n- `GET /api/weather/current?city={cityName}` - Get current weather for a city\n- `GET /api/weather/forecast?city={cityName}` - Get 5-day weather forecast\n- `GET /api/weather/history` - Get search history\n- `GET /api/weather/cities` - Get all tracked cities\n\n### Dashboard Endpoints\n\n- `GET /` - Main dashboard page\n- `POST /search` - Search functionality\n\n## API Documentation\n\nInteractive API documentation is available at:\n```\nhttp://localhost:3000/api/docs\n```\n\n## Database Schema\n\nThe application uses four main entities:\n\n### CityEntity\n- Stores city information with coordinates\n- Tracks search statistics\n- Primary reference for weather data\n\n### WeatherEntity  \n- Current weather data for cities\n- Linked to CityEntity via foreign key\n- Automatically updated on API calls\n\n### ForecastEntity\n- Weather forecast data points\n- 3-hour interval forecasts up to 5 days\n- Linked to CityEntity\n\n### SearchHistoryEntity\n- Tracks search patterns\n- Records search frequency and timestamps\n\n## Caching Strategy\n\n- **Current Weather**: Cached for 15 minutes\n- **Forecast Data**: Cached for 1 hour\n- **Background Refresh**: Scheduled hourly updates for popular cities\n\n## Error Handling\n\nThe API provides comprehensive error responses:\n\n- `200 OK` - Success\n- `400 Bad Request` - Invalid input or API key issues  \n- `404 Not Found` - City not found\n- `500 Internal Server Error` - Server errors\n\n## Development\n\n### Available Scripts\n\n- `npm start` - Start production server\n- `npm run start:dev` - Start development server with hot reload\n- `npm run build` - Build the application\n- `npm run test` - Run tests\n- `npm run lint` - Run ESLint\n\n### Project Structure\n\n```\nsrc/\n├── controllers/         # API controllers\n├── services/           # Business logic services\n├── entities/           # Database entities\n├── dto/               # Data transfer objects\n├── app.module.ts      # Main application module\n└── main.ts           # Application entry point\n```\n\n## Configuration\n\n### Environment Variables\n\n- `OPENWEATHER_API_KEY` - Required: Your OpenWeatherMap API key\n- `PORT` - Optional: Server port (default: 3000)\n\n### Database\n\nThe application uses SQLite by default. The database file is automatically created as `weather.db` in the project root.\n\n## Performance Considerations\n\n- Database queries are optimized to prevent N+1 query problems\n- API responses are cached to reduce external API calls\n- Background tasks refresh popular city data proactively\n- Proper indexing on frequently queried fields\n\n## Security\n\n- Input validation on all endpoints\n- Environment variable protection for API keys\n- CORS configuration for secure cross-origin access\n- Error messages sanitized to prevent information leakage\n\n## Monitoring and Logging\n\n- Morgan middleware for HTTP request logging\n- Structured logging for debugging and monitoring\n- Error tracking with detailed stack traces in development\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdax-side%2Fweather_forecast_service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdax-side%2Fweather_forecast_service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdax-side%2Fweather_forecast_service/lists"}