Skip to content

RashedAbdullah/time-entry

Repository files navigation

TimeTracker - Smart Time Tracking for Professionals

TimeTracker cover

License Stars Issues Contributors

TimeTracker is a powerful, full-stack time tracking application built with Next.js that helps professionals, freelancers, and teams visualize their work hours, analyze productivity, and generate comprehensive reports. Track time across projects, monitor daily activity, and export data in multiple formats.

✨ Features

Core Functionality

  • ⏱️ Real-time Timer - Start/stop timers with live duration updates (upcoming feature)
  • πŸ“Š Interactive Dashboard - Overview of today's activity, active timers, and quick actions
  • πŸ“… Calendar View - Visual representation of time entries with daily breakdowns
  • πŸ“ˆ Advanced Analytics - Charts and graphs to visualize work patterns
  • πŸ“‘ Multiple Export Formats - Export reports as PDF, Excel, or JSON
  • 🏒 Project Management - Organize time entries by projects (Personal, Office, Client)
  • 🏠 Workspace Tracking - Distinguish between Office and Home work
  • ⚑ Time Adjustments - Add or subtract time with reason tracking

User Experience

  • 🎨 Modern UI - Clean, professional interface with shadcn/ui components
  • πŸŒ“ Dark Mode - Seamless light/dark theme switching (upcoming feature)
  • πŸ“± Responsive Design - Works perfectly on desktop, tablet, and mobile
  • πŸ” Advanced Filtering - Filter reports by date, project, workspace
  • πŸ“Š Visual Analytics - Bar, line, and pie charts for data visualization

Security & Authentication

  • πŸ” NextAuth.js Integration - Secure authentication with multiple providers
  • πŸ‘€ User Isolation - Each user sees only their own data
  • πŸ”’ Protected Routes - Authentication required for all tracking features

πŸ› οΈ Tech Stack

Frontend

Backend

DevOps & Tooling

  • Package Manager: npm
  • Code Quality: ESLint, Prettier
  • Git Hooks: Husky
  • Deployment: Vercel

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • npm

Installation

  1. Clone the repository

    git clone https://github.com/RashedAbdullah/time-entry.git
    cd time-entry
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp .env.example .env

    Fill in your environment variables (see Environment Variables section)

  4. Set up the database

    # Run Prisma migrations
    npx prisma migrate dev --name init
    
    # Generate Prisma client
    npx prisma generate
  5. Run the development server

    npm run dev
  6. Open your browser Navigate to http://localhost:3000

Environment Variables

Create a .env file with the following variables:

# Database
DATABASE_URL="postgresql://username:password@localhost:5432/timetracker"

# NextAuth
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"

πŸ“ Project Structure

timetracker/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ (auth)/             # Authentication routes
β”‚   β”‚   β”‚   β”œβ”€β”€ signin/
β”‚   β”‚   β”‚   └── signup/
β”‚   β”‚   β”œβ”€β”€ (dashboard)/        # Protected dashboard routes
β”‚   β”‚   └── api/                 # API routes
β”‚   β”‚       β”œβ”€β”€ auth/
β”‚   β”‚       β”œβ”€β”€ projects/
β”‚   β”‚       β”œβ”€β”€ reports/
β”‚   β”‚       └── time-entries/
β”‚   β”œβ”€β”€ components/              # React components
β”‚   β”‚   β”œβ”€β”€ auth/
β”‚   β”‚   β”œβ”€β”€ calendar/
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”œβ”€β”€ modals/
β”‚   β”‚   β”œβ”€β”€ projects/
β”‚   β”‚   β”œβ”€β”€ reports/
β”‚   β”‚   β”œβ”€β”€ time-entry/
β”‚   β”‚   └── ui/                  # shadcn/ui components
β”‚   β”œβ”€β”€ hooks/                    # Custom React hooks
β”‚   β”œβ”€β”€ lib/                      # Utilities, configurations
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── validations/
β”‚   └── types/                    # TypeScript type definitions
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma             # Database schema
β”œβ”€β”€ public/                       # Static assets
└── ...config files

πŸ’Ύ Database Schema

// prisma/schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
}

model User {
  id          String           @id @default(uuid())
  name        String
  email       String           @unique
  password    String
  projects    Project[]
  timeEntries TimeEntry[]
  adjustments TimeAdjustment[]
  createdAt   DateTime         @default(now())
  updatedAt   DateTime         @updatedAt

  @@index([email])
}

model Project {
  id          String      @id @default(uuid())
  name        String
  description String?
  type        ProjectType @default(OFFICE)

  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
  userId String

  timeEntries TimeEntry[]

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@index([userId])
}

model TimeEntry {
  id String @id @default(uuid())

  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
  userId String

  project   Project? @relation(fields: [projectId], references: [id], onDelete: SetNull)
  projectId String?

  date DateTime // Entry date (normalized to 00:00:00)

  startDateTime DateTime
  endTime       DateTime?

  workspace   WorkspaceType @default(OFFICE)
  description String?

  adjustments TimeAdjustment[]

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@index([userId, date])
  @@index([projectId])
}

model TimeAdjustment {
  id String @id @default(uuid())

  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)
  userId String

  timeEntry   TimeEntry @relation(fields: [timeEntryId], references: [id], onDelete: Cascade)
  timeEntryId String

  minutes Int // Negative or positive
  reason  String?

  createdAt DateTime @default(now())

  @@index([userId])
  @@index([timeEntryId])
}

enum WorkspaceType {
  OFFICE
  HOME
}

enum ProjectType {
  PERSONAL
  OFFICE
  CLIENT
}

πŸ”Œ API Routes

Authentication

  • POST /api/auth/signup - Register new user
  • GET/POST /api/auth/[...nextauth] - NextAuth authentication

Projects

  • GET /api/projects - Get all projects for user
  • POST /api/projects - Create new project
  • GET /api/projects/[id] - Get project details
  • PATCH /api/projects/[id] - Update project
  • DELETE /api/projects/[id] - Delete project

Time Entries

  • GET /api/time-entries - Get time entries (with filters)
  • POST /api/time-entries - Create time entry
  • GET /api/time-entries/:date - Get today's entries
  • GET /api/time-entries/active - Get active timer
  • POST /api/time-entries/start - Start timer
  • POST /api/time-entries/stop - Stop timer
  • PATCH /api/time-entries/[id] - Update entry
  • DELETE /api/time-entries/[id] - Delete entry
  • POST /api/time-entries/[id]/adjust - Add time adjustment

Reports

  • GET /api/reports - Generate report with filters
  • GET /api/reports/export/pdf - Export as PDF
  • GET /api/reports/export/excel - Export as Excel
  • GET /api/reports/export/json - Export as JSON
  • GET /api/reports/monthly - Get monthly summary

🀝 Contributing

We welcome contributions from the community! Whether it's bug fixes, new features, or documentation improvements, your help is appreciated.

Contribution Guidelines

1. Fork the Repository

git clone https://github.com/RashedAbdullah/time-entry
cd time-entry

2. Create a Branch

git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix

3. Set Up Development Environment

  • Follow the Getting Started guide
  • Ensure all tests pass locally
  • Maintain code quality with ESLint and Prettier

4. Make Your Changes

  • Write clean, readable code
  • Add comments where necessary
  • Update documentation if needed
  • Add tests for new features

5. Commit Guidelines

We follow Conventional Commits:

feat: add new feature
fix: resolve bug
docs: update documentation
style: formatting changes
refactor: code restructuring
test: add tests
chore: maintenance tasks

6. Run Quality Checks

# Lint code
npm run lint

# Format code
npm run format

# Run tests
npm run test

# Type check
npm run type-check

7. Submit a Pull Request

  • Push to your fork
  • Open a PR to the main branch
  • Describe your changes in detail
  • Link any related issues

Development Workflow

  1. Pick an Issue - Look for good first issues
  2. Discuss - Comment on the issue to let others know you're working on it
  3. Code - Follow the guidelines above
  4. Review - Wait for maintainers to review your PR
  5. Merge - Once approved, your PR will be merged

Code Style

  • Use TypeScript for all new code
  • Follow existing patterns in the codebase
  • Use functional components with hooks
  • Write meaningful component and variable names
  • Add JSDoc comments for complex functions
  • Keep components focused and modular

Reporting Issues

Found a bug? Please include:

  • Steps to reproduce
  • Expected behavior
  • Actual behavior
  • Screenshots (if applicable)
  • Environment details (browser, OS)

Feature Requests

Have an idea? Open an issue with:

  • Clear description of the feature
  • Use case and benefits
  • Mockups or examples (if applicable)

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Contact & Support


Made with ❀️ by Rashed Abdullah
rashedabdullah.com