# joeseesun/sqlite-webnavi architecture

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

- Interactive diagram: https://gitdiagram.com/joeseesun/sqlite-webnavi
- Repository: https://github.com/joeseesun/sqlite-webnavi

## Overview

##### Project Type & Purpose
- This project is a full-stack web application that provides a dynamic navigation (WebNavi) system based on SQLite. It includes features such as dynamic navigation menus, site settings, theme switching, category/tag filtering, and a dedicated backend/admin interface.
- The backend is built with Node.js and uses SQLite as its database engine, while the frontend is composed of static HTML, CSS (with Tailwind CSS), and JavaScript, enhanced by Font Awesome and Google Fonts for UI aesthetics.

##### Analyzing the File Structure
- Main Entry Point: The app.js file is the central server script where the Node.js application is initialized.
- Static Resources: The public/ directory houses all frontend assets, including:
- The main home page (public/index.html),
- The admin interface under public/admin/ (for navigation, settings, login, etc.),
- JavaScript (public/js/) and custom styles (public/custom-styles.css).
- Database Files: Both database.sql and database.sqlite are present, indicating that the schema can be defined via SQL scripts and the live database is stored in the SQLite file.
- Migrations: The migrations/ directory contains scripts used to modify the database schema. These files suggest that the project uses a migration strategy for incremental database updates.
- Configuration & Deployment: Files like Dockerfile, docker-compose.yml, .dockerignore, and DOCKER-INSTALL.md point to containerization for deployment.
- Documentation: The docs/ folder holds additional developer insights, such as bug-fixing experiences.

##### Core Components
a. Backend Server (Node.js)
- Node.js application (app.js) as the central component that orchestrates the logic. Indicate that it handles HTTP requests, serves static files, and exposes API endpoints (e.g., GET /api/settings, GET /api/nav-menu, etc.).
- Middleware or routing that interprets and processes API requests.

b. Database (SQLite)
- SQLite database (database.sqlite) along with the SQL schema (database.sql). Indicate that the backend interacts with the database to manage site settings, navigation menu items, categories, tags, and sites.

c. Migrations Engine
- Migration scripts (in the migrations/ directory) as a component responsible for updating the database schema. This helps illustrate how the system evolves over time through migration files.

d. Frontend Client
- The user-facing homepage,
- The administrative interface (public/admin/),
- Static assets like CSS (including Tailwind and custom CSS files), JavaScript (main.js from public/js/), images, favicon, etc.
- That the frontend makes requests to API endpoints exposed by the backend.

e. Docker / Deployment Components
- Optionally, for deployment insights, include Docker-related components, showing that the application can be containerized (Dockerfile, docker-compose.yml). This layer stands for both development and production environments.

##### Relationships & Data Flow
- If including Docker components, demonstrate how these services are encapsulated and interact.

##### Architectural Patterns & Design Principles
- Although the project is relatively simple, it follows a modular separation between presentation (static HTML/JS/CSS) and business logic (Node.js backend).
- The RESTful API endpoints indicate a clear separation of concerns where the API layer is dedicated to website settings and navigation menu management.
- The existence of migration scripts and a separate static directory for administrative functions follow common patterns in modern web applications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        A["Frontend Client (HTML/CSS/JS)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B["Backend Server (Node.js)"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        C["SQLite Database"]:::database
        D["Migrations Engine"]:::migration
    end

    %% Deployment Components
    subgraph "Deployment Components"
        E1["Dockerfile"]:::deployment
        E2["docker-compose.yml"]:::deployment
        E3[".dockerignore"]:::deployment
        E4["DOCKER-INSTALL.md"]:::deployment
    end

    %% Connections between layers
    A -->|"HTTP/API"| B
    B -->|"CRUD"| C
    B -->|"migrate"| D

    %% Deployment connections to Backend
    E1 -->|"deploys"| B
    E2 -->|"deploys"| B
    E3 -->|"deploys"| B
    E4 -->|"deploys"| B

    %% Styling
    classDef frontend fill:#FFFF99,stroke:#000000,stroke-width:2px;
    classDef backend fill:#ADD8E6,stroke:#000000,stroke-width:2px;
    classDef database fill:#90EE90,stroke:#000000,stroke-width:2px;
    classDef migration fill:#FFB6C1,stroke:#000000,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#000000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/joeseesun/sqlite-webnavi/tree/main/public/"
    click B "https://github.com/joeseesun/sqlite-webnavi/blob/main/app.js"
    click C "https://github.com/joeseesun/sqlite-webnavi/blob/main/database.sqlite"
    click D "https://github.com/joeseesun/sqlite-webnavi/tree/main/migrations/"
    click E1 "https://github.com/joeseesun/sqlite-webnavi/tree/main/Dockerfile"
    click E2 "https://github.com/joeseesun/sqlite-webnavi/blob/main/docker-compose.yml"
    click E3 "https://github.com/joeseesun/sqlite-webnavi/blob/main/.dockerignore"
    click E4 "https://github.com/joeseesun/sqlite-webnavi/blob/main/DOCKER-INSTALL.md"
```
