# uncazzy/todoist-dashboard architecture

> Architecture diagram of the GitHub repository uncazzy/todoist-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uncazzy/todoist-dashboard
- Repository: https://github.com/uncazzy/todoist-dashboard

## Overview

##### Main Components

A. Frontend Layer:
- React Components (organized by feature)
- Dashboard components
- Analytics visualizations
- Recurring tasks management
- Layout components
- State Management (via React hooks)
- Authentication UI

B. Next.js Application Layer:
- API Routes
- Authentication handling
- Page routing
- Server-side rendering

C. External Services:
- Todoist API
- OAuth Authentication
- NextAuth.js service

##### Key Architectural Elements

**┌─ Client Layer ─────────────────────┐**
- ┌─ Components ──────────────────┐  │
- Dashboard                    │  │
- Insights                     │  │
- RecurringTasks              │  │
- Analytics Visualizations     │  │
- ┘ │
- ┌─ Hooks & Utils ───────────────┐  │
- useDashboardData            │  │
- Calculation Utils           │  │
- Pattern Processing          │  │
- ┘ │
- ┘
- ↕ (API Calls)
**┌─ Next.js Server Layer ──────────────┐**
- ┌─ API Routes ─────────────────┐    │
- /api/auth                   │    │
- /api/getStats              │    │
- /api/getTasks              │    │
- /api/getUser               │    │
- ┘   │
- ┌─ Authentication ──────────────┐    │
- NextAuth.js Integration     │    │
- ┘   │
- ┘
- ↕ (OAuth/API)
**┌─ External Services ───────────────────┐**
- ┌─ Todoist API ────────────────┐     │
- Task Management            │     │
- Project Data              │     │
- ┘    │
- ┘

##### Data Flow Indicators

- API request/response flows
- Authentication flows
- Data processing pipelines
- Component interactions

##### Important Notes

- Next.js-specific architecture (API routes, SSR capabilities)
- Separation between client and server components
- Where TypeScript types are shared
- Integration points with Todoist's API
- Authentication flow with NextAuth.js

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        direction TB
        Dashboard["Dashboard"]:::component
        Analytics["Analytics Components"]:::component
        RecurringTasks["Recurring Tasks"]:::component
        Layout["Layout Components"]:::component
        
        subgraph "Analytics Components"
            direction TB
            TimeOfDay["Completed By Time"]:::component
            ByProject["Tasks By Project"]:::component
            OverTime["Tasks Over Time"]:::component
            WordCloud["Word Cloud"]:::component
            ActiveTasks["Active Tasks"]:::component
        end
        
        subgraph "Recurring Tasks Patterns"
            direction TB
            Daily["Daily Patterns"]:::component
            Weekly["Weekly Patterns"]:::component
            Monthly["Monthly Patterns"]:::component
            Yearly["Yearly Patterns"]:::component
        end
        
        subgraph "State & Utils"
            direction TB
            DashboardHook["Dashboard Data Hook"]:::util
            VisibilityHook["Visibility Hook"]:::util
            CompletionUtils["Completion Utils"]:::util
            AveragesUtils["Task Averages"]:::util
            ProductiveTimeUtils["Productive Time Utils"]:::util
        end
    end
    
    subgraph "Next.js Server"
        direction TB
        AuthAPI["/api/auth"]:::api
        StatsAPI["/api/getStats"]:::api
        TasksAPI["/api/getTasks"]:::api
        UserAPI["/api/getUser"]:::api
        
        subgraph "Pages"
            direction TB
            MainPage["Main Dashboard"]:::page
            RecurringPage["Recurring Tasks"]:::page
            SignInPage["Sign In"]:::page
            LegalPage["Legal"]:::page
        end
    end
    
    subgraph "External Services"
        TodoistAPI["Todoist API"]:::external
        NextAuth["NextAuth.js"]:::external
    end
    
    %% Connections
    Dashboard --> DashboardHook
    Analytics --> DashboardHook
    RecurringTasks --> TasksAPI
    DashboardHook --> StatsAPI
    DashboardHook --> TasksAPI
    AuthAPI --> NextAuth
    NextAuth --> TodoistAPI
    
    %% Styles
    classDef component fill:#a8d1ff,stroke:#333
    classDef util fill:#ffe0a8,stroke:#333
    classDef api fill:#a8ffd1,stroke:#333
    classDef page fill:#d1a8ff,stroke:#333
    classDef external fill:#ffa8a8,stroke:#333
    
    %% Click Events
    click Dashboard "https://github.com/uncazzy/todoist-dashboard/blob/main/components/Dashboard.tsx"
    click TimeOfDay "https://github.com/uncazzy/todoist-dashboard/blob/main/components/CompletedByTimeOfDay.tsx"
    click ByProject "https://github.com/uncazzy/todoist-dashboard/blob/main/components/CompletedTasksByProject.tsx"
    click OverTime "https://github.com/uncazzy/todoist-dashboard/blob/main/components/CompletedTasksOverTime.tsx"
    click WordCloud "https://github.com/uncazzy/todoist-dashboard/blob/main/components/TaskWordCloud.tsx"
    click ActiveTasks "https://github.com/uncazzy/todoist-dashboard/blob/main/components/ActiveTasksByProject.tsx"
    click RecurringTasks "https://github.com/uncazzy/todoist-dashboard/blob/main/components/RecurringTasks/index.tsx"
    click Daily "https://github.com/uncazzy/todoist-dashboard/tree/main/components/RecurringTasks/streaks/patterns/daily/"
    click Weekly "https://github.com/uncazzy/todoist-dashboard/tree/main/components/RecurringTasks/streaks/patterns/weekly/"
    click Monthly "https://github.com/uncazzy/todoist-dashboard/tree/main/components/RecurringTasks/streaks/patterns/monthly/"
    click Yearly "https://github.com/uncazzy/todoist-dashboard/tree/main/components/RecurringTasks/streaks/patterns/yearly/"
    click Layout "https://github.com/uncazzy/todoist-dashboard/blob/main/components/layout/Layout.tsx"
    click AuthAPI "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/api/auth/[...nextauth].ts"
    click StatsAPI "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/api/getStats.ts"
    click TasksAPI "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/api/getTasks.ts"
    click UserAPI "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/api/getUser.ts"
    click DashboardHook "https://github.com/uncazzy/todoist-dashboard/blob/main/hooks/useDashboardData.ts"
    click VisibilityHook "https://github.com/uncazzy/todoist-dashboard/blob/main/hooks/useInView.ts"
    click CompletionUtils "https://github.com/uncazzy/todoist-dashboard/blob/main/utils/calculateCompletionRates.ts"
    click ProductiveTimeUtils "https://github.com/uncazzy/todoist-dashboard/blob/main/utils/calculateMostProductiveTimeOfDay.ts"
    click MainPage "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/index.tsx"
    click RecurringPage "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/recurring.tsx"
    click SignInPage "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/sign-in.tsx"
    click LegalPage "https://github.com/uncazzy/todoist-dashboard/blob/main/pages/legal.tsx"
```
