This project is a Flask-based API for managing a cow farm. It allows for tracking cows, their milk production, and weight measurements. The system can generate reports on cow health and productivity.
- Add and retrieve cow information
- Record milk production and weight measurements
- Generate daily reports on cow health and productivity
- Detect potentially ill cows based on weight loss and milk production drop
- Python 3.8+
- pip (Python package installer)
-
Clone the repository:
git clone https://github.com/your-username/cow-farm-management.git cd cow-farm-management -
Create a virtual environment:
python -m venv venv -
Activate the virtual environment:
- On Windows:
venv\Scripts\activate - On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
- Create a
.envfile in the project root directory. - Add the following content to the
.envfile:DATABASE_URL=sqlite:///farm.db
-
Ensure you're in the project directory and your virtual environment is activated.
-
Run the Flask application:
python minimal_app.py -
The server will start, typically on
http://127.0.0.1:5000/.
GET /cows: Retrieve all cowsPOST /cows: Add a new cowPOST /cows/<id>: Create a new cow with a specific IDGET /cows/<id>: Get details of a specific cowPOST /sensors: Add a new sensorPOST /measurements: Add a new measurement (milk production or weight)GET /report: Generate and retrieve a report
The application includes a function to populate the database with initial data from parquet files. This is automatically run when the application starts.
To run the unit tests:
- Ensure you're in the project directory and your virtual environment is activated.
- Run the following command:
python -m unittest test_minimal_app.py
- If you encounter any database-related issues, try deleting the
farm.dbfile and restart the application. It will create a new database and populate it with initial data. - Ensure all required packages are installed by running
pip install -r requirements.txtagain.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.