EcoTrack is an environmental monitoring and reporting platform designed to track, analyze, and report on various environmental data. It allows users to submit data, manage profiles, receive alerts, and more. This platform is part of an initiative to increase awareness and active participation in environmental conservation efforts.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before you begin, ensure you have the following installed:
- Node.js - JavaScript runtime environment
- npm - Node Package Manager
- Access to a MySQL database (remote or local)
-
Clone the Repository
git clone [URL of your Git repository] cd EcoTrack
-
Install Dependencies
Run the following command in the root directory of your project to install all required dependencies:
npm install
-
Environment Setup
Create a
.env
file in your root directory with the following content, replacing the values with your database credentials:DB_HOST=your_database_host DB_USER=your_database_username DB_PASS=your_database_password DB_NAME=your_database_name DB_PORT=your_database_port CA_CERT_PATH=/path/to/your/ca_certificate.pem
Ensure that the path to your CA certificate is correct and the file is accessible.
-
Running the Server
Start the server by running:
node server.js
You should see a message indicating that the server is running on a specified port.
-
Testing the Server
Ensure the application functions as expected by running automated tests:
npm test
Successful tests will display messages indicating passed tests for various API endpoints.
After starting the server, you can access the API endpoints through http://localhost:[PORT]
where [PORT]
is the port number your server is running on (default is 3000).
EcoTrack offers a RESTful API for environmental monitoring and reporting, supporting various operations related to data collection, user profiles, environmental alerts, community reporting, and more.
- Description: Submit environmental data.
- Request Payload:
{ "user_id": int, "data_type": "string", "value": float, "timestamp": "datetime", "location": "string" }
- Response: Confirmation message with the ID of the added data.
- Description: Retrieve all environmental data.
- Response: An array of all environmental data records.
- Description: Create a new user profile.
- Request Payload:
{ "username": "string", "email": "string", "password": "string" }
- Response: Confirmation message with the ID of the created user.
- Description: Retrieve a specific user profile.
- URL Parameter:
id
(user ID) - Response: User profile data for the specified ID.
- Description: Create an environmental alert.
- Request Payload:
{ "user_id": int, "message": "string", "threshold": float, "timestamp": "datetime" }
- Response: Confirmation message with the ID of the created alert.
- Description: Retrieve all environmental alerts.
- Response: An array of all alert records.
- Description: Submit a community report on environmental issues.
- Request Payload:
{ "user_id": int, "issue_type": "string", "description": "string", "timestamp": "datetime", "location": "string" }
- Response: Confirmation message with the ID of the created report.
- Description: Retrieve all community reports.
- Response: An array of all report records.
- Description: Retrieve the sustainability score of a specific user.
- URL Parameter:
id
(user ID) - Response: Sustainability score for the specified user.
- Description: Retrieve educational resources (functionality not yet implemented).
- Description: Retrieve aggregated environmental data for research purposes.
- Response: Aggregated environmental data useful for research.
EcoTrack's API endpoints provide descriptive HTTP status codes and messages to handle errors effectively. This includes scenarios like invalid request parameters, database connection issues, and resource not found situations.
For guidelines on contributing to EcoTrack, please read [CONTRIBUTING.md](URL to your contributing guidelines).
This project is currently unlicensed.
Usage: Node.js serves as the project's runtime environment, facilitating the creation of scalable and efficient server-side applications.
Usage: Express, a minimalist web application framework, simplifies API development by handling routing, middleware, and HTTP requests, streamlining the creation of RESTful endpoints.
Usage: MySQL, a reliable relational database system, was employed to store and manage structured data, ensuring data integrity and efficient querying for user profiles, environmental data, alerts, and reports.
Usage: npm simplifies dependency management by allowing the installation and maintenance of project dependencies like Express, Axios, and Jest.
Usage: Dotenv securely manages sensitive configuration data, such as database credentials and API keys, by loading them from a .env file into the project.
Usage: Jest, a JavaScript testing framework, automates testing for the EcoTrack API, ensuring reliability through comprehensive test cases covering input validation, database interactions, and error handling.
####Axios Usage: Axios simplifies external data integration, making HTTP requests to fetch real-time air quality, weather data, and potential educational resources for the EcoTrack platform.
For guidelines on deploying EcoTrack in a production environment, please refer to the deployment section.
[Optional additional sections on project background, future enhancements, etc.]