# riceball-tw/my-note architecture

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

- Interactive diagram: https://gitdiagram.com/riceball-tw/my-note
- Repository: https://github.com/riceball-tw/my-note

## Overview

##### Main Components

A. Frontend Layer:
- Vue Components Structure
- UI Components (shadcn-vue components)
- Components
- Pages (index, signin, signup)
- Asset Management
- Composables
- Middleware (auth)

B. Backend Layer:
- API Routes Structure
- Notes API endpoints
- User Authentication endpoints
- Database Layer (using Drizzle ORM)
- JWT Authentication Service

**┌─────────────────────────────────────────────────────────┐**
- Client Browser                        │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Frontend Layer                        │
- ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌────────┐  │
- Pages  │  │   UI     │  │  Note    │  │  Auth  │  │
- Components│  │Components│  │Middleware│  │
- ┘  └──────────┘  └──────────┘  └────────┘  │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Backend Layer                         │
- ┌──────────┐  ┌──────────┐  ┌──────────┐              │
- Notes   │  │  User    │  │   JWT    │              │
- API    │  │   API    │  │ Service  │              │
- ┘  └──────────┘  └──────────┘              │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Database Layer                        │
- ┌──────────────────────────────────────────┐          │
- Drizzle ORM                  │          │
- ┘          │
- ┘

##### Important Details to Highlight

A. Frontend Components:
- Hierarchy of UI components
- Authentication flow
- Routing structure

B. API Layer:
- CRUD operations (/api/notes)
- User authentication endpoints (/api/user)
- JWT handling (plugins/jwt.server.ts)

C. Database Schema:
- Main entities from schema.ts
- Relationships between entities

##### Technical Stack Callouts

- Nuxt.js (Frontend Framework)
- Vue.js (UI Framework)
- Tailwind CSS (Styling)
- Drizzle ORM (Database ORM)
- JWT (Authentication)

##### Interactions to Emphasize

- Authentication flow between frontend and backend
- CRUD operations flow
- Middleware interactions
- Database transactions

Remember to:
- Use consistent styling
- A title and version number
- Notes for any non-obvious architectural decisions
- Document any external service integrations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Browser"]
        Browser["Web Browser"]
    end

    subgraph FrontEnd["Frontend Layer"]
        Pages["Pages"]
        UIComponents["UI Components"]
        NoteComponents["Note Components"]
        AuthMiddleware["Auth Middleware"]
        Composables["Composables"]
    end

    subgraph API["Backend Layer"]
        NotesAPI["Notes API"]
        UserAPI["User API"]
        JWTService["JWT Service"]
    end

    subgraph DB["Database Layer"]
        DrizzleORM["Drizzle ORM"]
        Schema["Database Schema"]
    end

    %% Connections
    Browser <--> Pages
    Pages --> UIComponents
    Pages --> NoteComponents
    Pages --> AuthMiddleware
    Pages --> Composables
    AuthMiddleware <--> JWTService
    NoteComponents <--> NotesAPI
    Composables <--> UserAPI
    NotesAPI <--> DrizzleORM
    UserAPI <--> DrizzleORM
    DrizzleORM --- Schema

    %% Click Events
    click Pages "https://github.com/riceball-tw/my-note/tree/main//pages"
    click UIComponents "https://github.com/riceball-tw/my-note/tree/main//components/ui"
    click NoteComponents "https://github.com/riceball-tw/my-note/blob/main//components/note/NoteListItem.vue"
    click AuthMiddleware "https://github.com/riceball-tw/my-note/blob/main//middleware/auth.ts"
    click Composables "https://github.com/riceball-tw/my-note/blob/main//composables/useSignUp.ts"
    click NotesAPI "https://github.com/riceball-tw/my-note/tree/main//server/api/notes"
    click UserAPI "https://github.com/riceball-tw/my-note/tree/main//server/api/user"
    click JWTService "https://github.com/riceball-tw/my-note/blob/main//plugins/jwt.server.ts"
    click Schema "https://github.com/riceball-tw/my-note/blob/main//src/db/schema.ts"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef frontend fill:#dbeafe,stroke:#2563eb
    classDef api fill:#dcfce7,stroke:#16a34a
    classDef auth fill:#ffedd5,stroke:#ea580c
    classDef database fill:#f3e8ff,stroke:#9333ea
    
    class Pages,UIComponents,NoteComponents frontend
    class NotesAPI,UserAPI api
    class AuthMiddleware,JWTService auth
    class DrizzleORM,Schema database

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        APIComp["API Component"]:::api
        AuthComp["Auth Component"]:::auth
        DBComp["Database Component"]:::database
    end
```
