# abhishekgusain07/downtominutes architecture

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

- Interactive diagram: https://gitdiagram.com/abhishekgusain07/downtominutes
- Repository: https://github.com/abhishekgusain07/downtominutes

## Overview

##### Main Components
- Frontend Client: This is built with Next.js (evidenced by the “client/app” directory with the new App Router structure). It contains multiple feature areas such as:
– Authentication (sign-in, sign-up, user profile)
– Marketing pages
– Dashboard (including finance, projects, settings)
– Goal management (goals, subgoals, tasks, and two versions of goal pages)
– Friends & accountability features (activity feed, chat, friend requests)
– Notifications, logs, plans, and settings
- API Endpoints: Located under “client/app/api”; these endpoints handle server actions for authentication (webhooks), cron jobs, payments (Stripe checkout session, webhook), etc.
- Database and Data Layer: The “client/prisma” directory with migrations and “schema.prisma” shows the use of Prisma as the ORM for database management.
- AI and Utility Modules: The “client/utils/ai” and other utilities illustrate integration of AI features (for generating plans, subgoals, task actions) and other helper functions.
- State Management & Shared Components: The “client/store” directory and “client/components” (including UI components and wrappers) support client-side state and common UI elements.
- Real-Time Chat & Convex Integration: The “client/convex” folder and associated API endpoints indicate a real-time, possibly serverless backend system driven by Convex for chat and notifications.
- External Services: From the README, note integrations with Stripe (payments), Supabase, Redis, and Clerk for authentication.

##### Relationships and Interactions
– The Frontend (Next.js client) interacts with the backend API endpoints for data fetching, authentication, scheduling cron jobs, handling payments, etc.
– The API endpoints interact with the database managed through Prisma, reading/writing goal, user, friend, log, and notification data.
– The fact that real-time interactions exist (chat, notifications) suggests that certain endpoints leverage Convex, which may be integrated as a separate real-time service that communicates with the client.
– AI modules interact with both the frontend (providing dynamic plan or subgoal generation features) and the backend.
– UI components and wrappers are shared across different pages and modules to ensure consistency in functionality (navigation, authentication guards, dashboards, etc.).

##### Architectural Patterns and Design Principles
– The project follows a component-based design (React/Next.js) with a clear separation between UI (components & pages) and backend API functionality.
– There is an MVC-like separation: views and pages on the frontend, a well-defined API layer, and a data layer (Prisma’s migration and schema).
– The use of modules (separated by folder names like “auth”, “goals”, “friends”, “dashboard”) reflects a feature-driven module pattern.
– The integration of external services (Stripe, Clerk, Supabase, Redis) should be represented as external systems interfacing via well-defined APIs.

##### Final Assembly
– Show how the API endpoints mediate between the client and data layer.
– Include server-side scheduling (cron) and webhook processing nodes.
– Also visually represent the integration of external services (Stripe, Clerk, etc.) and how they connect to both the API and client modules.
– Emphasize the architectural pattern (component-based design, modular API endpoints, and clear data flow) as key design principles.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Frontend Client (Next.js Application)
    subgraph "Frontend Client (Next.js)"
        MA("Marketing Pages"):::frontend
        AU("Authentication"):::frontend
        DA("Dashboard"):::frontend
        GO("Goal Management"):::frontend
        FR("Friends & Accountability"):::frontend
        NL("Notifications & Logs"):::frontend
        PL("Plans (AI)"):::frontend
    end

    %% Backend API Endpoints
    subgraph "Backend API Endpoints"
        AW("Auth Webhooks"):::backend
        CR("Cron Jobs"):::backend
        PY("Payments"):::backend
    end

    %% Database and Data Layer (Prisma)
    subgraph "Data Layer (Prisma)"
        PS("Prisma Schema"):::database
        PM("Migrations"):::database
    end

    %% AI and Utility Modules
    subgraph "AI Modules"
        AI("AI Utility Modules"):::ai
    end

    %% State Management and Shared UI Components
    subgraph "Client Utilities"
        SM("State Management"):::state
        SC("Shared UI Components"):::state
    end

    %% Real-Time Chat & Convex Integration
    subgraph "Real-Time Service"
        CV("Convex (Real-Time Chat)"):::backend
    end

    %% External Services
    subgraph "External Services"
        ST("Stripe"):::external
        CK("Clerk"):::external
        SU("Supabase"):::external
        RE("Redis"):::external
    end

    %% Connections between Frontend Modules
    MA -->|"navigates_to"| AU
    AU -->|"authenticates"| DA
    DA -->|"accesses"| GO
    DA -->|"accesses"| FR
    DA -->|"accesses"| NL
    DA -->|"accesses"| PL

    %% Frontend to Backend API Interactions
    AU -->|"calls"| AW
    DA -->|"triggers"| PY
    GO -->|"may_call"| PY
    FR -->|"initiates_chat"| CV
    NL -->|"updates"| CV
    PL -->|"generates"| AI

    %% API Endpoints to Database
    AW -->|"data_access"| PS
    CR -->|"data_access"| PS
    PY -->|"data_access"| PS

    %% API Endpoints to External Services
    PY -->|"connects_to"| ST
    AW -->|"integrates_with"| CK
    CR -->|"can_use"| SU
    CR -->|"can_use"| RE

    %% State Management supporting Frontend
    SM --> DA
    SC --> AU
    SC --> GO
    SC --> FR
    SC --> NL
    SC --> PL

    %% AI Modules integration with Frontend
    AI --> PL

    %% Convex integration with Frontend
    CV --> FR
    CV --> NL

    %% Click Events for Component Mappings
    click MA "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/(marketing)"
    click AU "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/(auth)"
    click DA "https://github.com/abhishekgusain07/downtominutes/tree/main/client/dashboard"
    click GO "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/app/goals"
    click FR "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/app/friends"
    click NL "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/app/notifications"
    click PL "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/app/plans"
    click AW "https://github.com/abhishekgusain07/downtominutes/blob/main/client/app/api/auth/webhook/route.ts"
    click CR "https://github.com/abhishekgusain07/downtominutes/blob/main/client/app/api/cron/test-cron/route.ts"
    click PY "https://github.com/abhishekgusain07/downtominutes/tree/main/client/app/api/payments"
    click PS "https://github.com/abhishekgusain07/downtominutes/blob/main/client/prisma/schema.prisma"
    click PM "https://github.com/abhishekgusain07/downtominutes/tree/main/client/prisma/migrations"
    click AI "https://github.com/abhishekgusain07/downtominutes/tree/main/client/utils/ai"
    click SM "https://github.com/abhishekgusain07/downtominutes/tree/main/client/store"
    click SC "https://github.com/abhishekgusain07/downtominutes/tree/main/client/components"
    click CV "https://github.com/abhishekgusain07/downtominutes/tree/main/client/convex"

    %% Styles for Diagram Nodes
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef database fill:#D5F5E3,stroke:#239B56,stroke-width:2px;
    classDef ai fill:#F5CBA7,stroke:#9C640C,stroke-width:2px;
    classDef state fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
