An open API service indexing awesome lists of open source software.

https://github.com/waregagbagbo/cs-employee-activity-tracker

To build a system where customer support agents can log end-of-shift reports and also provide managers with visibility into team activities.
https://github.com/waregagbagbo/cs-employee-activity-tracker

drf-jwt markdown mysql-database orm-framework postgresql-database python rest-api webhooks-api

Last synced: about 1 month ago
JSON representation

To build a system where customer support agents can log end-of-shift reports and also provide managers with visibility into team activities.

Awesome Lists containing this project

README

          

## Employee Activity Tracker for Customer Support

A Django-based system for customer support teams to log end-of-shift reports and provide managers/supervisors with real-time visibility into team activities and performance.

## Project Structure
- `accounts/` – Custom user model and auth logic
- `shifts/` – Shift tracking and webhook triggers
- `reports/` – End-of-shift reporting and approval flow

## 🚀 Quickstart

1. Clone the repo:

```bash
git clone https://github.com/your-org/employee-activity-tracker.git
cd employee-activity-tracker

2. Create a virtual environment and install dependencies:

``` bash
Linux
python -m venv env
source env/bin/activate

Windows
python -m venv env
venv\Scripts\activate

3. Install dependencies

``` bash
pip install -r requirements.txt

4. Set up .env and run migrations:

``` bash
python manage.py makemigrations - schema version control
python manage.py migrate - Applies changes

5. Run the server:

``` bash
python manage.py runserver

## API Endpoints

### Authentication
- POST /login/ - User login
- POST /auth/register - User register
- POST /auth/logout/ - User logout
- POST /api/auth/refresh/ - Refresh JWT token. Also updates session-based auth tokens for compatibility with the accounts app.

### Employee Management (Viewsets)/Generic

Uses a custom AbstractUser model with email as the primary identifier.
Signals ensure automatic profile creation and token regeneration on user creation.

- GET /api/employees/ - List employees (paginated)
- GET /api/employees/{id}/ - Get employee details
- PUT /api/employees/{id}/ - Update employee profile
- GET /api/employees/me/ - Fetches the logged user profile

### Attendance Management (Viewsets)

- GET /api/attendance/ - List attendance of a user (lists)
- POST /api/attendance/clock_in - new attendance triggered
- POST /api/attendance/clok_out/ - time out for the user
- GET /api/attendance/status/ - Authenticated user gets status
- GET /api/attendance/today - Captures the day's attendance

### Shift Management (Viewsets)

- GET /api/shifts/ - List shifts (with filters)
- POST /api/shifts/ - Create new shift
- GET /api/shifts/{id}/ - Get shift details
- PUT/PATCH /shifts/{id}/ - Update shift
- DELETE /shifts/{id}/ - Delete shift
- GET /shifts/today/ - Today's shifts
- GET /shifts/upcoming/ - Next 7 days shifts
- PATCH /shifts/{id}/cancel/ - Cancel shift

### Activity Reports (Viewsets)

- GET /api/reports/ - List reports (with filters)
- POST /api/reports/ - Submit new report
- GET /api/reports/{id}/ - Get report details
- PUT /api/reports/{id}/ - Update report (if not approved)
- PATCH /api/reports/{id}/approve/ - Approve report (supervisors/managers only)
- GET /api/reports/export/ - Export reports (CSV)(Future) ONCE VALIDATED with Frontend library

### Webhook Management

Webhooks are triggered on shift status changes (start/end). Implemented using Django signals and dispatched to registered endpoints test(https://webhook.site/).

Future support for multichannel registry.

## Technical Considerations

### Security
- TokenAuth supported
- Role-based access control (supervisors, agents,admins)
- Input validation and permission checks
- CORS configured for deployment

### Performance
- Database indexing on frequently queried fields (MySQL)
- Pagination via DRF’s `PageNumberPagination` setting

### Architecture
- Modular design using ViewSets, signals, and custom user models.
- Webhook dispatch system for real-time notifications on shifts and reports. Testing ground (https://webhook.site/#!/view/a66fc247-bafa-41ce-93af-a408e52ea2b3)

## Development Environment Setup

### Required Tools
1. Python 3.9+
2. Django 4.2+
3. Django REST Framework
5. MySQL 8.0+
6. Git
7. Code editor (PyCharm)
8. Postman for endpoint tests
9. React - For Frontend Scaffolding

## SAMPLE Results.

#### DRF Login (use case for SessionAuth) http://127.0.0.1:8000/accounts/api/login/

image

#### Authentication and permissions required for the view functionality (http://127.0.0.1:8000/cs/shifts/)

image

#### Token Auth in operation

image