# qrave1/quicknotes architecture

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

- Interactive diagram: https://gitdiagram.com/qrave1/quicknotes
- Repository: https://github.com/qrave1/quicknotes

## Overview

##### Main Components Identification

The project follows a clear separation between Frontend and Backend with a clean architecture pattern in the backend. Here's how to represent the main components:

A. Frontend Layer:
- React/TypeScript application (evident from tsconfig.json and .tsx files)
- Component structure with Auth, Notes, and Welcome modules
- Vite as the build tool

B. Backend Layer:
- Go-based backend with Clean Architecture
- Distinct layers:
- Interface/Controllers Layer
- Use Cases Layer
- Domain Layer
- Infrastructure Layer

C. Data Stores:
- PostgreSQL (evident from repository implementations)
- Redis (for token management)

##### Frontend Section
- Rectangle for React Application
- Sub-components for Auth, Notes, and Welcome modules
- Connection to Backend via HTTP/REST

##### Backend Section (Clean Architecture)
- HTTP Server Layer (interfaces/http)
- Controllers Layer (auth, folder, note controllers)
- Use Cases Layer (auth, folder, note services)
- Domain Layer (user, folder, note entities)
- Repository Layer (PostgreSQL and Redis implementations)

##### Data Store Section
- PostgreSQL Database (for users, folders, and notes)
- Redis Store (for token management)

##### Specific Elements

A. Frontend Components:
**[React Application]**

- [Auth Module]
- [Notes Module]
- [Welcome Module]

B. Backend Components (Clean Architecture):
**[HTTP Server/Middleware]**

- [Controllers (Auth/Folder/Note)]

- [Use Cases]

- [Domain Entities]

- [Repositories]

C. Data Stores:
**[PostgreSQL]   [Redis]**

##### Important Interactions to Highlight

- Frontend to Backend communication via HTTP/REST
- JWT Authentication flow
- Repository pattern implementations
- Clean Architecture dependencies (pointing inward)
- Database interactions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        FA["Frontend Application"]
        AM["Auth Module"]
        NM["Notes Module"]
        WM["Welcome Module"]
        
        FA --> AM
        FA --> NM
        FA --> WM
    end

    subgraph "Backend Clean Architecture"
        subgraph "Interface Layer"
            HS["HTTP Server"]
            JM["JWT Middleware"]
            CL["Controllers Layer"]
            
            HS --> JM
            JM --> CL
        end
        
        subgraph "Use Cases Layer"
            UC["Use Cases"]
            VS["Validation System"]
            
            CL --> UC
            UC --> VS
        end
        
        subgraph "Domain Layer"
            DE["Domain Entities"]
            
            UC --> DE
        end
        
        subgraph "Infrastructure Layer"
            RL["Repository Layer"]
            CM["Configuration Management"]
            MS["Migration System"]
            
            subgraph "Repositories"
                UR["User Repository"]
                NR["Note Repository"]
                FR["Folder Repository"]
                TR["Token Repository"]
                
                RL --> UR
                RL --> NR
                RL --> FR
                RL --> TR
            end
            
            RL --> CM
            RL --> MS
        end
        
        DE --> RL
    end

    subgraph "Data Stores"
        PG[(PostgreSQL)]
        RD[(Redis)]
    end

    AM --> HS
    NM --> HS
    WM --> HS
    
    UR --> PG
    NR --> PG
    FR --> PG
    TR --> RD

    %% Click events for component mapping
    click FA "https://github.com/qrave1/quicknotes/tree/master/Frontend/src/"
    click AM "https://github.com/qrave1/quicknotes/tree/master/Frontend/src/components/auth/"
    click NM "https://github.com/qrave1/quicknotes/tree/master/Frontend/src/components/notes/"
    click WM "https://github.com/qrave1/quicknotes/tree/master/Frontend/src/components/welcome/"
    click HS "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/interfaces/http/server.go"
    click CL "https://github.com/qrave1/quicknotes/tree/master/Backend/internal/interface/controller/"
    click UC "https://github.com/qrave1/quicknotes/tree/master/Backend/internal/usecase/"
    click DE "https://github.com/qrave1/quicknotes/tree/master/Backend/internal/domain/"
    click RL "https://github.com/qrave1/quicknotes/tree/master/Backend/internal/infrastructure/repository/"
    click JM "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/interfaces/http/middleware/jwt.go"
    click CM "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/config/config.go"
    click MS "https://github.com/qrave1/quicknotes/tree/master/Backend/internal/storage/migrations/"
    click UR "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/repository/user_postgres_repository.go"
    click NR "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/repository/note_postgres_repository.go"
    click FR "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/repository/folder_postgres_repository.go"
    click TR "https://github.com/qrave1/quicknotes/blob/master/Backend/internal/infrastructure/repository/token_redis_repository.go"
    click VS "https://github.com/qrave1/quicknotes/blob/master/Backend/pkg/validator/validator.go"

    classDef frontend fill:#a8d1ff,stroke:#2270c1
    classDef interface fill:#90EE90,stroke:#006400
    classDef usecase fill:#98FB98,stroke:#006400
    classDef domain fill:#32CD32,stroke:#006400
    classDef infrastructure fill:#3CB371,stroke:#006400
    classDef database fill:#FFD700,stroke:#B8860B
    classDef repository fill:#20B2AA,stroke:#008080

    class FA,AM,NM,WM frontend
    class HS,JM,CL interface
    class UC,VS usecase
    class DE domain
    class RL,CM,MS infrastructure
    class UR,NR,FR,TR repository
    class PG,RD database
```
