Order weather is an app where everyone can order specific weather at a specific time and place.
OrderWeather is a full-stack application that allows users to "order" good weather for a specific date and location. Users pay upfront, and if the weather conditions are met (no rain, temperature β₯20Β°C), the payment is captured. If the conditions are not met, the payment is automatically refunded.
- π€οΈ Weather Ordering: Select a date and location to order good weather
- π³ Stripe Payment Integration: Secure payment processing with manual capture
- π Weather Verification: Automatic weather checking using OpenWeatherMap API
- π° Automatic Refunds: Money returned if weather conditions aren't met
- β° Cron Job Processing: Scheduled weather checks and payment processing
- π Order Tracking: Real-time order status updates
orderweather/
βββ backend/ # Node.js/Express backend
β βββ src/
β β βββ config/ # Database configuration
β β βββ controllers/ # Route controllers
β β βββ models/ # MongoDB models
β β βββ routes/ # API routes
β β βββ services/ # Business logic (weather, payment, cron)
β β βββ server.js # Main server file
β βββ package.json
β βββ .env.example
β
βββ frontend/ # React frontend
β βββ public/
β βββ src/
β β βββ components/ # React components
β β βββ services/ # API service layer
β β βββ App.js
β β βββ index.js
β βββ package.json
β βββ .env.example
β
βββ .gitignore
βββ README.md
- Node.js (v16 or higher)
- MongoDB (local or Atlas)
- Stripe account
- OpenWeatherMap API key
-
Clone the repository
git clone https://github.com/hotabics/orderweather.git cd orderweather -
Setup Backend
cd backend npm install # Copy and configure environment variables cp .env.example .env # Edit .env with your credentials
Required environment variables:
PORT=5000 NODE_ENV=development MONGODB_URI=mongodb://localhost:27017/orderweather OPENWEATHER_API_KEY=your_openweather_api_key STRIPE_SECRET_KEY=your_stripe_secret_key STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret FRONTEND_URL=http://localhost:3000 -
Setup Frontend
cd ../frontend npm install # Copy and configure environment variables cp .env.example .env # Edit .env with your credentials
Required environment variables:
REACT_APP_API_URL=http://localhost:5000/api REACT_APP_STRIPE_PUBLIC_KEY=your_stripe_public_key
-
Start MongoDB (if running locally)
mongod
-
Start Backend Server
cd backend npm run devServer will run on http://localhost:5000
-
Start Frontend
cd frontend npm startApp will open on http://localhost:3000
- Sign up at https://openweathermap.org/
- Generate an API key
- Add to backend
.envfile
- Sign up at https://stripe.com/
- Get your test API keys from the dashboard
- Add both public and secret keys to respective
.envfiles
POST /api/orders- Create a new orderGET /api/orders/:orderId- Get order detailsGET /api/[email protected]- Get user ordersPOST /api/orders/:orderId/confirm- Confirm payment
GET /api/health- Check API status
-
User Orders Weather
- User selects date (1-5 days in future) and location
- Creates payment intent with Stripe (manual capture)
- Order stored in MongoDB with status "pending"
-
Payment Processing
- User completes payment with credit card
- Payment is authorized but not captured (held)
- Order status updated to "succeeded"
-
Weather Verification (Cron Job runs hourly)
- Checks orders where date has passed
- Fetches actual weather from OpenWeatherMap
- Compares with required conditions:
-
Payment Finalization
- If conditions met: Payment captured, order marked "fulfilled"
- If conditions not met: Payment cancelled/refunded, order marked "not_fulfilled"
- Node.js - Runtime environment
- Express - Web framework
- MongoDB - Database
- Mongoose - ODM
- Stripe - Payment processing
- Axios - HTTP client
- node-cron - Task scheduling
- React - UI framework
- Stripe React Elements - Payment UI
- React DatePicker - Date selection
- React Toastify - Notifications
- Axios - API client
{
userId: String,
email: String,
date: Date,
location: {
city: String,
lat: Number,
lon: Number
},
amount: Number,
currency: String,
paymentIntentId: String,
paymentStatus: String,
weatherConditions: {
requiredTemp: Number,
noRain: Boolean
},
status: String,
weatherCheckResult: {
actualTemp: Number,
hasRain: Boolean,
checkedAt: Date,
fulfilled: Boolean
}
}# Backend tests
cd backend
npm test
# Frontend tests
cd frontend
npm test- Set environment variables
- Deploy code
- Ensure MongoDB is accessible
- Cron jobs will run automatically
- Set environment variables
- Deploy code
- Update backend CORS settings
ISC
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
- Never commit
.envfiles - Use environment variables for all sensitive data
- Stripe webhooks should be verified in production
- Implement rate limiting for production
- Add authentication/authorization for user-specific operations
For issues or questions, please open an issue on GitHub.
Order weather is app where everyone can order specific weather in specific time and place
OpenWeatherMap API key:
- Within the next couple of hours, your API key ba8dcc457360639fc97cd4ea1903ed1f will be activated and ready to use
- You can later create more API keys on your account page
- Please, always use your API key in each API call
Endpoint:
- Please, use the endpoint api.openweathermap.org for your API calls
Example of API call: api.openweathermap.org/data/2.5/weather?q=London,uk&APPID=ba8dcc457360639fc97cd4ea1903ed1f
Useful links:
- API documentation https://openweathermap.org/api
- Details of your plan https://openweathermap.org/price