Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d46a60b
Add requirements.txt with initial package dependencies
pmca31 Feb 11, 2026
8ecbf5e
Initialize Django project structure and create models, serializers, v…
pmca31 Feb 11, 2026
eeca2b5
Enhance Django settings for GitHub Codespaces support and add setup v…
pmca31 Feb 11, 2026
7c9643a
Add API root endpoint for GitHub Codespaces with dynamic URL generation
pmca31 Feb 11, 2026
eaa741b
feat: Initialize OctoFit Tracker frontend with routing and components
pmca31 Feb 11, 2026
7671696
fix: Update API URL construction in Users component for consistency
pmca31 Feb 11, 2026
8c56273
Initial plan
Copilot Feb 11, 2026
18d283d
Initial plan
Copilot Feb 11, 2026
511570d
Initial plan
Copilot Feb 11, 2026
382ca52
fix: Add Codespaces support to test-teams-api.sh
Copilot Feb 11, 2026
57c555a
Update octofit-tracker/backend/octofit_tracker/settings.py
pmca31 Feb 11, 2026
45a45fe
fix: Update App.test.js to match current OctoFit Tracker UI
Copilot Feb 11, 2026
a5dbe50
Initial plan
Copilot Feb 11, 2026
b2de384
Initial plan
Copilot Feb 11, 2026
b0b333a
refactor: Improve navbar test specificity using getByRole
Copilot Feb 11, 2026
b05622e
Initial plan
Copilot Feb 11, 2026
11566ac
fix: Consolidate API root to /api/ path only, remove redundant custom…
Copilot Feb 11, 2026
13ea265
Initial plan
Copilot Feb 11, 2026
ad20166
Initial plan
Copilot Feb 11, 2026
8bf6fbc
Initial plan
Copilot Feb 11, 2026
147c234
Initial plan
Copilot Feb 11, 2026
997eed7
Initial plan
Copilot Feb 11, 2026
4332fd6
Update octofit-tracker/backend/octofit_tracker/settings.py
pmca31 Feb 11, 2026
8c5d280
refactor: Use SimpleRouter with custom api_root at /api/ path
Copilot Feb 11, 2026
ccb29f0
feat: Add centralized API configuration with localhost fallback
Copilot Feb 11, 2026
98ea23f
feat: Add centralized API configuration with localhost fallback
Copilot Feb 11, 2026
2bc2c81
docs: Add clarifying comments to URL pattern ordering
Copilot Feb 11, 2026
fc3ee78
docs: Update .env.example and add API config README
Copilot Feb 11, 2026
90e4d90
Merge pull request #6 from pmca31/copilot/sub-pr-2-yet-again
pmca31 Feb 11, 2026
bb79453
fix: Use relative path in verify_setup.sh instead of hard-coded absol…
Copilot Feb 11, 2026
162dc58
refactor: Remove console.log from production API config
Copilot Feb 11, 2026
3958c3e
fix: Use python3 instead of python in shell scripts for consistency
Copilot Feb 11, 2026
7cd82e9
fix: Add directory navigation to copy-logo.sh for path independence
Copilot Feb 11, 2026
3c037ae
feat: Implement configurable API base URL with localhost fallback
Copilot Feb 11, 2026
08a5ea6
feat: Add centralized API configuration with localhost fallback
Copilot Feb 11, 2026
2fc6903
docs: Add API configuration documentation
Copilot Feb 11, 2026
14fb188
docs: Update FRONTEND_README.md with new API configuration
Copilot Feb 11, 2026
7cfd796
feat: Add centralized API configuration with localhost fallback
Copilot Feb 11, 2026
3323e53
fix: Comment out REACT_APP_CODESPACE_NAME in .env to avoid confusion
Copilot Feb 11, 2026
6458d88
docs: Add clarifying comment about API_BASE_URL module load behavior
Copilot Feb 11, 2026
e4acb31
Merge branch 'build-octofit-app' into copilot/sub-pr-2-044f0a73-1df6-…
pmca31 Feb 11, 2026
aea3ff1
Merge pull request #13 from pmca31/copilot/sub-pr-2-044f0a73-1df6-4ef…
pmca31 Feb 11, 2026
934bc06
Merge branch 'build-octofit-app' into copilot/sub-pr-2-741bb43a-a0ac-…
pmca31 Feb 11, 2026
9e5fedb
Merge pull request #12 from pmca31/copilot/sub-pr-2-741bb43a-a0ac-4d3…
pmca31 Feb 11, 2026
7caf193
Merge pull request #3 from pmca31/copilot/sub-pr-2
pmca31 Feb 11, 2026
ead17e1
Merge pull request #4 from pmca31/copilot/sub-pr-2-again
pmca31 Feb 11, 2026
d8bc74f
Merge pull request #5 from pmca31/copilot/sub-pr-2-another-one
pmca31 Feb 11, 2026
e319987
Merge pull request #8 from pmca31/copilot/sub-pr-2-please-work
pmca31 Feb 11, 2026
dbea9cd
Merge pull request #10 from pmca31/copilot/sub-pr-2-c0f5406f-183c-43a…
pmca31 Feb 11, 2026
32cfffa
Merge pull request #9 from pmca31/copilot/sub-pr-2-5726c6bb-22bd-4260…
pmca31 Feb 11, 2026
6422ffc
Merge branch 'build-octofit-app' into copilot/sub-pr-2-246b387c-31c0-…
pmca31 Feb 11, 2026
8c4fbb8
Merge pull request #11 from pmca31/copilot/sub-pr-2-246b387c-31c0-47a…
pmca31 Feb 11, 2026
7028531
Merge branch 'build-octofit-app' into copilot/sub-pr-2-one-more-time
pmca31 Feb 11, 2026
6cb79f8
Merge pull request #7 from pmca31/copilot/sub-pr-2-one-more-time
pmca31 Feb 11, 2026
9c679d5
style: Update CORS settings and enhance table header styling with Boo…
pmca31 Feb 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/prompts/update-octofit-tracker-app.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
description: Update Django project files for octofit-tracker app
---

# Django App Updates

- All Django project files are in the `octofit-tracker/backend/octofit_tracker` directory.

1. Update `settings.py` for MongoDB connection and CORS. And make sure `octofit_tracker`, `rest_framework`, and `djongo` are in `INSTALLED_APPS`.
2. Update `models.py`, `serializers.py`, `urls.py`, `views.py`, `tests.py`, and `admin.py` to support users, teams, activities, leaderboard, and workouts collections.
3. Ensure `/` points to the api and `api_root` is present in `urls.py`.
179 changes: 179 additions & 0 deletions CODESPACE_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
# OctoFit Tracker - Codespace Setup & Testing Guide

## Configuration Summary
Comment on lines +1 to +3

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title mentions "registration validation", but this PR doesn't appear to introduce any registration/auth endpoints or validation logic (it focuses on models/viewsets and setup docs). Consider updating the PR title/description to match the actual scope, or adding the missing registration validation work if it was intended.

Copilot uses AI. Check for mistakes.

The following files have been configured to work with GitHub Codespaces:

### 1. Django Settings ([octofit-tracker/backend/octofit_tracker/settings.py](octofit-tracker/backend/octofit_tracker/settings.py))

- **ALLOWED_HOSTS**: Dynamically configured to include:
- `localhost`
- `127.0.0.1`
- `${CODESPACE_NAME}-8000.app.github.dev` (when running in Codespaces)

- **Proxy Headers**: Configured for GitHub Codespaces HTTPS proxy
- `USE_X_FORWARDED_HOST = True`
- `SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')`

### 2. VS Code Launch Configuration ([.vscode/launch.json](.vscode/launch.json))

Pre-configured with:
- **Launch Django Backend**: Runs Django on `0.0.0.0:8000`
- **Launch React Frontend**: Runs React on port `3000`

### 3. Port Forwarding ([.devcontainer/devcontainer.json](.devcontainer/devcontainer.json))

- Port 8000: Django API (public)
- Port 3000: React frontend (public)
- Port 27017: MongoDB (private)

## Starting the Server

### Option 1: Using VS Code Debugger (Recommended)

1. Open the **Run and Debug** panel (Ctrl+Shift+D or Cmd+Shift+D)
2. Select "Launch Django Backend" from the dropdown
3. Click the green play button or press F5

The server will start with debugging enabled.

### Option 2: Using Terminal

```bash
# Activate virtual environment
source octofit-tracker/backend/venv/bin/activate

# Start Django server
cd octofit-tracker/backend
python manage.py runserver 0.0.0.0:8000
```

## API Endpoints

The REST API is available at:

**In GitHub Codespaces:**
```
https://${CODESPACE_NAME}-8000.app.github.dev/api/
```

**Locally:**
```
http://localhost:8000/api/
```

### Available Endpoints

- `/api/users/` - User management
- `/api/teams/` - Team management
- `/api/activities/` - Activity tracking
- `/api/leaderboard/` - Leaderboard entries
- `/api/workouts/` - Workout suggestions

## Testing the API

### Manual Testing with curl

#### Test API Root
```bash
# In Codespaces
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/

# Locally
curl http://localhost:8000/api/
```

#### Test Specific Endpoints
```bash
# Users endpoint
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/users/

# Activities endpoint
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/activities/

# Teams endpoint
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/teams/

# Leaderboard endpoint
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/leaderboard/

# Workouts endpoint
curl https://${CODESPACE_NAME}-8000.app.github.dev/api/workouts/
```

### Automated Testing Script

Run the automated test script:

```bash
chmod +x test_api.sh
./test_api.sh
```

This script will:
1. Detect if running in Codespaces or locally
2. Test all API endpoints
3. Display HTTP status codes
4. Show sample response data

## Verifying Configuration

### Check ALLOWED_HOSTS

```bash
# Display current ALLOWED_HOSTS configuration
cd octofit-tracker/backend
source venv/bin/activate
python -c "import os; os.environ['CODESPACE_NAME'] = os.getenv('CODESPACE_NAME', 'test'); from octofit_tracker import settings; print('ALLOWED_HOSTS:', settings.ALLOWED_HOSTS)"
```

### Check MongoDB Connection

```bash
# Verify MongoDB is running
ps aux | grep mongod | grep -v grep

# Test MongoDB connection
mongosh --eval "db.adminCommand('ping')"
```

## Troubleshooting

### Server Not Starting

1. Check if MongoDB is running: `ps aux | grep mongod`
2. Check if port 8000 is already in use: `lsof -i :8000`
3. Check Python virtual environment: `which python` (should show venv path)

### CORS Errors

The Django backend is configured with `CORS_ALLOW_ALL_ORIGINS = True` for development.

### Connection Refused

1. Verify the server is running on `0.0.0.0:8000` not `127.0.0.1:8000`
2. Check port forwarding in VS Code (Ports tab in terminal panel)
3. Ensure CODESPACE_NAME environment variable is set: `echo $CODESPACE_NAME`

### 400 Bad Request or Invalid Host Header

This means ALLOWED_HOSTS is not configured correctly. Verify:
```bash
echo $CODESPACE_NAME
# Should output your codespace name
```

The settings should automatically add `${CODESPACE_NAME}-8000.app.github.dev` to ALLOWED_HOSTS.

## Next Steps

1. ✅ Start the Django backend
2. ✅ Test API endpoints with curl
3. Configure and start the React frontend
4. Test end-to-end functionality

## Additional Resources

- [Django Settings Documentation](https://docs.djangoproject.com/en/4.1/ref/settings/)
- [Django REST Framework](https://www.django-rest-framework.org/)
- [GitHub Codespaces Port Forwarding](https://docs.github.com/en/codespaces/developing-in-codespaces/forwarding-ports-in-your-codespace)
Binary file added octofit-tracker/backend/db.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions octofit-tracker/backend/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file.
41 changes: 41 additions & 0 deletions octofit-tracker/backend/octofit_tracker/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from django.contrib import admin
from .models import User, Team, Activity, Leaderboard, Workout


@admin.register(User)
class UserAdmin(admin.ModelAdmin):
list_display = ['name', 'email', 'team', 'created_at']
list_filter = ['team', 'created_at']
search_fields = ['name', 'email']
ordering = ['-created_at']


@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
list_display = ['name', 'description', 'created_at']
search_fields = ['name', 'description']
ordering = ['-created_at']


@admin.register(Activity)
class ActivityAdmin(admin.ModelAdmin):
list_display = ['user_email', 'activity_type', 'duration', 'calories_burned', 'date']
list_filter = ['activity_type', 'date']
search_fields = ['user_email', 'activity_type']
ordering = ['-date']


@admin.register(Leaderboard)
class LeaderboardAdmin(admin.ModelAdmin):
list_display = ['rank', 'user_name', 'team', 'total_points', 'updated_at']
list_filter = ['team']
search_fields = ['user_name', 'user_email']
ordering = ['rank']


@admin.register(Workout)
class WorkoutAdmin(admin.ModelAdmin):
list_display = ['title', 'difficulty_level', 'duration', 'category']
list_filter = ['difficulty_level', 'category']
search_fields = ['title', 'description', 'category']
ordering = ['title']
16 changes: 16 additions & 0 deletions octofit-tracker/backend/octofit_tracker/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for octofit_tracker project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings')

application = get_asgi_application()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Management commands package
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Management commands
Loading