# lukaprsina/jknm architecture

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

- Interactive diagram: https://gitdiagram.com/lukaprsina/jknm
- Repository: https://github.com/lukaprsina/jknm

## Overview

##### Project’s Purpose & Main Technologies
- The README (“Jamarski klub Novo mesto”) and file structure indicate this is a website. The heavy use of Next.js (with a “src/app” folder, API routes, and Next.js configuration files like next.config.mjs) confirms it is a modern full-stack web application.
- Notice the use of MDX pages (e.g., src/app/(static)/klub/page.mdx and similar in other subdirectories), which means static content is mixed with dynamic content.
- The presence of “drizzle” directories (with SQL migration files and schemas) indicates a relational database managed via Drizzle ORM.
- There are integrations with external services: AWS S3 (in components/aws-s3 and s3-publish scripts), Backblaze B2 (upload_file_to_b2 API endpoint), and Supabase (api/wake_supabase).
- A rich UI component library, along with Tailwind CSS and various ESLint/Prettier configurations, rounds out modern front-end techniques.

##### Main Components
a. Frontend (Client/Presentation Layer):
- Next.js Application pages: Represented mainly by the “src/app” folder that contains different page groups (static pages for klub, publiciranje, raziskovanje, etc., as well as dynamic pages like novica and avtorji).
- MDX-based static content, responsive layouts, and UI components housed in “src/components” (with dedicated sections for articles, the shell, UI elements, and navigation).
- Client-side utilities and hooks (“src/hooks”) that manage interactions such as infinite scrolling, notifications, or editor mutations.

b. Backend (Server/API Layer):
- API endpoints in “src/app/api”: including authentication ([...nextauth] routes), sending messages, file upload to B2, and waking up Supabase.
- Server-side logic located in “src/server”: managing article operations (create-draft, delete, publish, etc.), author management, and database queries.
- Middleware (src/middleware.ts) for request handling.
- Conversion logic (under src/app/converter) that includes server and client converter files, image generation, and data parsing.

c. Database Layer:
- Relational database schema/migrations managed by tools in the “drizzle” folder (drizzle/schema.ts, relations.ts) that hints at a SQL-based setup.
- The “src/server/db” directory which handles database operations and state caching.

d. External Integrations:
- AWS S3: Evident through components in “src/components/aws-s3” and s3-publish scripts inside “src/lib”.
- Backblaze B2: Via the “src/app/api/upload_file_to_b2” endpoint for file uploads.
- Supabase: An integration indicated in “src/app/api/wake_supabase”.

e. Supporting Tools & Scripts:
- Utility scripts in the “scripts” directory for tasks like renaming, generating TOC, and image manipulation.
- Development tools and config files (e.g., ESLint, Prettier, Tailwind CSS, and the Vercel deployment descriptor).

##### Establishing Relationships and Interactions
- Demonstrate that the backend server interacts with the Database via Drizzle ORM and SQL migrations. Indicate how articles or authors are queried and updated.
- Connections from the backend to external services (AWS S3 for file storage, Backblaze B2 for file uploads, and Supabase for additional functionality).
- Out the conversion tools – showing how the converter components process and manipulate data/images before being rendered or stored.

##### Architectural Patterns & Design Principles
- Separation of concerns: Distinguish between frontend presentation, backend logic, and data persistence.
- Full-stack integration: The Next.js paradigm that blends client and server code in a single repository.
- Modular design: Components are divided logically (e.g., UI vs. API vs. server operations) and externalized via scripts and utilities.
- Use of server components and API routing to ensure that both static and dynamic content are handled appropriately.
- Demonstration of how middleware or context providers (e.g., editor context, shell context) integrate into the app.

##### Specific Elements
- Use clear labels for each component: “Next.js Pages & Components”, “API Endpoints (auth, file upload, wake_supabase)”, “Server-side Article & Author Management”, “Database (Drizzle ORM)”, “AWS S3 & Backblaze B2 Storage”, and “Utility/Conversion Scripts”.
- From client browsers to the Next.js application.
- From API/server services to the Database and external services.

- Below that, represent the Next.js application layer that includes both static (MDX pages and UI components) and dynamic routes.
- On a parallel track, detail the API endpoints and server logic – from authentication, sending data, and conversion tasks.
- Link the server layer to the Database (show the Drizzle ORM and SQL migrations) and external services (AWS S3, Backblaze B2, Supabase).
- Finally, include utility scripts and development tools as side components that feed into the build and deployment process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    B["User Browser"]:::client

    subgraph "Frontend (Next.js)"
        P["Pages & MDX Content"]:::frontend
        UIC["UI Components Library"]:::frontend
        CU["Client Utilities & Hooks"]:::frontend
    end

    subgraph "Backend & API"
        API["API Endpoints (Auth,FileUpload,WakeSupabase)"]:::backend
        SSR["Server-side Article & Author Management"]:::backend
    end

    subgraph "Database"
        DR["Drizzle ORM Migrations"]:::database
        DBOp["Server DB Operations"]:::database
    end

    subgraph "External Services"
        AWS1["AWS S3 - Components"]:::external
        AWS2["AWS S3 - Publish Script"]:::external
        B2["Backblaze B2"]:::external
        SUP["Supabase"]:::external
    end

    subgraph "Utility Scripts"
        CS["Conversion Scripts"]:::utility
        UT2["Other Utility Scripts"]:::utility
    end

    B --> P
    B --> UIC
    B --> CU
    P -->|"fetch_data"| API
    UIC -->|"render_UI"| API
    API -->|"process_request"| SSR
    SSR -->|"db_interaction"| DBOp
    DR -->|"migration_support"| DBOp
    API -->|"store_files"| AWS1
    API -->|"publish_files"| AWS2
    API -->|"upload_file"| B2
    API -->|"trigger_wake"| SUP
    CU -->|"invoke_converter"| CS
    UT2 -->|"support_conversion"| CS
    CS -->|"prepare_content"| P

    click P "https://github.com/lukaprsina/jknm/tree/main/src/app/(static)"
    click UIC "https://github.com/lukaprsina/jknm/tree/main/src/components"
    click CU "https://github.com/lukaprsina/jknm/tree/main/src/hooks"
    click API "https://github.com/lukaprsina/jknm/tree/main/src/app/api"
    click SSR "https://github.com/lukaprsina/jknm/tree/main/src/server"
    click DR "https://github.com/lukaprsina/jknm/tree/main/drizzle"
    click DBOp "https://github.com/lukaprsina/jknm/tree/main/src/server/db"
    click AWS1 "https://github.com/lukaprsina/jknm/tree/main/src/components/aws-s3"
    click AWS2 "https://github.com/lukaprsina/jknm/blob/main/src/lib/s3-publish.ts"
    click B2 "https://github.com/lukaprsina/jknm/blob/main/src/app/api/upload_file_to_b2/route.ts"
    click SUP "https://github.com/lukaprsina/jknm/blob/main/src/app/api/wake_supabase/route.ts"
    click CS "https://github.com/lukaprsina/jknm/tree/main/src/app/converter"
    click UT2 "https://github.com/lukaprsina/jknm/tree/main/scripts"

    classDef client fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef frontend fill:#C0E8D5,stroke:#333,stroke-width:2px;
    classDef backend fill:#F7CAC9,stroke:#333,stroke-width:2px;
    classDef database fill:#B2BABB,stroke:#333,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#333,stroke-width:2px;
    classDef utility fill:#FAD7A0,stroke:#333,stroke-width:2px;
```
