Skip to content

PRAZPC/teamhub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TeamHub - Collaborative Project Management Platform

TeamHub

A modern, full-stack project management application built with Django and Reflex

Python Django Reflex


📋 Table of Contents


🌟 Overview

TeamHub is a comprehensive project management platform designed to streamline team collaboration, project organization, and task tracking. Built with modern technologies, it combines the power of Django's robust backend with Reflex's reactive frontend to deliver a seamless user experience.

Key Highlights

  • 🔐 Secure Authentication: Google OAuth 2.0 integration with JWT token-based authentication
  • 👥 Team Management: Create and manage teams with role-based permissions
  • 📊 Project Organization: Organize work into projects with automatic team member synchronization
  • ✅ Task Tracking: Create, assign, and track tasks with status workflows (Todo → Doing → Done)
  • 🎨 Beautiful UI: Modern, gradient-based interface with responsive design
  • ⚡ Real-time Updates: Instant synchronization across teams, projects, and tasks
  • 🔗 Project Joining: Unique join codes for easy project access

✨ Features

Core Features

1. Team Management

  • ✅ Create teams (staff-only privilege)
  • ✅ Add/remove team members
  • ✅ Automatic team synchronization to projects
  • ✅ Owner and member role distinction
  • ✅ Real-time member count display

2. Project Management

  • ✅ Create projects linked to teams
  • ✅ Automatic team member assignment to projects
  • ✅ Unique join codes for external collaboration
  • ✅ Project member listing and management
  • ✅ Team-based project filtering

3. Task Management

  • ✅ Create tasks within projects
  • ✅ Assign tasks to project members
  • ✅ Three-stage status workflow: Todo, Doing, Done
  • ✅ Task filtering by project
  • ✅ Color-coded status badges
  • ✅ Task detail modal with status updates

4. Authentication & Security

  • ✅ Google OAuth 2.0 integration
  • ✅ JWT (JSON Web Token) authentication
  • ✅ Session-based token storage
  • ✅ CORS-enabled API
  • ✅ Permission-based access control
  • ✅ Staff-only administrative features

5. User Interface

  • ✅ Responsive design for all devices
  • ✅ Modal-based forms for creation workflows
  • ✅ Tab-based navigation (Tasks, Projects, Teams)
  • ✅ Beautiful gradient themes
  • ✅ Loading states and error handling
  • ✅ Jazzmin-powered Django admin interface

🛠 Tech Stack

Backend

Technology Version Purpose
Django 5.2.10 Web framework and ORM
Django REST Framework 3.16.1 RESTful API development
djangorestframework-simplejwt 5.5.1 JWT authentication
django-allauth 65.13.1 Social authentication
django-cors-headers 4.6.0 CORS support
django-jazzmin 3.0.1 Modern admin UI
google-auth 2.37.0 Google OAuth integration
SQLite 3.x Database (development)

Frontend

Technology Version Purpose
Reflex 0.8.26 Python-based web framework
Tailwind CSS V4 Plugin Styling
Python 3.10+ Programming language

Development Tools

  • PowerShell - Server startup automation
  • Requests - HTTP library for API calls
  • python-dotenv - Environment variable management

🏗 Architecture

TeamHub follows a modern full-stack architecture with clear separation of concerns:

┌─────────────────────────────────────────────────────────────┐
│                        Frontend Layer                        │
│                     (Reflex - Port 3000)                     │
│  ┌────────────┬─────────────┬─────────────┬──────────────┐ │
│  │ Login Page │ Tasks View  │ Projects    │ Teams View   │ │
│  │            │             │ View        │              │ │
│  └────────────┴─────────────┴─────────────┴──────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
                      │ HTTP/HTTPS + JWT
                      │ (CORS Enabled)
┌─────────────────────▼───────────────────────────────────────┐
│                      API Layer (REST)                        │
│                   (Django - Port 8000)                       │
│  ┌────────────────────────────────────────────────────────┐ │
│  │  /api/auth/google/  │ /api/tasks/  │ /api/projects/  │ │
│  │  /api/teams/        │ /api/users/  │ /api/token/     │ │
│  └────────────────────────────────────────────────────────┘ │
└─────────────────────┬───────────────────────────────────────┘
                      │ Django ORM
┌─────────────────────▼───────────────────────────────────────┐
│                      Data Layer                              │
│                    (SQLite Database)                         │
│  ┌──────────┬──────────┬──────────┬──────────┬──────────┐  │
│  │   User   │  Profile │   Team   │ Project  │   Task   │  │
│  └──────────┴──────────┴──────────┴──────────┴──────────┘  │
└─────────────────────────────────────────────────────────────┘

Component Interactions

  1. Frontend (Reflex): Handles UI rendering, user interactions, and state management
  2. API Layer (Django REST Framework): Exposes RESTful endpoints with JWT authentication
  3. Business Logic: Django models with signals for automatic synchronization
  4. Database: SQLite for development (PostgreSQL recommended for production)

🚀 Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.10 or higher (Download)
  • pip (Python package installer)
  • Virtual environment (recommended)
  • Git (for version control)
  • PowerShell (Windows) or Bash (Linux/Mac)

System Requirements

  • OS: Windows 10+, macOS 10.14+, or Linux
  • RAM: 4GB minimum, 8GB recommended
  • Disk Space: 500MB for dependencies

📥 Installation

Step 1: Clone the Repository

git clone https://github.com/yourusername/teamhub.git
cd teamhub

Step 2: Create Virtual Environment

Windows:

python -m venv venv
.\venv\Scripts\Activate.ps1

Linux/Mac:

python3 -m venv venv
source venv/bin/activate

Step 3: Install Dependencies

Install root-level dependencies (Reflex):

pip install -r requirements.txt

Install backend dependencies:

cd backend
pip install -r requirements.txt
cd ..

Step 4: Set Up Environment Variables

Create a .env file in the backend/ directory:

# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=True

# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Generate a Django secret key:

python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

Step 5: Database Setup

cd backend
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser  # Create admin account
cd ..

Step 6: Configure Google OAuth (Optional)

Follow the guide in GOOGLE_LOGIN_SETUP.md to set up Google OAuth authentication.


⚙️ Configuration

Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable Google+ API
  4. Create OAuth 2.0 credentials
  5. Add authorized origins:
    • http://localhost:3000
    • http://127.0.0.1:3000
  6. Add authorized redirect URIs:
    • http://localhost:3000
    • http://127.0.0.1:3000
  7. Copy Client ID and Secret to .env

CORS Configuration

CORS is pre-configured in backend/teamhub/settings.py:

CORS_ALLOWED_ORIGINS = [
    "http://localhost:3000",
    "http://127.0.0.1:3000",
]
CORS_ALLOW_CREDENTIALS = True

💻 Usage

Starting the Application

Option 1: Automated Startup (Recommended)

Windows:

.\start_servers.ps1

This script automatically starts both Django and Reflex servers.

Option 2: Manual Startup

Terminal 1 - Django Backend:

cd backend
python manage.py runserver 8000

Terminal 2 - Reflex Frontend:

python -m reflex run
or
reflex run

Access Points

Service URL Description
Frontend http://localhost:3000 Main application UI
Backend API http://localhost:8000/api/ RESTful API endpoints
Django Admin http://localhost:8000/admin/ Admin dashboard

Default Workflow

  1. Login with Google OAuth or create a user account
  2. Create a Team (staff users only)
  3. Create a Project and select a team
  4. Create Tasks within projects
  5. Assign and Track tasks through completion

📚 API Documentation

Authentication

All API endpoints (except login) require JWT authentication via the Authorization header:

Authorization: Bearer <your-jwt-token>

Endpoints Overview

Authentication

POST /api/token/
POST /api/token/refresh
POST /api/auth/google/login/
GET  /api/auth/google/callback/custom/

Users

GET /api/users/

Teams

GET  /api/teams/
POST /api/teams/create/

Projects

GET  /api/projects/
POST /api/projects/create/
POST /api/projects/join/

Tasks

GET   /api/tasks/
POST  /api/tasks/
PATCH /api/tasks/<task_id>/

Detailed API Reference

For complete API documentation with request/response examples, see API_DOCUMENTATION.md.


📁 Project Structure

teamhub/
├── assets/                      # Static assets
│   └── favicon.ico
├── backend/                     # Django backend
│   ├── accounts/                # User accounts & profiles
│   │   ├── migrations/
│   │   ├── models.py           # Profile, Email_verification
│   │   ├── views.py
│   │   └── urls.py
│   ├── api/                     # REST API
│   │   ├── serializers.py      # DRF serializers
│   │   ├── views.py            # API views
│   │   ├── google_oauth_views.py
│   │   └── urls.py
│   ├── core/                    # Core functionality
│   │   ├── permission.py
│   │   └── views.py
│   ├── projects/                # Project management
│   │   ├── models.py           # Project model with signals
│   │   ├── views.py
│   │   └── forms.py
│   ├── task/                    # Task management
│   │   ├── models.py           # Task model
│   │   ├── views.py
│   │   └── forms.py
│   ├── teams/                   # Team management
│   │   ├── models.py           # Team model with signals
│   │   ├── views.py
│   │   └── forms.py
│   ├── teamhub/                 # Django settings
│   │   ├── settings.py         # Main configuration
│   │   ├── urls.py             # URL routing
│   │   └── wsgi.py
│   ├── templates/               # Django templates
│   ├── manage.py
│   └── requirements.txt
├── teamhub/                     # Reflex frontend
│   ├── __init__.py
│   └── teamhub.py              # Main Reflex app (1200+ lines)
├── .gitignore
├── rxconfig.py                  # Reflex configuration
├── requirements.txt             # Root dependencies
├── start_servers.ps1           # Server startup script
├── GOOGLE_LOGIN_SETUP.md       # OAuth setup guide
├── TESTING_GUIDE.md            # Testing instructions
└── README.md                    # This file

🔐 Authentication

JWT Authentication Flow

┌─────────┐                                    ┌─────────┐
│ Client  │                                    │  Server │
└────┬────┘                                    └────┬────┘
     │                                              │
     │  1. POST /api/token/                         │
     │     {username, password}                     │
     │─────────────────────────────────────────────>│
     │                                              │
     │  2. {access_token, refresh_token}            │
     │<─────────────────────────────────────────────│
     │                                              │
     │  3. Store tokens in sessionStorage           │
     │                                              │
     │  4. GET /api/tasks/                          │
     │     Authorization: Bearer <access_token>     │
     │─────────────────────────────────────────────>│
     │                                              │
     │  5. Task data                                │
     │<─────────────────────────────────────────────│
     │                                              │

Google OAuth Flow

  1. User clicks "Sign in with Google"
  2. Redirected to Google OAuth consent screen
  3. Google returns authorization code
  4. Backend exchanges code for access token
  5. Backend retrieves user info from Google
  6. User created/retrieved in database
  7. JWT token generated and returned
  8. Frontend stores token and redirects

👨‍💻 Development

Development Server

The application uses hot-reload for both frontend and backend:

  • Reflex: Automatically reloads on file changes
  • Django: Use --reload flag (default with runserver)

Code Style

  • Python: Follow PEP 8 guidelines
  • Django: Follow Django's coding style
  • Reflex: Follow Reflex best practices

Database Models

Core Models

User (Django built-in)

  • Extended with Profile model for email verification

Team

- name: CharField
- owner: ForeignKey(User)
- members: ManyToManyField(User)
- created_at: DateTimeField

Project

- name: CharField
- team: ForeignKey(Team)
- members: ManyToManyField(User)
- join_code: CharField (unique, auto-generated)
- created_at: DateTimeField

Task

- title: CharField
- description: TextField
- project: ForeignKey(Project)
- assigned_to: ForeignKey(User, nullable)
- status: CharField (todo/doing/done)
- created_at: DateTimeField

Signals & Automation

Automatic Team Synchronization:

@receiver(post_save, sender=Project)
def add_team_members_to_project(sender, instance, created, **kwargs):
    # Automatically adds team members to newly created projects

Automatic Member Updates:

@receiver(m2m_changed, sender=Team.members.through)
def sync_team_members_to_projects(sender, instance, action, pk_set, **kwargs):
    # Syncs team member changes to all team projects

🧪 Testing

Manual Testing

Follow the comprehensive guide in TESTING_GUIDE.md.

Quick Test Checklist

  • User registration and login
  • Google OAuth authentication
  • Team creation (staff only)
  • Project creation with team selection
  • Task creation and assignment
  • Task status updates (todo → doing → done)
  • Project joining via code
  • Automatic team member sync to projects

Creating Test Data

Via Django Admin:

# Access admin at http://localhost:8000/admin/
1. Create users (mark one as staff)
2. Create a team
3. Add members to team
4. Projects are created via frontend

Via Frontend:

  1. Login as staff user
  2. Navigate to Teams tab
  3. Click "Create Team"
  4. Add members and save

🚀 Deployment

Production Checklist

  • Set DEBUG = False in settings.py
  • Use PostgreSQL or MySQL instead of SQLite
  • Configure proper ALLOWED_HOSTS
  • Set up HTTPS/SSL certificates
  • Use environment variables for secrets
  • Configure static file serving (WhiteNoise or CDN)
  • Set up proper logging
  • Enable CSRF protection
  • Configure secure cookies
  • Set up monitoring and error tracking

Environment Variables (Production)

SECRET_KEY=<strong-secret-key>
DEBUG=False
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DATABASE_URL=postgres://user:pass@host:port/dbname
GOOGLE_CLIENT_ID=<production-client-id>
GOOGLE_CLIENT_SECRET=<production-client-secret>
CORS_ALLOWED_ORIGINS=https://yourdomain.com

Recommended Hosting

  • Backend: Heroku, Railway, DigitalOcean, AWS
  • Frontend: Vercel, Netlify, Reflex Hosting
  • Database: PostgreSQL on Heroku, AWS RDS, or Supabase
  • Static Files: AWS S3, Cloudflare

🤝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Write clear commit messages
  • Add tests for new features
  • Update documentation
  • Follow existing code style
  • Ensure all tests pass

📞 Support

For questions, issues, or feature requests:


🗺️ Roadmap

Current Status: Version 1.0

Planned Features (Future Development)

Phase 2 (In Planning)

  • Real-time notifications with WebSockets
  • Task comments and attachments
  • Advanced task filtering and search
  • Team activity timeline
  • Email notifications
  • Task due dates and reminders
  • Project templates
  • Export functionality (PDF, CSV)

Phase 3 (Future)

  • Mobile app (React Native)
  • Advanced analytics and reporting
  • Time tracking integration
  • Calendar integration (Google Calendar, Outlook)
  • File storage and sharing
  • Advanced permissions (custom roles)
  • API webhooks
  • Third-party integrations (Slack, Discord)

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published