CalMiner
A web application to plan mining projects and estimate costs, returns and profitability.
Focuses on ore mining operations and covering parameters such as capital and operational expenditures, resource consumption, production output, and Monte Carlo simulations for risk analysis.
The system is designed to help mining companies make informed decisions by simulating various scenarios and analyzing potential outcomes based on stochastic variables.
A range of features are implemented to support these functionalities.
Features
- 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.
- Unified UI Shell: Server-rendered templates extend a shared base layout with a persistent left sidebar linking scenarios, parameters, costs, consumption, production, equipment, maintenance, simulations, and reporting views.
- Operations Overview Dashboard: The root route (
/) surfaces cross-scenario KPIs, charts, and maintenance reminders with a one-click refresh backed by aggregated loaders. - Theming Tokens: Shared CSS variables in
static/css/main.csscentralize the UI color palette for consistent styling and rapid theme tweaks. - Modular Frontend Scripts: Page-specific interactions now live in
static/js/modules, keeping templates lean while enabling browser caching and reuse. - Monte Carlo Simulation (in progress): Services and routes are scaffolded for future stochastic analysis.
Documentation & quickstart
This repository contains detailed developer and architecture documentation in the docs/ folder.
Quickstart contains developer quickstart, migrations, testing and current status.
Key architecture documents: see architecture for the arc42-based architecture documentation.
For contributors: the routes/, models/ and services/ folders contain the primary application code. Tests and E2E specs are in tests/.
Run with Docker
The repository ships with a multi-stage Dockerfile that produces a slim runtime image.
# Build the image locally
docker build -t calminer:latest .
# Run the container (exposes FastAPI on http://localhost:8000)
docker run --rm -p 8000:8000 calminer:latest
# Provide environment variables (e.g., database URL)
docker run --rm -p 8000:8000 -e DATABASE_URL="postgresql://user:pass@host/db" calminer:latest
Use docker compose or an orchestrator of your choice to co-locate PostgreSQL/Redis alongside the app when needed. The image expects migrations to be applied before startup.
CI/CD expectations
CalMiner uses Gitea Actions workflows stored in .gitea/workflows/:
test.ymlruns style/unit/e2e suites on every push with cached Python dependencies.build-and-push.ymlbuilds the Docker image, reuses cached layers, and pushes to the configured registry.deploy.ymlpulls the pushed image on the target host and restarts the container.
Pipelines assume the following secrets are provisioned in the Gitea instance: GITEA_USERNAME, GITEA_PASSWORD, GITEA_REGISTRY, SSH_HOST, SSH_USERNAME, and SSH_PRIVATE_KEY.