# kimbylr/inemit architecture

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

- Interactive diagram: https://gitdiagram.com/kimbylr/inemit
- Repository: https://github.com/kimbylr/inemit

## Overview

##### Main System Components

A. Client Layer (Frontend)
- Next.js Application
- Learn Module (src/app/(learn))
- Lists Management Module (src/app/lists)
- UI Components (src/components, src/elements)
- State Management (src/hooks)

B. Server Layer (Backend)
- Next.js API Routes (src/app/api)
- Authentication System (Auth0 integration)
- Database Layer (MongoDB)

C. External Services
- Unsplash API (for images)
- Deepl API (mentioned in env vars)

##### Component Relationships

a) User Flow:
- User → Auth0 → Application
- Authenticated User → Lists Management/Learn Module
- Lists Management → Database Operations
- Image Selection → Unsplash API

b) Data Flow:
- Client Components → API Routes → Database
- Learning Session → Spaced Repetition Algorithm → Progress Updates

##### Specific Architectural Elements

Key architectural patterns:

a) Next.js App Router Structure:
- Route groups: (learn), lists, about
- Dynamic routes: [slug]
- API routes structure

b) Component Architecture:
- Base Elements (src/elements)
- Composed Components (src/components)
- Complex Compositions (src/compositions)
- Page Layouts

##### Technical Details

Create sections for:

a) Frontend:
- PWA Capabilities (manifest.webmanifest)
- CSS Framework (Tailwind)
- Client-side Hooks and Helpers

b) Backend:
- Database Models (src/db/models.ts)
- Database Actions (src/db/actions.ts)
- Authentication Middleware

##### Special Features to Highlight

Create dedicated sections for:

- Spaced Repetition System
- Learning Progress Tracking
- Management Features
- Image Integration
- Import/Export Functionality

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        NextApp["Next.js Application"]
        
        subgraph Modules["Core Modules"]
            direction TB
            Learn["Learn Module"]:::module
            Lists["Lists Management"]:::module
        end
        
        subgraph Components["Component Layer"]
            direction TB
            BaseElem["Base Elements"]:::component
            Comp["Components"]:::component
            Compos["Compositions"]:::component
        end
        
        subgraph State["State Management"]
            direction TB
            Hooks["Hooks & State"]:::state
            Helpers["Helper Functions"]:::state
        end
    end
    
    subgraph Server["Server Layer"]
        direction TB
        API["API Routes"]:::api
        Auth["Auth0 Integration"]:::auth
        
        subgraph DB["Database Layer"]
            direction TB
            Models["DB Models"]:::db
            Actions["DB Actions"]:::db
            DBHelpers["DB Helpers"]:::db
        end
    end
    
    subgraph External["External Services"]
        direction TB
        Unsplash["Unsplash API"]:::external
        Deepl["Deepl Translation"]:::external
    end
    
    subgraph Features["Core Features"]
        direction TB
        Progress["Learning Progress"]:::feature
        Evaluation["Answer Evaluation"]:::feature
        StateMachine["State Machine"]:::feature
        ImportExport["Import/Export"]:::feature
    end
    
    %% Connections
    NextApp --> Auth
    Auth --> API
    API --> DB
    Learn --> Progress
    Lists --> Actions
    Progress --> StateMachine
    StateMachine --> Evaluation
    Lists --> Unsplash
    Lists --> Deepl
    
    %% Click Events
    click Learn "https://github.com/kimbylr/inemit/tree/main/src/app/(learn)/lists/[slug]/learn"
    click Lists "https://github.com/kimbylr/inemit/tree/main/src/app/lists"
    click BaseElem "https://github.com/kimbylr/inemit/tree/main/src/elements"
    click Comp "https://github.com/kimbylr/inemit/tree/main/src/components"
    click Compos "https://github.com/kimbylr/inemit/tree/main/src/compositions"
    click Auth "https://github.com/kimbylr/inemit/tree/main/src/app/api/auth/[auth0]"
    click Models "https://github.com/kimbylr/inemit/blob/main/src/db/models.ts"
    click Actions "https://github.com/kimbylr/inemit/blob/main/src/db/actions.ts"
    click DBHelpers "https://github.com/kimbylr/inemit/blob/main/src/db/helpers.ts"
    click Progress "https://github.com/kimbylr/inemit/blob/main/src/app/(learn)/lists/[slug]/learn/learn-progress.tsx"
    click Evaluation "https://github.com/kimbylr/inemit/blob/main/src/helpers/evaluate-answer.ts"
    click StateMachine "https://github.com/kimbylr/inemit/blob/main/src/app/(learn)/lists/[slug]/learn/state-machine.tsx"
    click ImportExport "https://github.com/kimbylr/inemit/blob/main/src/compositions/import-popup.tsx"
    click Hooks "https://github.com/kimbylr/inemit/blob/main/src/hooks/use-debounce.ts"
    click Helpers "https://github.com/kimbylr/inemit/blob/main/src/helpers/learn-item.ts"
    
    %% Styles
    classDef module fill:#a8dadc,stroke:#1d3557
    classDef component fill:#457b9d,stroke:#1d3557
    classDef state fill:#e63946,stroke:#1d3557
    classDef api fill:#2a9d8f,stroke:#1d3557
    classDef auth fill:#e9c46a,stroke:#1d3557
    classDef db fill:#f4a261,stroke:#1d3557
    classDef external fill:#264653,stroke:#1d3557,color:#fff
    classDef feature fill:#6b705c,stroke:#1d3557
    
    %% Legend
    subgraph Legend
        direction TB
        L1["🔒 Protected Routes"]
        L2["🔄 State Management"]
        L3["📡 API Endpoints"]
        L4["💾 Data Persistence"]
        L5["🖼️ Media Handling"]
    end
```
