This guide will help you set up and run the DisasterWatch web application locally.
Before you begin, ensure you have the following installed:
- Node.js 18.x or higher
- npm 9.x or higher
- Git
- A code editor (VS Code recommended)
- A Google Maps API key (for map functionality)
-
Clone the repository:
git clone https://github.com/yourusername/DisasterWebFrontend.git cd DisasterWebFrontend -
Install dependencies:
npm install
-
Create a
.env.localfile in the root directory with the following variables:NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key NEXT_PUBLIC_API_URL=your_backend_api_url NEXT_PUBLIC_VAPID_PUBLIC_KEY=your_vapid_public_key VAPID_PRIVATE_KEY=your_vapid_private_key -
Generate VAPID keys for push notifications:
npx web-push generate-vapid-keys
-
Start the development server:
npm run dev
-
Open http://localhost:3000 in your browser.
-
The application will automatically reload if you change any of the source files.
npm run dev- Start development server with Turbopacknpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint
src/
├── app/ # Next.js app router pages and layouts
├── components/ # Reusable UI components
│ ├── ui/ # shadcn/ui components
│ ├── common/ # Common components
│ └── ... # Feature-specific components
├── lib/ # Utility functions and constants
├── hooks/ # Custom React hooks
├── provider/ # Context providers
└── api/ # API route handlers
-
Code Style
- Follow the Airbnb React/JSX Style Guide
- Use TypeScript for type safety
- Implement proper error handling
-
Component Structure
- Place reusable components in
src/components - Group related components in subdirectories
- Create barrel exports (index.ts) for clean imports
- Place reusable components in
-
State Management
- Use React Context for global state
- Implement custom hooks for complex state logic
- Keep component state local when possible
-
Styling
- Use Tailwind CSS utility classes
- Follow mobile-first responsive design
- Maintain consistent spacing and typography
-
Build Errors
- Clear the
.nextdirectory:rm -rf .next - Reinstall dependencies:
rm -rf node_modules && npm install - Check for TypeScript errors:
npm run type-check
- Clear the
-
Environment Variables
- Ensure all required environment variables are set in
.env.local - Restart the development server after updating environment variables
- Ensure all required environment variables are set in
-
API Connection Issues
- Verify the API URL in
.env.local - Check network connectivity
- Review API documentation for correct endpoints
- Verify the API URL in
- Check the Issues page
- Create a new issue with detailed information about your problem
- Join our Discord community for real-time support
- Review the Architecture documentation
- Learn about Authentication
- Explore Features
- Check the API Documentation