# taniarascia/takenote architecture

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

- Interactive diagram: https://gitdiagram.com/taniarascia/takenote
- Repository: https://github.com/taniarascia/takenote

## Overview

##### Main Components Structure

a) Frontend Layer (Client)
- Sub-components:
- Components (AppSidebar, Editor, NoteList)
- State Management (Redux Store)
- Router
- Styles (SCSS modules)

b) Backend Layer (Server)
- Sub-components:
- Authentication Handler
- Sync Handler
- Middleware
- Router

c) External Services
- GitHub OAuth (for self-hosted version)
- Local Storage (for demo version)

##### Component Relationships

- Client-Server communication via REST API
- Authentication flow with GitHub OAuth
- State management flow with Redux

##### Detailed Component Breakdown

Frontend (React):
- Components Layer
- AppSidebar (Navigation)
- Editor (Note Management)
- NoteList (Note Organization)
- State Management Layer
- Redux Store
- Slices (auth, category, note, settings, sync)
- Sagas
- Router Layer
- Styles Layer

Backend (Express):
- API Routes
- /auth
- /sync
- Middleware
- Authentication
- User Management
- Handlers
- Auth Handler
- Sync Handler

##### Important Architectural Patterns to Highlight

- Redux for state management
- React component hierarchy
- Express middleware pattern
- OAuth authentication flow
- Local storage persistence

##### Technical Stack Indicators

- TypeScript
- React
- Redux
- Express
- Jest/Cypress
- Webpack
- SCSS

##### Environment Variations

A section showing the differences between:
- Demo deployment (client-only with local storage)
- Self-hosted deployment (full stack with GitHub integration)

Remember to:
- Use consistent styling
- Brief annotations explaining key interactions
- Both synchronous and asynchronous flows
- Security boundaries
- Public vs. private routes

- Management
- Markdown processing
- Category organization
- Search functionality
- Settings management
- Sync capabilities

This architecture represents a modern React application with a clear separation of concerns, robust state management, and optional backend integration.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        TakeNoteApp["TakeNote App"]:::frontend
        click TakeNoteApp "https://github.com/taniarascia/takenote/blob/master/src/client/containers/TakeNoteApp.tsx"

        subgraph Components
            AppSidebar["App Sidebar"]:::frontend
            Editor["Editor"]:::frontend
            NoteList["Note List"]:::frontend
            click AppSidebar "https://github.com/taniarascia/takenote/tree/master/src/client/components/AppSidebar/"
            click Editor "https://github.com/taniarascia/takenote/tree/master/src/client/components/Editor/"
            click NoteList "https://github.com/taniarascia/takenote/tree/master/src/client/components/NoteList/"
        end

        subgraph "State Management"
            ReduxStore["Redux Store"]:::state
            click ReduxStore "https://github.com/taniarascia/takenote/tree/master/src/client/slices/"
            
            subgraph "Redux Slices"
                AuthSlice["Auth Slice"]:::state
                CategorySlice["Category Slice"]:::state
                NoteSlice["Note Slice"]:::state
                SettingsSlice["Settings Slice"]:::state
                SyncSlice["Sync Slice"]:::state
                click AuthSlice "https://github.com/taniarascia/takenote/blob/master/src/client/slices/auth.ts"
                click CategorySlice "https://github.com/taniarascia/takenote/blob/master/src/client/slices/category.ts"
                click NoteSlice "https://github.com/taniarascia/takenote/blob/master/src/client/slices/note.ts"
                click SettingsSlice "https://github.com/taniarascia/takenote/blob/master/src/client/slices/settings.ts"
                click SyncSlice "https://github.com/taniarascia/takenote/blob/master/src/client/slices/sync.ts"
            end
            
            Sagas["Redux Sagas"]:::state
            click Sagas "https://github.com/taniarascia/takenote/blob/master/src/client/sagas/index.ts"
        end

        subgraph "Router Layer"
            PrivateRoute["Private Route"]:::router
            PublicRoute["Public Route"]:::router
            click PrivateRoute "https://github.com/taniarascia/takenote/blob/master/src/client/router/PrivateRoute.tsx"
            click PublicRoute "https://github.com/taniarascia/takenote/blob/master/src/client/router/PublicRoute.tsx"
        end

        StylesLayer["Styles (SCSS)"]:::styles
        click StylesLayer "https://github.com/taniarascia/takenote/tree/master/src/client/styles/"

        ClientAPI["Client API"]:::api
        click ClientAPI "https://github.com/taniarascia/takenote/blob/master/src/client/api/index.ts"
    end

    subgraph Server
        ExpressServer["Express Server"]:::backend
        click ExpressServer "https://github.com/taniarascia/takenote/blob/master/src/server/index.ts"

        ServerInit["Server Initialization"]:::backend
        click ServerInit "https://github.com/taniarascia/takenote/blob/master/src/server/initializeServer.ts"

        subgraph "Server Handlers"
            AuthHandler["Authentication Handler"]:::backend
            SyncHandler["Sync Handler"]:::backend
            click AuthHandler "https://github.com/taniarascia/takenote/blob/master/src/server/handlers/auth.ts"
            click SyncHandler "https://github.com/taniarascia/takenote/blob/master/src/server/handlers/sync.ts"
        end

        subgraph "Server Middleware"
            AuthMiddleware["Authentication Middleware"]:::backend
            UserManagement["User Management"]:::backend
            click AuthMiddleware "https://github.com/taniarascia/takenote/blob/master/src/server/middleware/checkAuth.ts"
            click UserManagement "https://github.com/taniarascia/takenote/blob/master/src/server/middleware/getUser.ts"
        end

        subgraph "Server Router"
            MainRouter["Main Router"]:::backend
            AuthRoutes["Auth Routes"]:::backend
            SyncRoutes["Sync Routes"]:::backend
            click MainRouter "https://github.com/taniarascia/takenote/blob/master/src/server/router/index.ts"
            click AuthRoutes "https://github.com/taniarascia/takenote/blob/master/src/server/router/auth.ts"
            click SyncRoutes "https://github.com/taniarascia/takenote/blob/master/src/server/router/sync.ts"
        end
    end

    subgraph "External Services"
        GitHub["GitHub OAuth"]:::external
        LocalStorage["Local Storage"]:::storage
    end

    %% Connections
    TakeNoteApp --> Components
    TakeNoteApp --> ReduxStore
    Components --> ReduxStore
    ReduxStore --> Sagas
    Sagas --> ClientAPI
    ClientAPI --> ExpressServer
    ExpressServer --> ServerInit
    ServerInit --> MainRouter
    MainRouter --> AuthRoutes & SyncRoutes
    AuthRoutes --> AuthHandler
    SyncRoutes --> SyncHandler
    AuthHandler --> GitHub
    SyncHandler --> LocalStorage
    AuthMiddleware --> UserManagement

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef external fill:#FFC107,color:black
    classDef storage fill:#9C27B0,color:white
    classDef state fill:#FF5722,color:white
    classDef router fill:#607D8B,color:white
    classDef api fill:#795548,color:white
    classDef styles fill:#009688,color:white
```
