|
| 1 | +# Student & Client Time Tracking API |
| 2 | + |
| 3 | +A Next.js application for tracking student and client hours using Toggl Track integration. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🕒 Hours tracking integration with Toggl Track |
| 8 | +- 📊 Client-specific time tracking with custom tags |
| 9 | +- 💾 SQLite database for client data storage |
| 10 | +- 🔒 Type-safe API endpoints with Zod validation |
| 11 | + |
| 12 | +## Getting Started |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +- Node.js |
| 17 | +- Toggl Track account with API access |
| 18 | + |
| 19 | +### Environment Variables |
| 20 | + |
| 21 | +Create a `.env` file with: |
| 22 | + |
| 23 | +```bash |
| 24 | +TOGGL_API_EMAIL=your-email@example.com |
| 25 | +TOGGL_API_PASSWORD=your-password |
| 26 | +# DATABASE_URL=file:sqlite.db |
| 27 | +``` |
| 28 | + |
| 29 | +### Installation |
| 30 | + |
| 31 | +```bash |
| 32 | +npm install |
| 33 | +``` |
| 34 | + |
| 35 | +### Database Setup |
| 36 | + |
| 37 | +Seed the database with initial data: |
| 38 | + |
| 39 | +```bash |
| 40 | +npm run seed |
| 41 | +``` |
| 42 | + |
| 43 | +### Development |
| 44 | + |
| 45 | +Start the development server: |
| 46 | + |
| 47 | +```bash |
| 48 | +npm run dev |
| 49 | +``` |
| 50 | + |
| 51 | +### Build |
| 52 | + |
| 53 | +Create a production build: |
| 54 | + |
| 55 | +```bash |
| 56 | +npm run build |
| 57 | +``` |
| 58 | + |
| 59 | +## API Endpoints |
| 60 | + |
| 61 | +### GET `/api/client/[clientId]` |
| 62 | + |
| 63 | +Retrieves client tracking data including remaining hours and last tracked entry. |
| 64 | + |
| 65 | +#### Parameters |
| 66 | + |
| 67 | +- `clientId` (UUID): The unique identifier for the client |
| 68 | + |
| 69 | +#### Response |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "clientId": "uuid", |
| 74 | + "hoursRemaining": 40, |
| 75 | + "lastPaidDate": "2024-01-01T00:00:00.000Z", |
| 76 | + "togglLink": "https://track.toggl.com/timer?tags=client-tag", |
| 77 | + "lastEntryTrackedDate": "2024-01-02T10:00:00.000Z" |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +## Testing |
| 82 | + |
| 83 | +Run the test suite: |
| 84 | + |
| 85 | +```bash |
| 86 | +npm test |
| 87 | +``` |
| 88 | + |
| 89 | +## Tech Stack |
| 90 | + |
| 91 | +- [Next.js](https://nextjs.org/) |
| 92 | +- [Drizzle ORM](https://orm.drizzle.team/) |
| 93 | +- [Toggl Track API](https://developers.track.toggl.com/) |
| 94 | +- [Vitest](https://vitest.dev/) |
| 95 | +- [Zod](https://zod.dev/) |
0 commit comments