Mobile-base Automated Coin Counter and Segregation for Coin Businesses Management
A modern, responsive web application for automated coin counting and segregation using Streamlit and Python hardware integration.
- π Secure Authentication System - User login and registration
- πͺ Real-time Coin Counting - Live counter with Philippine Peso denominations
- π Interactive Dashboard - Real-time statistics and visualizations
- π§ Hardware Integration - Serial communication with coin counting hardware
- π Comprehensive Reporting - Session statistics and data export
- π± Mobile Responsive - Optimized for mobile and desktop use
Supports all Philippine Peso denominations:
- β±0.01 (1 sentimo)
- β±0.05 (5 sentimo)
- β±0.10 (10 sentimo)
- β±0.25 (25 sentimo)
- β±1.00 (1 piso)
- β±5.00 (5 piso)
- β±10.00 (10 piso)
- β±20.00 (20 piso)
- Python 3.9 or higher
- Poetry (for dependency management)
- Serial port access (for hardware integration)
-
Clone the repository
git clone <repository-url> cd bar-coin
-
Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 - -
Quick setup (recommended)
python setup.py
This will:
- Check Python version
- Install Poetry if needed
- Install all dependencies
- Create
.envfile from template - Test the setup
-
Run the application
python run.py
This will:
- Check Poetry installation
- Install dependencies if needed
- Create
.envfile from template - Initialize the database
- Start the Streamlit application
-
Alternative manual setup
# Install dependencies poetry install # Set up environment variables cp .env.example .env # Edit .env with your configuration # Run the application poetry run streamlit run bar_coin/app.py
The application will be available at http://localhost:8501
bar-coin/
βββ bar_coin/
β βββ app.py # Main Streamlit application
β βββ config/
β β βββ __init__.py
β β βββ settings.py # Configuration settings
β βββ hardware/
β β βββ __init__.py
β β βββ coin_counter.py # Hardware interface
β β βββ mock_hardware.py # Mock for testing
β β βββ serial_handler.py # Serial communication
β βββ components/
β β βββ __init__.py
β β βββ auth.py # Authentication component
β β βββ dashboard.py # Dashboard component
β β βββ statistics.py # Statistics component
β βββ utils/
β β βββ __init__.py
β β βββ database.py # SQLite for data storage
β β βββ helpers.py # Utility functions
β βββ static/
β βββ logo.png # BAR-COIN logo
βββ data/
β βββ coins.db # SQLite database
βββ tests/ # Test suite
βββ pyproject.toml # Poetry configuration
βββ README.md # This file
Create a .env file in the project root:
# Database
DATABASE_URL=sqlite:///data/coins.db
# Hardware Configuration
SERIAL_PORT=COM3
BAUD_RATE=9600
# Application Settings
DEBUG=True
SECRET_KEY=your-secret-key-here
# Mock Mode (for testing without hardware)
MOCK_HARDWARE=True-
Serial Connection
- Connect coin counting hardware via USB
- Configure port and baud rate in settings
- Test connection using the hardware status panel
-
Mock Mode
- Enable mock mode for testing without hardware
- Simulates coin insertion for development
- Register a new account or login with existing credentials
- Secure password hashing with bcrypt
- Session-based authentication
-
Real-time Counter
- Live display of total coins processed
- Breakdown by denomination
- Total value in Philippine Pesos
-
Control Panel
- Start/Stop/Pause hardware operations
- Reset counter
- Emergency stop functionality
-
Statistics
- Session summaries
- Historical data visualization
- Export capabilities
- Serial Communication: JSON-based protocol
- Real-time Updates: 100ms refresh rate
- Error Handling: Graceful disconnection handling
- Auto-reconnection: Automatic retry on connection loss
# Run all tests (recommended)
python run_tests.py
# Alternative: Run with Poetry
poetry run pytest
# Run with coverage
poetry run pytest --cov=bar_coin
# Run specific test file
poetry run pytest tests/test_hardware.py# Format code
poetry run black bar_coin/
# Lint code
poetry run flake8 bar_coin/
# Type checking
poetry run mypy bar_coin/- Follow the existing project structure
- Add tests for new functionality
- Update documentation
- Ensure mobile responsiveness
{
"type": "coin_detected",
"denomination": 5.00,
"timestamp": "2024-01-01T12:00:00",
"sensor_id": 1
}-- Users table
CREATE TABLE users (
id INTEGER PRIMARY KEY,
username TEXT UNIQUE,
password_hash TEXT,
created_at TIMESTAMP
);
-- Counting sessions
CREATE TABLE sessions (
id INTEGER PRIMARY KEY,
user_id INTEGER,
start_time TIMESTAMP,
end_time TIMESTAMP,
total_value DECIMAL,
total_coins INTEGER
);
-- Coin counts
CREATE TABLE coin_counts (
id INTEGER PRIMARY KEY,
session_id INTEGER,
denomination DECIMAL,
count INTEGER,
timestamp TIMESTAMP
);- Set
DEBUG=Falsein environment - Configure production database
- Set up reverse proxy (nginx)
- Enable SSL/TLS
- Configure logging
# Install dependencies
poetry install --no-dev
# Set production environment
export DEBUG=False
export SECRET_KEY=your-production-secret-key
# Run the application
poetry run streamlit run bar_coin/app.py --server.port 8501 --server.address 0.0.0.0- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Check the documentation
- Review the troubleshooting guide
- Initial release
- Basic coin counting functionality
- Authentication system
- Real-time dashboard
- Hardware integration
- Mock mode for testing