# jaimin25/daydonezo architecture

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

- Interactive diagram: https://gitdiagram.com/jaimin25/daydonezo
- Repository: https://github.com/jaimin25/daydonezo

## Overview

- Frontend (Next.js Application):
- Routing & Pages: Represent the “app” directory demonstrating different route groups such as:
- (root)/auth (login & register pages)
- (root)/landing (landing page)
- (root)/main (includes sub-modules for analytics, dashboard, journal, leaderboard, settings)
- Not-found routes for catch-all 404 handling.
- Layout & Providers: Include provider components (in app/_providers) that wrap the application, as well as shared layouts (app/(root)/layout.tsx and components/Layout).
- UI Components: Capture the modular components from the “components” directory (e.g., Analytics, Dashboard, Forms, Journal, Marketing, Leaderboard, Modal, UI elements). These represent the reusable building blocks for screens and user interactions.
- Hooks & State Management: Mention the “hooks” directory (e.g., use-mobile) and the “store” (userStore) for client-side state management.

- Backend & Data Access:
- API / Actions: Represent the “app/actions.tsx” that suggests server-side actions or API calls possibly used with Next.js API routes.
- Database Integration: Illustrate the Prisma layer under the “prisma” directory (schema.prisma, migrations) which interfaces with the PostgreSQL database.
- Auth & External Integration Services: Highlight the “lib” directory files where the authentication logic (lib/auth.ts), configuration, Firebase integration (lib/firebase.ts), and other utilities exist.

- External Services & Technologies:
- PostgreSQL: Represent your primary relational database managed through Prisma.
- Firebase: Indicate Firebase integration (likely used for authentication, storage, or notifications).
- PWA & Service Worker: Note the public service worker files (e.g., public/sw.js, workbox-*.js) for offline support.

##### Relationships and Flow
- How the user interacts with the Frontend:
- The user accesses the application via the landing page.
- Authentication components (login/register) route users through the auth provider.
- Navigation between dashboard, journal entry creation/edit, analytics view, leaderboard, and settings.
- Internal communication between layout components and state providers.
- That the frontend business logic (inside “lib”, “hooks”, “store”) interacts with server-side actions, which in turn call the Prisma API for database operations.
- Integration with Firebase and external third party libraries (ShadCN, MagicUI, Aceternity) for UI enhancements and additional functionality.

##### Architectural Patterns and Design Principles
- Next.js Routing: Use a layered representation for the new Next.js app directory, showing separation between public pages, nested layouts, and catch-all routes.
- Component-Based UI: Emphasize the clear modular design found in the “components” directory, which makes the UI highly maintainable.
- Service Layer / Data Access: Highlight the role of the “lib” and “prisma” directories for encapsulating business logic and data access.
- Extensibility: Through multiple UI components and clear separation between pages and business logic, it becomes easier to extend or modify individual modules.

##### Final Touches
- That all major functionalities listed in the README (streak tracking, analytics, shareable wins, encryption, etc.) are mapped to their respective modules (for example, analytics components and DB interactions).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        routing["Routing & Pages"]:::frontend
        layout["App Layout"]:::frontend
        providers["Providers"]:::frontend
        ui["UI Components"]:::frontend
        hooks["Hooks & State Management"]:::frontend
    end

    subgraph "Backend"
        apiActions["API / Actions"]:::backend
        authLib["Auth & External Lib"]:::backend
        prisma["Prisma Data Layer"]:::backend
    end

    subgraph "External Services"
        postgres["PostgreSQL"]:::db
        firebase["Firebase"]:::external
        pwa["PWA & Service Worker"]:::external
    end

    user["User"]:::external

    user -->|"accesses"| routing
    routing -->|"uses"| layout
    layout -->|"renders"| providers
    providers -->|"supports"| ui
    ui -->|"manages_state_via"| hooks
    hooks -->|"calls"| apiActions
    apiActions -->|"invokes"| authLib
    apiActions -->|"queries"| prisma
    authLib -->|"integrates"| firebase
    prisma -->|"operates_on"| postgres
    ui -->|"offline_support_through"| pwa

    %% Click Events
    click routing "https://github.com/jaimin25/daydonezo/blob/main/app/(root)/..."
    click layout "https://github.com/jaimin25/daydonezo/blob/main/app/(root)/layout.tsx"
    click layout "https://github.com/jaimin25/daydonezo/tree/main/components/Layout"
    click providers "https://github.com/jaimin25/daydonezo/tree/main/app/_providers"
    click ui "https://github.com/jaimin25/daydonezo/tree/main/components"
    click hooks "https://github.com/jaimin25/daydonezo/blob/main/hooks/use-mobile.tsx"
    click hooks "https://github.com/jaimin25/daydonezo/blob/main/store/userStore.ts"
    click apiActions "https://github.com/jaimin25/daydonezo/blob/main/app/actions.tsx"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/auth.ts"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/firebase.ts"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/config.ts"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/contants.ts"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/prisma.ts"
    click authLib "https://github.com/jaimin25/daydonezo/blob/main/lib/utils.ts"
    click prisma "https://github.com/jaimin25/daydonezo/blob/main/prisma/schema.prisma"
    click prisma "https://github.com/jaimin25/daydonezo/tree/main/prisma/migrations"
    click pwa "https://github.com/jaimin25/daydonezo/blob/main/public/sw.js"
    click pwa "https://github.com/jaimin25/daydonezo/blob/main/public/workbox-e43f5367.js"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef external fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef db fill:#FADBD8,stroke:#922B21,stroke-width:2px;
```
