Refactor and enhance CalMiner application
- Updated README.md to reflect new features and usage instructions. - Removed deprecated Dashboard.html component and integrated dashboard functionality directly into the main application. - Revised architecture documentation for clarity and added module map and request flow diagrams. - Enhanced maintenance model to include equipment association and cost tracking. - Updated requirements.txt to include new dependencies (httpx, pandas, numpy). - Improved consumption, maintenance, production, and reporting routes with better validation and response handling. - Added unit tests for maintenance and production routes, ensuring proper CRUD operations and validation. - Enhanced reporting service to calculate and return detailed summary statistics. - Redesigned Dashboard.html for improved user experience and integrated Chart.js for visualizing simulation results.
This commit is contained in:
44
README.md
44
README.md
@@ -10,15 +10,15 @@ A range of features are implemented to support these functionalities.
|
||||
|
||||
## Features
|
||||
|
||||
- **Scenario Management**: The database supports different scenarios for what-if analysis, with parent-child relationships between scenarios.
|
||||
- **Monte Carlo Simulation**: The system can perform Monte Carlo simulations for risk analysis and probabilistic forecasting.
|
||||
- **Stochastic Variables**: The model handles uncertainty by defining variables with probability distributions.
|
||||
- **Cost Tracking**: It tracks capital (`capex`) and operational (`opex`) expenditures.
|
||||
- **Consumption Tracking**: It monitors the consumption of resources like chemicals, fuel, water, and scrap materials.
|
||||
- **Production Output**: The database stores production results, including tons produced, recovery rates, and revenue.
|
||||
- **Process Parameters**: It allows for defining and storing various parameters for different processes and scenarios.
|
||||
- **Equipment Management**: The system manages equipment and their operational data.
|
||||
- **Maintenance Logging**: It includes a log for equipment maintenance events.
|
||||
- **Scenario Management**: Manage multiple mining scenarios with independent parameter sets and outputs.
|
||||
- **Process Parameters**: Define and persist process inputs via FastAPI endpoints and template-driven forms.
|
||||
- **Cost Tracking**: Capture capital (`capex`) and operational (`opex`) expenditures per scenario.
|
||||
- **Consumption Tracking**: Record resource consumption (chemicals, fuel, water, scrap) tied to scenarios.
|
||||
- **Production Output**: Store production metrics such as tonnage, recovery, and revenue drivers.
|
||||
- **Equipment Management**: Register scenario-specific equipment inventories.
|
||||
- **Maintenance Logging**: Log maintenance events against equipment with dates and costs.
|
||||
- **Reporting Dashboard**: Surface aggregated statistics for simulation outputs with an interactive Chart.js dashboard.
|
||||
- **Monte Carlo Simulation (in progress)**: Services and routes are scaffolded for future stochastic analysis.
|
||||
|
||||
## Architecture
|
||||
|
||||
@@ -66,10 +66,36 @@ pip install -r requirements.txt
|
||||
uvicorn main:app --reload
|
||||
```
|
||||
|
||||
## Usage Overview
|
||||
|
||||
- **API base URL**: `http://localhost:8000/api`
|
||||
- **Key routes**:
|
||||
- `POST /api/scenarios/` create scenarios
|
||||
- `POST /api/parameters/` manage process parameters
|
||||
- `POST /api/costs/capex` and `POST /api/costs/opex` capture project costs
|
||||
- `POST /api/consumption/` add consumption entries
|
||||
- `POST /api/production/` register production output
|
||||
- `POST /api/equipment/` create equipment records
|
||||
- `POST /api/maintenance/` log maintenance events
|
||||
- `POST /api/reporting/summary` aggregate simulation results
|
||||
|
||||
### Dashboard Preview
|
||||
|
||||
1. Start the FastAPI server and navigate to `/dashboard` (served by `templates/Dashboard.html`).
|
||||
2. Use the "Load Sample Data" button to populate the JSON textarea with demo results.
|
||||
3. Select "Refresh Dashboard" to view calculated statistics and a distribution chart sourced from `/api/reporting/summary`.
|
||||
4. Paste your own simulation outputs (array of objects containing a numeric `result` property) to visualize custom runs.
|
||||
|
||||
## Testing
|
||||
|
||||
Testing guidelines and best practices are outlined in [docs/testing.md](docs/testing.md).
|
||||
|
||||
To execute the unit test suite:
|
||||
|
||||
```powershell
|
||||
pytest
|
||||
```
|
||||
|
||||
## Database Objects
|
||||
|
||||
The database is composed of several tables that store different types of information.
|
||||
|
||||
Reference in New Issue
Block a user