A Go backend service for the Zebra time tracking application, supporting user accounts and multi-device synchronization.
- User authentication with JWT
- Timer session management
- Project management
- Multi-device synchronization
- PostgreSQL database for persistent storage
- Go 1.21 or later
- PostgreSQL 12 or later
- Docker (optional, for containerized development)
-
Clone the repository:
git clone https://github.com/zigaowang/zebra-backend.git cd zebra-backend
-
Install dependencies:
go mod download
-
Create the database:
createdb zebra
-
Set up the environment:
cp .env.example .env # Edit .env with your configuration
-
Initialize the database schema:
psql -d zebra -f internal/db/schema.sql
-
Run the server:
go run cmd/api/main.go
POST /api/register
- Register a new userPOST /api/login
- Login and get JWT token
POST /api/sessions
- Create a new timer sessionGET /api/sessions
- List user's timer sessionsPUT /api/sessions/{id}
- Update a timer sessionDELETE /api/sessions/{id}
- Delete a timer session
POST /api/projects
- Create a new projectGET /api/projects
- List user's projectsPUT /api/projects/{id}
- Update a projectDELETE /api/projects/{id}
- Delete a project
POST /api/sync
- Sync data between devicesGET /api/sync/status
- Get sync status
The schema is currently managed through a single SQL file. For production, consider using a migration tool like golang-migrate
.
Run the tests:
go test ./...
A Dockerfile and docker-compose configuration will be added soon for containerized deployment.
MIT