6.0 KiB
6.0 KiB
Implementation Plan
This document outlines the MVP features and implementation steps for CalMiner.
Refer to the following for context alignment:
- System architecture: docs/architecture.md
- Development setup: docs/development_setup.md
Project Setup
- Connect to PostgreSQL database with schema
calminer. - Create and activate a virtual environment and install dependencies via
requirements.txt. - Define environment variables in
.env, includingDATABASE_URL. - Configure FastAPI entrypoint in
main.pyto include routers.
Feature: Scenario Management
Implementation Steps
- Create
models/scenario.pyfor scenario CRUD. - Implement API endpoints in
routes/scenarios.py(GET, POST, PUT, DELETE). - Write unit tests in
tests/unit/test_scenario.py. - Build UI component
components/ScenarioForm.html.
Feature: Process Parameters
Implementation Steps
- Create
models/parameters.pyfor process parameters. - Implement Pydantic schemas in
routes/parameters.py. - Add validation middleware in
middleware/validation.py. - Write unit tests in
tests/unit/test_parameter.py. - Build UI component
components/ParameterInput.html.
Feature: Stochastic Variables
Implementation Steps
- Create
models/distribution.pyfor variable distributions. - Implement API routes in
routes/distributions.py. - Write Pydantic schemas and validations.
- Write unit tests in
tests/unit/test_distribution.py. - Build UI component
components/DistributionEditor.html.
Feature: Cost Tracking
Implementation Steps
- Create
models/capex.pyandmodels/opex.py. - Implement API routes in
routes/costs.py. - Write Pydantic schemas for CAPEX/OPEX.
- Write unit tests in
tests/unit/test_costs.py. - Build UI component
components/CostForm.html.
Feature: Consumption Tracking
Implementation Steps
- Create models for consumption:
chemical_consumption.py,fuel_consumption.py,water_consumption.py,scrap_consumption.py. - Implement API routes in
routes/consumption.py. - Write Pydantic schemas for consumption data.
- Write unit tests in
tests/unit/test_consumption.py. - Build UI component
components/ConsumptionDashboard.html.
Feature: Production Output
Implementation Steps
- Create
models/production_output.py. - Implement API routes in
routes/production.py. - Write Pydantic schemas for production output.
- Write unit tests in
tests/unit/test_production.py. - Build UI component
components/ProductionChart.html.
Feature: Equipment Management
Implementation Steps
- Create
models/equipment.pyfor equipment data. - Implement API routes in
routes/equipment.py. - Write Pydantic schemas for equipment.
- Write unit tests in
tests/unit/test_equipment.py. - Build UI component
components/EquipmentList.html.
Feature: Maintenance Logging
Implementation Steps
- Create
models/maintenance.pyfor maintenance events. - Implement API routes in
routes/maintenance.py. - Write Pydantic schemas for maintenance logs.
- Write unit tests in
tests/unit/test_maintenance.py. - Build UI component
components/MaintenanceLog.html.
Feature: Monte Carlo Simulation Engine
Implementation Steps
- Implement Monte Carlo logic in
services/simulation.py. - Persist results in
models/simulation_result.py. - Expose endpoint in
routes/simulations.py. - Write integration tests in
tests/unit/test_simulation.py. - Build UI component
components/SimulationRunner.html.
Feature: Reporting / Dashboard
Implementation Steps
- Implement report calculations in
services/reporting.py. - Add detailed and summary endpoints in
routes/reporting.py. - Write unit tests in
tests/unit/test_reporting.py. - Enhance UI in
components/Dashboard.htmlwith charts.
MVP Feature Analysis (summary)
Goal: Identify core MVP features, acceptance criteria, and quick estimates.
Features:
-
Scenario Management
- Acceptance: create/read/update/delete scenarios; persist to DB; API coverage with tests.
- Estimate: 3-5 days (backend + minimal UI).
-
Parameter Input & Validation
- Acceptance: define parameter schemas, validate inputs, surface errors to API/UI.
- Estimate: 2-3 days.
-
Monte Carlo Simulation Engine
- Acceptance: run parameterised simulations, store results, ability to rerun with different seeds, basic progress reporting.
- Estimate: 1-2 weeks (core engine + persistence).
-
Reporting / Dashboard
- Acceptance: display simulation outputs (NPV, IRR distributions), basic charts, export CSV.
- Estimate: 4-7 days.
Edge cases to consider:
- Large simulation runs (memory / timeouts) — use streaming, chunking, or background workers.
- DB migration and schema versioning.
- Authentication/authorization for scenario access.
Next actionable items:
- Break Scenario Management into sub-issues (models, routes, tests, simple UI).
- Scaffold Parameter Input & Validation (models/parameters.py, middleware, routes, tests).
- Prototype the simulation engine with a small deterministic runner and unit tests.
- Scaffold Monte Carlo Simulation endpoints (
services/simulation.py,routes/simulations.py, tests). - Scaffold Reporting endpoints (
services/reporting.py,routes/reporting.py, front-end Dashboard, tests). - Add CI job for tests and coverage.
UI Template Audit (2025-10-20)
- Existing HTML templates:
ScenarioForm.html,ParameterInput.html, andDashboard.html(reporting summary view). - Coverage gaps remain for costs, consumption, production, equipment, maintenance, and simulation workflows—no dedicated templates yet.
- Shared layout primitives (navigation/header/footer) are absent; current pages duplicate boilerplate markup.
- Dashboard currently covers reporting metrics but should be wired to a central
/route once the shared layout lands. - Next steps align with the updated TODO checklist: introduce a
base.html, refactor existing templates to extend it, and scaffold placeholder pages for the remaining features.