Predictive Reliability & Intelligence for Smart Manufacturing
This guide covers everything you need to set up your local development environment, follow the project's code standards, and contribute effectively.
- Prerequisites
- Local Setup
- Development Tools
- Pre-commit Hooks
- Running the Project
- Code Standards
- Testing
- Commit Message Convention
- Releasing
Make sure you have the following installed before starting:
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.10 or 3.11 | Backend runtime |
| Node.js | 20+ | Frontend runtime |
| Docker Desktop | Latest | Container builds |
| Git | Any | Version control |
git clone https://github.com/arcoder181105/manufacturing-intelligence.git
cd manufacturing-intelligence# Create a virtual environment
python -m venv venv
# Activate it
# Windows:
venv\Scripts\activate
# Mac/Linux:
source venv/bin/activate
# Install app dependencies
pip install -r requirements.txt
# Install dev dependencies (linting, testing, pre-commit)
pip install -r requirements-dev.txtcd dashboard
npm install
cd ..pre-commit installThis installs git hooks that automatically run formatters before every commit — so CI never fails due to formatting issues.
All dev tools are listed in requirements-dev.txt. Here's what each one does:
| Tool | Command | Purpose |
|---|---|---|
black |
black src/ api/ tests/ |
Auto-formats Python code |
isort |
isort src/ api/ tests/ |
Sorts Python imports |
flake8 |
flake8 src/ api/ tests/ |
Lints for syntax errors |
pytest |
pytest tests/ |
Runs the test suite |
pre-commit |
runs automatically | Runs formatters before each commit |
If you want to run them manually without committing:
# Fix import order
isort src/ api/ tests/
# Fix code formatting
black src/ api/ tests/
# Check for lint errors (does not auto-fix)
flake8 src/ api/ tests/ --select=E9,F63,F7,F82Once installed via pre-commit install, the hooks run automatically on every git commit. You never need to think about formatting again.
If a hook fixes a file, the commit will be blocked and you'll see which files were changed. Just git add the fixed files and commit again:
git commit -m "your message"
# hook runs, fixes imports → commit blocked
git add src/
git commit -m "your message"
# passes ✅To manually run hooks on all files without committing:
pre-commit run --all-filesTo temporarily skip hooks (use sparingly):
git commit --no-verify -m "your message"# Build and start both services
docker-compose up -d --build
# View logs
docker-compose logs -f
# Stop
docker-compose downServices will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
Backend:
# Activate venv first
uvicorn api.main:app --reload --port 8000Frontend:
cd dashboard
npm run dev- Formatter:
black(line length 88) - Import sorter:
isort(compatible with black) - Linter:
flake8(syntax errors only — formatting is handled by black) - Style: Follow existing patterns in
src/andapi/
- Formatter: Prettier (via
npm run lint) - Framework: Next.js 16 App Router
- Keep components in
dashboard/src/components/ - Keep API calls in
dashboard/src/lib/
- Never commit
.envfiles — use.env.exampleas a template - Never commit model files or large data files — these are mounted as Docker volumes
- Keep
requirements.txtfor runtime dependencies only - Keep
requirements-dev.txtfor developer tools only
# Run all tests
pytest tests/ -v
# Run with coverage report
pytest tests/ --cov=src --cov=api --cov-report=term-missing
# Run a specific test file
pytest tests/test_api.py -v
# Run a specific test
pytest tests/test_api.py::test_health_endpoint -vTests must pass on both Python 3.10 and 3.11 — the CI pipeline tests both automatically.
We use a simple prefix convention so the release changelog is generated automatically:
| Prefix | When to use | Example |
|---|---|---|
feat: |
New feature | feat: add batch comparison endpoint |
fix: |
Bug fix | fix: handle missing model gracefully |
perf: |
Performance improvement | perf: cache SHAP values on startup |
ci: |
CI/CD changes | ci: add Python 3.11 to test matrix |
docker: |
Docker changes | docker: reduce backend image size |
docs: |
Documentation | docs: update API endpoint reference |
test: |
Test changes | test: add integration tests for predict endpoint |
refactor: |
Code cleanup | refactor: extract prediction logic to service layer |
Releases are fully automated — just tag and push:
# Stable release
git tag v1.0.0
git push origin v1.0.0
# Pre-release
git tag v1.0.0-beta.1
git push origin v1.0.0-beta.1This triggers the release workflow which:
- Validates the version format
- Auto-generates a changelog from commits
- Creates a GitHub Release with release notes
- Builds and pushes versioned Docker images to GHCR
See RELEASES.md for full details on the release process.
Open an issue on GitHub or check the existing issues before starting work on a new feature.