Time Tracker App
A React-based time tracking application with user authentication and session management.
Features
- User authentication system with Supabase Auth
- Start/stop time tracking functionality
- Pause/resume functionality for breaks
- Session history management
- Edit current and past sessions
- Create new sessions with simplified time input
- Integration with Supabase for data persistence
- Responsive design for desktop and mobile
Pages
- Login/Register Page - Secure authentication entry point
- Dashboard - Main page with timer controls
- Session History - View, edit, and create sessions
Setup Instructions
- Clone the repository (if applicable)
- Install dependencies:
npm install - Set up environment variables:
- Copy
.env.exampleto.env - Update the values in
.envwith your Supabase credentials:
REACT_APP_SUPABASE_URL=your_supabase_project_url_here REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_key_here - Copy
- Start the development server:
npm start
Database Setup
Supabase Tables
Create these tables in your Supabase project:
Users Table
-- Users table (handled by Supabase Auth)
-- Supabase automatically creates auth.users table
Timers Table
-- Create timers table
create table if not exists timers (
id uuid primary key default gen_random_uuid(),
user_id uuid references auth.users(id) not null,
start_time timestamptz not null,
end_time timestamptz,
duration_ms integer,
pauses json,
created_at timestamptz default now()
);
-- Enable RLS (Row Level Security)
alter table timers enable row level security;
-- Create policy to allow users to access their own timers only
create policy "Users can access their own timers" on timers
for all using (auth.uid() = user_id);
-- Grant permissions
grant usage on schema public to anon, authenticated;
grant all on table timers to anon, authenticated;
Automatic Session Closure (Optional)
To automatically close active sessions at midnight every day (without deleting history):
- Make sure the
pg_cronextension is enabled in your Supabase project (it's usually enabled by default) - Run the SQL script in
supabase/close_sessions_cron.sqlin your Supabase SQL Editor - The cron job will automatically run daily at 00:00 to close any active sessions
The function identifies sessions that are currently active (where end_time is NULL) and sets their end_time to midnight, calculating the duration accordingly. This preserves all session history while ensuring no session remains indefinitely open.
Session Management Features
Creating New Sessions
- Click "Create New Session" in Session History
- Select date and enter start/end times (HH:MM format)
- Add pauses with start/end times as needed
- Save to store in Supabase database
Editing Sessions
- Edit current active session
- Edit past sessions from history
- Modify start/end times and pause periods
- Changes automatically saved to database
Timer Controls
- Start/Stop schedule tracking
- Take breaks with Pause/Resume functionality
- Real-time work time calculation (excluding pause time)
Security
- Environment variables are stored in
.env(excluded from git) - Sensitive data never stored in browser localStorage or sessionStorage
- All session data persists only in user session and external database
- Review
.gitignoreto ensure sensitive files are not committed - Supabase Auth handles user authentication securely
Implementation Details
- Built with React and React Router for navigation
- Uses Context API for state management
- Implements a clean, responsive UI with CSS
- Session data persists in user session and Supabase database
- Integrates with Supabase API for data persistence and authentication
File Structure
src/
├── components/ # Reusable UI components
├── context/ # Authentication and state context
├── pages/ # Page components (Login, Dashboard, Sessions)
├── services/ # API integration services
└── App.js # Main app component with routing
Database Integration
The app includes a service layer for Supabase integration:
- Sessions are saved to the database when stopped
- Session history is loaded from the database on login
- All database operations are handled through the sessionService
- User authentication is managed by Supabase Auth
To connect to your own Supabase project:
- Create a Supabase account at https://supabase.io
- Create a new project
- Get your project URL and anon key from project settings
- Create the required tables using the SQL provided above
- Update the environment variables with your credentials
Original Create React App Documentation
This project was bootstrapped with Create React App.
Available Scripts
In the project directory, you can run:
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.
You may also see any lint errors in the console.
npm test
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
npm run build
Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
npm run eject
Note: this is a one-way operation. Once you eject, you can't go back!
If you aren't satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
Learn More
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.
Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
npm run build fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify