A real-time flight tracking application built with React and TypeScript, following Domain-Driven Design principles.
- Node.js 20.18 or higher
- npm 10.8 or higher
- A modern web browser (Chrome, Firefox, Safari, or Edge)
You'll need a Google Maps API key to display the map. Here's how to get one:
-
Go to the Google Cloud Console
-
Create a new project or select an existing one
-
Enable the required APIs:
- Maps JavaScript API
- Places API (if you plan to add search functionality)
-
Create credentials:
- Go to "Credentials" in the left sidebar
- Click "Create Credentials" > "API Key"
- Your new API key will be displayed
-
(Recommended) Restrict the API key:
- Go back to the Credentials page
- Click on the newly created API key
- Under "Application restrictions", choose "HTTP referrers"
- Add your development and production domains
- Under "API restrictions", select "Restrict key"
- Select the APIs you enabled (Maps JavaScript API, etc.)
- Click "Save"
The project follows a feature-based Domain-Driven Design approach where each feature is organized in its own directory with DDD layers:
src/
├── flights/ # Flight tracking feature
│ ├── ui/ # Presentation components
│ ├── application/ # Use cases and services
│ ├── domain/ # Entities and value objects
│ └── infrastructure/ # External services and adapters
├── shared/ # Shared utilities and components
└── App.tsx # Application entry point
tests/
├── flights/ # Flight feature tests
│ ├── ui/ # UI component tests
│ ├── domain/ # Domain logic tests
│ └── infrastructure/ # Infrastructure tests
└── setupTests.ts # Test environment setup
Each feature follows the DDD layered architecture:
- UI Layer: React components and hooks
- Application Layer: Services and use cases that orchestrate domain logic
- Domain Layer: Business entities, value objects, and core business rules
- Infrastructure Layer: External services, repositories, and technical implementations
The test structure mirrors the source code organization, making it easy to locate and maintain tests for each component.
- Clone the repository:
git clone git@github.com:luismr/flight-tracker-event-app.git
cd flight-tracker-event-app
- Install dependencies:
npm install
- Create a
env.js
file in the project root based on the example file:
// env.js
window.environment = {
WEBSOCKET_URL: "ws://localhost:8080/map-updates",
WEBSOCKET_RECONNECT_INTERVAL: 5000,
WEBSOCKET_MAX_RETRIES: 5,
GOOGLE_MAPS_API_KEY: "your-google-maps-api-key-here"
};
Note: The
env.js
file is used for runtime configuration. This file should be created locally and not committed to version control. For local development with Vite, this file needs to be placed in the project root.
- Start the development server:
npm run dev
The application will be available at http://localhost:5173
- Real-time flight tracking via WebSocket
- Interactive Google Maps display showing all flights
- Custom airplane icons with status indicators
- Detailed flight information cards
- Automatic map bounds adjustment to show all flights
- Responsive design for mobile browsers
npm run build
The built files will be in the dist
directory.
Build and run the application using Docker:
# Create a .env file with your environment variables
cat <<EOF > .env
VITE_GOOGLE_MAPS_API_KEY=your-google-maps-api-key-here
VITE_WEBSOCKET_URL=ws://your-websocket-server/map-updates
VITE_WEBSOCKET_RECONNECT_INTERVAL=5000
VITE_WEBSOCKET_MAX_RETRIES=3
EOF
docker-compose up -d
The application will be available at http://localhost
.
Build the image:
docker build -t flight-tracker-app .
docker run -d \
--name flight-tracker \
-p 80:80 \
-e GOOGLE_MAPS_API_KEY=your-google-maps-api-key-here \
-e WEBSOCKET_URL=ws://your-websocket-server/map-updates \
-e WEBSOCKET_RECONNECT_INTERVAL=5000 \
-e WEBSOCKET_MAX_RETRIES=3 \
flight-tracker-app
The application will use the environment variables that were set during the build process if not overridden at runtime. The default values are:
- WEBSOCKET_URL: ws://localhost:8080/map-updates
- WEBSOCKET_RECONNECT_INTERVAL: 5000
- WEBSOCKET_MAX_RETRIES: 3
Note: You can override the build-time variables by providing them at runtime using the -e
flag.
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage report
npm run test:coverage
The test suite includes:
- Unit tests for domain logic
- Component tests with React Testing Library
- Integration tests for infrastructure services
We welcome contributions! Here's how you can help:
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add some amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
Please make sure to:
- Follow the existing code style
- Add tests if applicable
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE.md file for details.