This project is a full-stack application that manages user locations using OpenWeatherMap API to fetch geographic data based on zip codes. The application is built using a modern stack with TypeScript, tRPC, React, and Firebase Realtime Database.
- ✅ Complete CRUD operations for user management
- ✅ Firebase Authentication with Email/Password
- ✅ Protected routes and authenticated API endpoints
- ✅ Firebase Realtime Database integration for real-time data updates
- ✅ Automatic fetching of geographic data (latitude, longitude, timezone) from OpenWeatherMap API
- ✅ Interactive map visualization of user locations using Google Maps
- ✅ Real-time updates across all connected clients
- ✅ Type-safe end-to-end API using tRPC
- ✅ Monorepo architecture for better code organization and sharing
- ✅ Automated deployment using GitHub Actions
- ✅ Backend deployed to Google Cloud Run
- ✅ Frontend deployed to Netlify
- Frontend: React, TypeScript, Tailwind CSS, Framer Motion
- Backend: Node.js, TypeScript, tRPC
- Database: Firebase Realtime Database
- Authentication: Firebase Authentication
- APIs: OpenWeatherMap API, Google Maps API
- Build Tools: Turborepo, Vite
- Package Manager: Bun
- Deployment: GitHub Actions, Google Cloud Run, Netlify
- Clone the repository
git clone https://github.com/betiol/weather-app.git
cd weather-app- Install dependencies
bun install- Set up environment variables:
Create .env files in both apps/api and apps/web directories:
For apps/api/.env:
PORT=your_app_port
OPENWEATHER_API_KEY=your_openweather_api_key
FIREBASE_PROJECT_ID=your_firebase_project_id
FIREBASE_PRIVATE_KEY=your_firebase_private_key
FIREBASE_CLIENT_EMAIL=your_firebase_client_email
FIREBASE_DATABASE_URL=your_firebase_database_urlFor apps/web/.env:
VITE_API_BASE_URL=your_api_base_url
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
VITE_FIREBASE_DATABASE_URL=your_firebase_database_url
VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id
VITE_FIREBASE_APP_ID=your_firebase_app_id
VITE_GOOGLE_MAPS_API_KEY=your_google_maps_api_key- Start the development servers
bun devThis will start both the API and web application in development mode. The web application will be available at http://localhost:5173 and the API at http://localhost:3000.
The application is deployed and available online:
- Frontend: Deployed on Netlify with automatic deployment from the main branch
- Backend: Deployed on Google Cloud Run with containerized deployment
- CI/CD: GitHub Actions automatically builds and deploys both frontend and backend on every push to main
The application uses Firebase Authentication for secure user access:
- Email/Password authentication
- Protected routes using React Context
- Authenticated tRPC endpoints
- Secure session management
- Real-time authentication state updates
tRPC was chosen over traditional REST for several key benefits:
- Type Safety: tRPC provides end-to-end type safety between the client and server without manual type synchronization or code generation.
- Developer Experience: Automatic IntelliSense and type checking across the full stack.
- Performance: Smaller bundle size and better performance compared to REST clients due to its minimal runtime.
- Real-time Capabilities: Built-in support for subscriptions and real-time updates.
The project uses a monorepo architecture with Turborepo for several reasons:
- Code Sharing: Shared types and utilities between frontend and backend.
- Consistent Development Experience: Single command to run all services.
- Dependency Management: Centralized package management and versioning.
- Build Performance: Turborepo's intelligent build caching.
The project is organized into:
apps/api: Backend tRPC serverapps/web: React frontend applicationpackages/: Shared code (types, utilities)
The project includes several types of tests:
-
Unit Tests: Service layer testing using Jest
- User service operations
- Weather service integration
- Firebase database operations
- Authentication flows
-
Integration Tests: API endpoint testing
- CRUD operations
- Error handling
- Data validation
- Authentication middleware
-
Manual Testing:
- Cross-browser compatibility
- Responsive design
- Real-time updates
- Map interaction
- Form validation
- Authentication flows
- Session management
-
API Endpoints Testing:
- All CRUD operations (Create, Read, Update, Delete)
- Authentication middleware feature
- Error handling for invalid zip codes
- OpenWeatherMap API integration
-
Frontend features:
- User registration and login flows
- Form validation (name and zip code fields)
- Real-time updates when users are added/edited/deleted
- Google Maps integration and marker display
- Responsive design across different screen sizes
-
Integration Testing:
- End-to-end user creation workflow
- Geographic data fetching from zip codes
- Firebase Realtime Database operations
- tRPC client-server communication
-
Manual Testing Scenarios:
- Created users with various zip codes (valid and invalid)
- Updated user information and verified re-fetching of location data
- Tested authentication flows (login, logout, session persistence)
- Verified real-time updates across multiple browser tabs
- Tested map interactions and marker clustering
- Cross-browser compatibility (Chrome, Firefox, Safari)
- Users are identified by unique IDs generated by Firebase
- Zip codes are assumed to be US-based for OpenWeatherMap API
- All users have valid zip codes that can be geocoded
- Google Maps API is used for visualization only
- Real-time updates are required for collaborative features
- Email/Password is sufficient for authentication needs