Skip to content

jalbacar/react

Repository files navigation

Cellular Tower Monitoring System

This is a monorepo containing both the frontend React application and the backend Python Flask API for monitoring cellular tower anomalies.

Project Structure

.
├── package.json          # Monorepo configuration
├── backend/              # Python Flask API
│   ├── app.py            # Main Flask application
│   ├── requirements.txt  # Python dependencies
│   ├── .env              # Environment variables
│   └── logs/             # Telecom anomaly logs
│       └── telco_anomalies.log  # Sample telecom log file
└── cellular-tower-map/   # React frontend application
    ├── src/
    │   └── App.js        # Main React component
    └── ...

Backend API Endpoints

Get all towers

GET /api/towers

Returns all cellular towers with their current status and disfunctionality information derived from telecom logs.

Update tower status

PUT /api/towers/{tower_id}

Updates the status and disfunctionality of a specific tower (manual override).

Get tower status

GET /api/towers/{tower_id}/status

Returns the status and disfunctionality of a specific tower.

Analyze logs

GET /api/logs/analyze

Returns the parsed telecom log data for analysis purposes.

How It Works

The backend reads from logs/telco_anomalies.log which follows telecom standards with the format: timestamp|tower_id|component|severity|description

Severity levels (in order of impact):

  • INFO: No operational impact
  • WARNING: Minor issues, yellow marker
  • ERROR: Significant issues, red marker
  • CRITICAL: Major issues, red marker

Frontend Features

  • Interactive map showing cellular tower locations
  • Color-coded markers based on tower status (green=operational, yellow=warning, red=offline)
  • Detailed information window for each tower showing disfunctionality
  • Real-time data from telecom log analysis
  • Manual status update capability for towers

Technology Stack

Backend

  • Python Flask: Web framework for building RESTful APIs
  • Flask-CORS: Enables Cross-Origin Resource Sharing
  • python-dotenv: For managing environment variables

Frontend

  • React: JavaScript library for building user interfaces
  • @react-google-maps/api: Google Maps integration
  • React Scripts: Build toolchain for React applications

Setup Instructions

Prerequisites

  • Node.js (v14 or higher)
  • Python 3.8 or higher
  • npm (v6 or higher) or yarn

Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Install Python dependencies:

    pip install -r requirements.txt
  3. Start the backend server:

    python app.py

Frontend Setup

  1. Navigate to the frontend directory:

    cd cellular-tower-map
  2. Install JavaScript dependencies:

    npm install
  3. Start the development server:

    npm start

Running Both Applications Together

You can start both the backend and frontend servers simultaneously using:

npm run start:all

This command uses concurrently to run both applications at the same time.

Environment Variables

Backend (.env file)

  • FLASK_ENV=development: Sets the Flask environment to development
  • PORT=5000: Specifies the port for the Flask server

Data Format

The telecom log file (logs/telco_anomalies.log) follows this format: timestamp|tower_id|component|severity|description

Example:

2023-01-01 10:00:00|1|Power Supply|WARNING|Voltage fluctuation detected
2023-01-01 11:00:00|2|Antenna|ERROR|Signal degradation

Development Notes

Backend

  • The Flask app exposes RESTful endpoints for tower data and log analysis
  • The application parses telecom logs to determine tower status
  • Tower status is determined by the most recent log entry's severity level
  • The application includes mock data for tower locations (hardcoded in app.py)

Frontend

  • The React application integrates with Google Maps API
  • Tower data is fetched from the backend API endpoint
  • Interactive markers display tower status and allow manual status updates
  • Status update functionality is implemented via PUT requests to the backend

Testing

Backend

  • The application can be tested by sending HTTP requests to the defined endpoints
  • Log parsing functionality is tested with sample log entries
  • Tower status determination logic is validated through different severity levels

Frontend

  • Unit tests can be run using npm test
  • Manual testing of the map interface and interactivity is recommended
  • Integration testing between frontend and backend should verify data flow

Deployment

Backend

  • The Flask application can be deployed to any Python-compatible hosting platform
  • Consider using Gunicorn or similar WSGI servers for production deployment

Frontend

  • Build the application with npm run build
  • Deploy the contents of the build folder to any static web hosting service
  • Ensure the API endpoint URLs are configured correctly for production

Troubleshooting

Common Issues

  1. Missing Google Maps API Key:

    • Add your Google Maps API key to .env file in the frontend
    • Set REACT_APP_GOOGLE_MAPS_API_KEY environment variable
  2. Backend Server Not Starting:

    • Ensure Python dependencies are installed (pip install -r requirements.txt)
    • Verify the log file path exists and is accessible
  3. Frontend Not Loading:

    • Make sure the backend server is running before starting the frontend
    • Check browser console for CORS-related errors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published