# ilyaizen/streak-calendar architecture

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

- Interactive diagram: https://gitdiagram.com/ilyaizen/streak-calendar
- Repository: https://github.com/ilyaizen/streak-calendar

## Overview

##### Main Components
- Frontend (Next.js App):
- "src/app" directory that contains the localized pages (e.g. routes for about, calendar, calendars, habits, and pricing), layouts, global styles, and providers.
- "src/components" layer which holds atomic UI components (buttons, forms, calendars, habit details, dialogs) as well as analytics and internationalization wrappers.
- Use of custom hooks ("src/hooks") and internationalization resources ("src/i18n" and "src/messages") for dynamic UI behavior and localization support.
- Backend (Convex):
- "convex/" directory which encapsulates backend logic and data schema including routes for authentication, calendar sync, habit management, migrations, and other business logic.
- Both the generated API types (in convex/_generated) and the Convex functions along with configuration files.
- External Services and Libraries:
- Authentication (Clerk): Illustrate where the authentication mechanism fits within the system.
- Payment and Subscription (Stripe): (Documented in the README as a planned integration for premium services.)
- Other libraries (e.g., Tailwind CSS, shadcn/ui, Framer Motion, Chart.js): Mention these as supporting libraries that enhance the UI and UX.
- Static Assets:

##### Relationships and Interactions
- Data Flow:
- User interactions in the browser trigger requests handled by Next.js components. These then communicate with Convex backend functions/API to fetch or update calendar and habit data.
- Component Dependencies:
- The frontend integrates with authentication providers (Clerk) and various libraries that handle analytics and animations.
- The static assets in "public/" are consumed by the frontend as part of responsive design.
- Internationalization flow: routes and providers leverage configuration files in "src/i18n" and translation files in "src/messages" ensuring localized rendering.

##### Architectural Patterns and Design Principles
- Modern Full-Stack Structure: Emphasize the separation of concerns between UI (Next.js/front-end) and business logic/data persistence (Convex/back-end), which also makes the project more maintainable and scalable.
- Modular Design:
- The clear separation of directories such as "src/components", "src/hooks", "src/lib", and "convex/" demonstrates modularity.
- Internationalization & Responsive Design:
- That the app is built with multi-locale support (via dynamic routing in "src/app/[locale]") and adaptive UI components.
- Integration of Third-Party Services:
- External systems like Clerk for auth, foresee Stripe for payment, and mention that services like Canvas Confetti and Chart.js are used to enhance user experience.

##### Final Elements
- Clear labels and distinct nodes for each primary component.
- Annotations that denote the responsibilities of each module (ex: “Handles user authentication via Clerk”, “Manages habit and calendar data using Convex”, “Renders UI with Next.js and shadcn/ui”).
- An overall architectural layer that succinctly shows the breakdown from user interactions (client-side) to server-side processing (backend) and then to any external systems (payment, analytics).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client"
        User("User Browser"):::clientstyle
    end

    subgraph "Frontend (Next.js)"
        direction TB
        App("Next.js App (src/app)"):::frontend
        Locale("Internationalized Pages (src/app/[locale])"):::frontend
        Components("UI Components (src/components)"):::frontend
        Hooks("Custom Hooks (src/hooks)"):::frontend
        I18n("Internationalization Config (src/i18n)"):::frontend
        Messages("Translations (src/messages)"):::frontend
    end

    subgraph "Backend (Convex)"
        direction TB
        Convex("Convex Services & Business Logic (convex)"):::backend
        Gen("Generated API Types (convex/_generated)"):::backend
    end

    subgraph "Static Assets"
        Public("Public Assets (public)"):::assets
    end

    subgraph "External Services"
        Clerk("Authentication (Clerk)"):::external
        Stripe("Payment (Stripe)"):::external
        Other("UI Enhancements (Tailwind,shadcn/ui,Chart.js)"):::external
    end

    User -->|"Interacts"| App
    User -->|"Interacts"| Components

    App -->|"LocalizedRouting"| Locale
    Components -->|"UsesCustomHooks"| Hooks
    Components -->|"UsesI18n"| I18n
    Components -->|"UsesTranslations"| Messages

    App -->|"LoadsStaticAssets"| Public

    App -->|"APICalls"| Convex
    Components -->|"TriggerAPIs"| Convex
    Convex -->|"ReturnsData"| App

    App -->|"AuthenticatesVia"| Clerk
    Components -->|"AuthWrapper"| Clerk
    Clerk -->|"ProvidesAuthTokens"| Convex

    App -->|"FutureSubscription"| Stripe

    Components -->|"StyledWith"| Other

    click App "https://github.com/ilyaizen/streak-calendar/tree/main/src/app"
    click Locale "https://github.com/ilyaizen/streak-calendar/tree/main/src/app/[locale]"
    click Components "https://github.com/ilyaizen/streak-calendar/tree/main/src/components"
    click Hooks "https://github.com/ilyaizen/streak-calendar/tree/main/src/hooks"
    click I18n "https://github.com/ilyaizen/streak-calendar/tree/main/src/i18n"
    click Messages "https://github.com/ilyaizen/streak-calendar/tree/main/src/messages"
    click Convex "https://github.com/ilyaizen/streak-calendar/tree/main/convex"
    click Gen "https://github.com/ilyaizen/streak-calendar/tree/main/convex/_generated"
    click Clerk "https://github.com/ilyaizen/streak-calendar/blob/main/src/components/authentication-wrapper.tsx"
    click Public "https://github.com/ilyaizen/streak-calendar/tree/main/public"

    classDef clientstyle fill:#f1c40f,stroke:#e67e22,stroke-width:2px;
    classDef frontend fill:#3498db,stroke:#2980b9,stroke-width:2px;
    classDef backend fill:#2ecc71,stroke:#27ae60,stroke-width:2px;
    classDef assets fill:#9b59b6,stroke:#8e44ad,stroke-width:2px;
    classDef external fill:#e74c3c,stroke:#c0392b,stroke-width:2px;
```
