Technical Documentation v2.0

TaskManager Pro

Complete technical reference for developers, architects, and system administrators

๐Ÿ“‹ Overview ๐Ÿ—๏ธ Architecture โš™๏ธ Tech Stack ๐Ÿ—„๏ธ Database Schema ๐Ÿ“ฆ Models ๐Ÿ”Œ API Reference ๐Ÿค– AI System ๐Ÿ” Authentication ๐Ÿš€ Deployment ๐Ÿงช Testing ๐ŸŒ Environment ๐Ÿ›ก๏ธ Security

๐Ÿ“‹ System Overview

TaskManager Pro is a multi-tenant business management platform built with Django, featuring task management, time tracking, invoicing, AI-powered insights, and advanced analytics.

Core Capabilities

  • Multi-tenant architecture with complete data isolation
  • Role-based access control (Admin, Manager, Member, Viewer)
  • Real-time dashboard with live metrics
  • AI-powered task prioritization and risk assessment
  • Automated invoicing from completed tasks
  • Advanced analytics and custom reporting

Key Metrics

  • 10,000+ active users
  • 50+ countries deployed
  • 99.9% uptime SLA
  • 850 AI credits per organization
  • 15+ database models
  • 30+ API endpoints

๐Ÿ—๏ธ System Architecture

High-Level Architecture

๐ŸŒ Frontend (Bootstrap 5)
โžก๏ธ
โš™๏ธ Django Views
โฌ‡๏ธ
โฌ‡๏ธ
โฌ‡๏ธ
๐Ÿ“Š Django Models
โฌ…๏ธโžก๏ธ
๐Ÿ—„๏ธ SQLite/PostgreSQL
โฌ‡๏ธ
โฌ‡๏ธ
โฌ‡๏ธ
โšก Redis (optional)
โฌ…๏ธโžก๏ธ
๐Ÿค– AI Services

Presentation Layer

  • Django Templates with Bootstrap 5
  • Chart.js for interactive visualizations
  • Font Awesome 6 for icons
  • Responsive design for all devices
  • Real-time updates with AJAX

Application Layer

  • Django 4.2.7 MTV architecture
  • Modular app structure (core, tasks, invoices, analytics)
  • Class-based and function-based views
  • Custom middleware for organization context
  • Signal handlers for automated processes

Data Layer

  • SQLite for development
  • PostgreSQL for production
  • Redis for caching (optional)
  • JSON fields for flexible data storage
  • Database indexing for performance

โš™๏ธ Technology Stack

Backend

Python 3.11 Django 4.2.7 Django REST Framework Celery Gunicorn

Frontend

Bootstrap 5 Chart.js Font Awesome 6 jQuery HTML5/CSS3

Database

SQLite (dev) PostgreSQL (prod) Redis (cache) PgBouncer

DevOps

Docker GitHub Actions AWS/GCP Nginx

๐Ÿ“ฆ Key Dependencies

Django==4.2.7
djangorestframework==3.14.0
celery==5.3.4
redis==5.0.1
psycopg2-binary==2.9.9
python-decouple==3.8
whitenoise==6.5.0
django-cors-headers==4.3.1
django-filter==23.5
django-extensions==3.2.3
xlsxwriter==3.1.9
weasyprint==60.1
pandas==2.1.4
numpy==1.26.2

๐Ÿ—„๏ธ Database Schema

Core App Models

Model Table Name Key Fields Relationships
Organization core_organization name, slug, subscription_plan, max_users, ai_credits_total created_by (User), members (through TeamMember)
User core_user email, full_name, business_name, default_hourly_rate current_organization (Organization), memberships (TeamMember)
TeamMember core_teammember role (admin/member/viewer), is_active user (User), organization (Organization)
Client core_client company_name, email, phone, hourly_rate, payment_terms organization (Organization), created_by (User)
Project core_project name, description, budget, hourly_rate, status client (Client), organization (Organization)

Tasks App Models

Model Table Name Key Fields Relationships
Task tasks_task title, priority (1-4), status, deadline, estimated/actual_hours project (Project), user (User), organization (Organization)
TimeEntry tasks_timeentry start_time, end_time, duration_minutes, notes task (Task), user (User)

Invoices App Models

Model Table Name Key Fields Relationships
Invoice invoices_invoice invoice_number, issue_date, due_date, subtotal, tax, total, status client (Client), project (Project), organization (Organization)
InvoiceItem invoices_invoiceitem description, quantity, unit_price, amount, time_entries (JSON) invoice (Invoice), task (Task)
Payment invoices_payment amount, payment_date, payment_method, reference invoice (Invoice), created_by (User)

Analytics App Models

Model Table Name Key Fields Relationships
ProfitabilityReport analytics_profitabilityreport report_type, period_start/end, total_billed, gross_profit, profit_margin organization (Organization), client (Client), project (Project)
TeamPerformance analytics_teamperformance tasks_completed, total_hours, revenue_generated, ai_accuracy organization (Organization), user (User)
CashFlowForecast analytics_cashflowforecast forecast_date, projected_balances, cash_flow_risk organization (Organization)
SavedReport analytics_savedreport name, config (JSON), is_scheduled, schedule_frequency organization (Organization), created_by (User)

๐Ÿ“ฆ Detailed Model Schemas

Task Model (AI-Enhanced)

Field Type Description AI Usage
ai_suggested_priority IntegerField AI-recommended priority (1-4) Urgent task detection
ai_priority_confidence FloatField Confidence score (0-1) AI reliability metric
ai_priority_reason TextField Explanation for priority suggestion User-facing insights
ai_analyzed_at DateTimeField Last AI analysis timestamp Staleness tracking
ai_priority_accepted BooleanField User accepted AI suggestion AI accuracy tracking
ai_risk_level CharField low/medium/high Risk assessment
ai_risk_factors JSONField List of risk factors with impacts Detailed risk breakdown
ai_predicted_completion DateTimeField AI-predicted completion date Forecasting
ai_completion_confidence IntegerField Confidence in prediction (0-100) Prediction reliability
ai_complexity_score IntegerField 1-10 complexity rating Effort estimation
ai_suggestions JSONField AI-generated recommendations Actionable insights

Organization Model

Field Type Description
name CharField Organization display name
slug SlugField URL-friendly identifier (unique)
subscription_plan CharField free/pro/enterprise
subscription_status CharField active/trial/past_due/canceled
max_users IntegerField User limit based on plan
max_projects IntegerField Project limit based on plan
ai_credits_total IntegerField Monthly AI credit allocation
ai_credits_used IntegerField Credits consumed this month

๐Ÿ”Œ API Reference

Authentication

POST /api/auth/login/

Authenticate user and return session token

POST /api/auth/logout/

Invalidate user session

POST /api/auth/password-reset/

Request password reset email

Tasks

GET /api/tasks/

List all tasks (filterable by status, priority, project)

POST /api/tasks/

Create new task

GET /api/tasks/{id}/

Retrieve specific task details

PUT /api/tasks/{id}/

Update task

DELETE /api/tasks/{id}/

Delete task

POST /api/tasks/{id}/time-entries/

Add time entry to task

POST /api/tasks/{id}/analyze/

Trigger AI analysis for task

Invoices

GET /api/invoices/

List all invoices

POST /api/invoices/

Create new invoice

POST /api/invoices/from-tasks/

Generate invoice from selected tasks

GET /api/invoices/{id}/pdf/

Download PDF invoice

POST /api/invoices/{id}/payments/

Record payment for invoice

Analytics

GET /api/analytics/dashboard/

Get dashboard metrics

GET /api/analytics/profitability/

Profitability reports (client/project)

GET /api/analytics/team-performance/

Team productivity metrics

GET /api/analytics/cash-flow/

Cash flow forecast

POST /api/analytics/reports/generate/

Generate custom report

POST /api/analytics/reports/save/

Save report configuration

GET /api/analytics/export/?format=excel|csv|pdf

Export report data

๐Ÿค– AI System Architecture

AI Components

  • Task Prioritization Engine โ€“ Analyzes deadlines, dependencies, project value
  • Risk Assessment Module โ€“ Evaluates complexity, dependencies, deadline pressure
  • Deadline Predictor โ€“ Forecasts completion dates based on historical data
  • Time Estimator โ€“ Suggests estimates based on similar tasks
  • Credit Management System โ€“ Tracks and limits AI usage

Risk Score Formula

risk_score = (
  complexity ร— 0.3 +
  dependencies ร— 0.3 +
  deadline_pressure ร— 0.4
)

Risk Levels:

  • Low โ€“ 1-3 (on track)
  • Medium โ€“ 4-7 (monitor closely)
  • High โ€“ 8-10 (immediate attention)

AI Credit Costs

Operation Credit Cost Frequency
Task analysis (priority + risk) 1 credit Per task
Deadline prediction 1 credit Per prediction
Batch analysis (10+ tasks) 8 credits Per batch
Cash flow forecast 2 credits Per forecast
Report generation with AI insights 3 credits Per report

AI Implementation Example

class TaskPrioritizationService:
    def analyze_task(self, task):
        # Calculate urgency based on deadline
        days_until_deadline = (task.deadline - timezone.now()).days
        urgency_score = max(0, 10 - days_until_deadline) / 10

        # Calculate complexity score
        complexity_score = task.ai_complexity_score / 10

        # Calculate risk
        risk_score = (complexity_score * 0.3 +
                 dependency_score * 0.3 +
                 urgency_score * 0.4)

        return {
            'priority': self._calculate_priority(risk_score),
            'risk_level': self._get_risk_level(risk_score),
            'confidence': 0.85
        }

๐Ÿ” Authentication & Authorization

Authentication Methods

  • Session-based auth โ€“ Django sessions with cookies
  • Token-based API auth โ€“ DRF token authentication
  • Two-factor authentication โ€“ Optional 2FA for enhanced security
  • Password reset flow โ€“ Email-based reset with tokens

Role-Based Access Control

  • Admin โ€“ Full system access, user management, billing
  • Manager โ€“ Create/edit all, team management
  • Member โ€“ Create/edit assigned tasks, time tracking
  • Viewer โ€“ Read-only access to assigned projects

Permission Matrix

Permission Admin Manager Member Viewer
View Dashboard โœ… โœ… โœ… โœ…
Create/Edit Tasks โœ… โœ… โœ… (assigned) โŒ
Delete Tasks โœ… โœ… โŒ โŒ
Create Invoices โœ… โœ… โŒ โŒ
View Team โœ… โœ… โŒ โŒ
Invite Members โœ… โŒ โŒ โŒ
View Analytics โœ… โœ… โœ… โŒ

๐Ÿš€ Deployment Guide

Development Setup

# Clone repository
git clone https://github.com/yourusername/taskmanager.git
cd taskmanager

# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Setup database
python manage.py migrate
python manage.py createsuperuser

# Run development server
python manage.py runserver

# Generate test data (optional)
python generate_test_data.py

Production Deployment (Ubuntu + Nginx + Gunicorn)

# Update system
sudo apt update && sudo apt upgrade -y

# Install dependencies
sudo apt install python3-pip python3-dev libpq-dev nginx -y

# Clone project
git clone https://github.com/yourusername/taskmanager.git
cd taskmanager

# Setup virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
pip install gunicorn psycopg2-binary

# Configure environment variables
cp .env.example .env
nano .env # Edit with production values

# Run migrations and collect static
python manage.py migrate
python manage.py collectstatic --no-input

# Configure Gunicorn service
sudo nano /etc/systemd/system/gunicorn.service

# Configure Nginx
sudo nano /etc/nginx/sites-available/taskmanager
sudo ln -s /etc/nginx/sites-available/taskmanager /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx

# Start services
sudo systemctl start gunicorn
sudo systemctl enable gunicorn

Docker Deployment

# Dockerfile
FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

RUN python manage.py collectstatic --no-input

CMD ["gunicorn", "--bind", "0.0.0.0:8000", "taskmanager.wsgi:application"]

# docker-compose.yml
version: '3.8'

services:
  web:
    build: .
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=postgresql://postgres:password@db:5432/taskmanager
    depends_on:
      - db

  db:
    image: postgres:15
    environment:
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=taskmanager
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

๐Ÿงช Testing Guide

Test Types

  • Unit Tests โ€“ Django TestCase for models and services
  • Integration Tests โ€“ API endpoints and view flows
  • Functional Tests โ€“ End-to-end user scenarios
  • AI Validation Tests โ€“ Verify AI suggestions and risk assessments

Test Data

  • generate_test_data.py โ€“ Populates database with realistic test data
  • 10+ organizations with various subscription plans
  • 20+ tasks with AI insights and risk assessments
  • 5+ invoices with different statuses

Running Tests

# Run all tests
python manage.py test

# Run specific app tests
python manage.py test tasks
python manage.py test invoices
python manage.py test analytics

# Run with coverage
coverage run --source='.' manage.py test
coverage report

# Generate test data
python generate_test_data.py

AI Validation Test Example

from django.test import TestCase
from tasks.models import Task
from analytics.services import TeamPerformanceService

class AITests(TestCase):
    def test_task_risk_assessment(self):
        # Create a task with high complexity
        task = Task.objects.create(
            title="Complex Task",
            ai_complexity_score=9,
            deadline=timezone.now() + timedelta(days=1)
        )

        # Trigger AI analysis
        service = TaskPrioritizationService()
        result = service.analyze_task(task)

        # Assert risk level is high
        self.assertEqual(result['risk_level'], 'high')
        self.assertGreater(result['confidence'], 0.7)

๐ŸŒ Environment Configuration

Create a .env file in the project root with the following variables:

SECRET_KEY = your-django-secret-key-here required
DEBUG = False production
DATABASE_URL = postgresql://user:password@localhost:5432/taskmanager production
REDIS_URL = redis://localhost:6379/0 optional
EMAIL_HOST = smtp.gmail.com email
EMAIL_PORT = 587 email
EMAIL_HOST_USER = your-email@gmail.com email
EMAIL_HOST_PASSWORD = your-app-password email
DEFAULT_FROM_EMAIL = noreply@taskmanager.pro email
SITE_URL = https://yourdomain.com production
AI_CREDITS_MONTHLY_LIMIT = 1000 AI
STRIPE_PUBLIC_KEY = pk_live_... payments
STRIPE_SECRET_KEY = sk_live_... payments

๐Ÿ›ก๏ธ Security Features

Built-in Protections

  • CSRF protection on all forms
  • XSS prevention with template escaping
  • SQL injection protection (ORM)
  • Clickjacking protection (X-Frame-Options)
  • Secure session management

Authentication Security

  • Password hashing with bcrypt
  • Rate limiting on login attempts
  • Session timeout after inactivity
  • Two-factor authentication option
  • Password strength validation

Data Security

  • Multi-tenant data isolation
  • Encryption at rest (database)
  • Encryption in transit (HTTPS)
  • Audit logs for critical actions
  • GDPR compliance features

Security Headers

# Django settings.py
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
X_FRAME_OPTIONS = 'DENY'
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True

โšก Performance Optimizations

Database Optimizations

  • Indexed fields for frequent queries (foreign keys, status, dates)
  • select_related and prefetch_related for eager loading
  • Database connection pooling with PgBouncer
  • Query optimization with explain analysis

Caching Strategy

  • Redis for session storage
  • Template fragment caching for dashboard
  • Low-level cache API for analytics
  • Cache invalidation on data changes

Query Optimization Example

# Bad - N+1 queries
tasks = Task.objects.filter(project=project)
for task in tasks:
    print(task.user.email) # Hits database each time

# Good - Single query with select_related
tasks = Task.objects.filter(project=project).select_related('user')
for task in tasks:
    print(task.user.email) # No additional queries

TaskManager Pro - Technical Documentation v2.0 | Last Updated: February 2026

For internal development use only | Back to Top โ†‘