A web application for tracking motohours and battery capacity with user authentication and PostgreSQL database.
- Automatic Date/Time Display: Real-time clock showing current date and time
- User-Specific Login: Each user has their own password
- Shared Data View: All users can see all entries, but can only manage their own
- Motohours Tracking: Input field for motohours with decimal support
- Battery Capacity: Input field for battery percentage (0-100%)
- Data Table: Displays all entries with date/time, name, motohours, and battery capacity
- Charging Control: Start/stop charging buttons with session tracking
- Charging Sessions Table: Separate table showing all charging sessions with duration
- Data Persistence: All data is stored in PostgreSQL database
- User Authentication: Secure login with JWT tokens
- Responsive Design: Works on desktop and mobile devices
- Logout Functionality: Users can log out and switch accounts
- Docker Support: Easy deployment with Docker Compose
-
Clone the repository:
git clone <repository-url> cd forklit-battery-checker
-
Start the application:
docker-compose up -d
-
Access the application:
- Frontend: http://localhost:5000
- Backend API: http://localhost:3000
-
Install dependencies:
# Backend cd backend npm install # Frontend cd ../frontend npm install
-
Set up PostgreSQL database:
- Install PostgreSQL 15
- Create database and user (see
database/README.md) - Copy
backend/env.exampletobackend/.envand configure
-
Start the services:
# Backend cd backend npm run dev # Frontend (in another terminal) cd frontend npm run dev
- Open the Application: Navigate to http://localhost:5000
- Login:
- Enter your username
- Enter your password
- Click "Login"
- Add Entries:
- Enter motohours (supports decimals)
- Enter battery capacity percentage
- Click "Add Entry"
- Charging Control:
- Click "Start Charging" to begin a charging session
- Click "Stop Any Charging" to end any active session (any user can stop any session)
- Only one charging session can be active at a time across all users
- View Data:
- All entries are displayed in the first table (your entries are highlighted in green)
- All charging sessions are displayed in the second table (your sessions are highlighted in green)
- Manage Data:
- Delete individual entries using the "Delete" button (only for your own entries)
- Delete completed charging sessions using the "Delete" button (only for your own sessions)
- Clear all your entries using the "Clear All Your Entries" button
- Clear all your charging sessions using the "Clear All Your Charging Sessions" button
- Logout: Click "Logout" to switch users or exit the application
forklit-battery-checker/
├── backend/ # Node.js backend API
│ ├── routes/ # API routes
│ ├── middleware/ # Authentication middleware
│ ├── database/ # Database configuration
│ └── server.js # Express server
├── frontend/ # React frontend
│ ├── src/ # Source code
│ └── public/ # Static files
├── database/ # PostgreSQL setup
│ ├── Dockerfile # Database container
│ └── init.sql # Database schema
├── docker-compose.yml # Docker orchestration
└── README.md # This file
Users can be added directly to the PostgreSQL database or through the API. The default users have been removed from the code for security.
Copy backend/env.example to backend/.env and configure:
- Database connection settings
- JWT secret key
- Server port and environment
Modify the frontend CSS files to change colors, fonts, and layout.
- Backend: Node.js with Express.js
- Database: PostgreSQL with connection pooling
- Authentication: JWT-based authentication
- Frontend: React with Vite
- Containerization: Docker and Docker Compose
- Security: Helmet.js, rate limiting, CORS protection
Works in all modern browsers:
- Chrome
- Firefox
- Safari
- Edge
The application uses three main tables:
- users - User accounts with hashed passwords
- entries - Motohours and battery capacity records
- charging_sessions - Battery charging session tracking
See database/README.md for detailed schema information.
- Password Hashing: All passwords are hashed using bcrypt
- JWT Authentication: Secure token-based authentication
- SQL Injection Protection: Parameterized queries
- Rate Limiting: API request rate limiting
- CORS Protection: Cross-origin request protection
- Helmet.js: Security headers
For production deployment:
- Change the JWT secret in environment variables
- Use strong database passwords
- Configure proper CORS origins
- Set up SSL/TLS certificates
- Use environment-specific database configurations