# keevingfu/creative architecture

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

- Interactive diagram: https://gitdiagram.com/keevingfu/creative
- Repository: https://github.com/keevingfu/creative

## Overview

##### Project Type and Purpose
- From the structure (“frontend/”, “api/”, “docker-compose.yml”, “init-mongo.js”), we see this is a full-stack web application.
- The “api/” folder contains an Express server plus models; “frontend/” holds static assets and a simple Node server; MongoDB is initialized via “init-mongo.js”; there is an n8n workflow for automation.

##### File Structure
- Top-level:
- api/ – backend code (models/creative.js, server.js)
- frontend/ – UI assets (html/, css/, server.js)
- n8n_workflow/ – workflow automations
- creativedoc/ – documentation
- docker-compose.yml & Dockerfiles – container definitions
- init-mongo.js – DB initialization
- setup.sh, deploy.sh – environment and deployment scripts
- Patterns: clear separation of concerns (presentation vs. data vs. automation).

##### Extract Architecture Insights from README
- The README is minimal, but the file layout and scripts point to:
- A multi-container deployment via Docker Compose
- A Node.js/Express REST API
- A MongoDB database
- A simple Node-based static file server for the frontend
- n8n for workflow or integration tasks

##### Main Components
a. User’s Web Browser (UI)
b. Frontend Web Server (frontend/server.js + static files)
c. Backend API Server (api/server.js + models)
d. MongoDB Database (initialized via init-mongo.js)
e. n8n Workflow Engine (n8n_workflow)
f. Deployment Orchestrator (docker-compose + setup.sh, deploy.sh)

##### Relationships & Data Flows
- Browser → HTTP requests → Frontend Server (serves HTML/CSS/JS)
- Frontend Server → REST API calls → API Server
- API Server → Database driver → MongoDB
- n8n → triggers API endpoints or database hooks → Workflow tasks
- docker-compose → brings up Frontend, API, MongoDB, n8n as separate containers

##### Architectural Patterns & Technologies
- Layered, client-server pattern
- RESTful API
- Micro-services style via separate containers
- Data persistence with MongoDB
- CI/CD or deployment scripting with shell scripts
- Containerization (Docker, Docker Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User[/"User's Browser"/]:::presentation

    %% Docker Compose Group
    subgraph "Docker Compose" 
        direction TB
        FrontendServer["Frontend Server<br/>(frontend.Dockerfile)"]:::presentation
        APIServer["Backend API Server<br/>(api.Dockerfile)"]:::api
        MongoDB[(MongoDB Data Store)]:::data
        n8nEngine["n8n Workflow Engine"]:::infra
    end

    %% External Scripts
    InitMongo["DB Init Script<br/>(init-mongo.js)"]:::infra
    SetupScript["Setup Script<br/>(setup.sh)"]:::infra
    DeployScript["Deploy Script<br/>(deploy.sh)"]:::infra
    ComposeFile["Docker Compose<br/>(docker-compose.yml)"]:::infra

    %% Frontend Static Assets
    FrontendHTML["Index HTML<br/>(index.html)"]:::presentation
    FrontendCSS["Stylesheet CSS<br/>(styles.css)"]:::presentation

    %% API Model
    APIModel["Creative Model<br/>(creative.js)"]:::api

    %% Connections
    User -->|"HTTP Request"| FrontendServer
    FrontendServer -->|"Serves Static Files"| FrontendHTML
    FrontendServer --> FrontendCSS
    FrontendServer -->|"REST API Calls"| APIServer
    APIServer -->|"Uses Model"| APIModel
    APIServer -->|"Reads/Writes"| MongoDB
    InitMongo -->|"Initialize DB"| MongoDB
    n8nEngine -->|"Triggers API/Webhooks"| APIServer
    n8nEngine -->|"Direct DB Ops"| MongoDB

    %% Deployment Orchestration
    ComposeFile -.-> FrontendServer
    ComposeFile -.-> APIServer
    ComposeFile -.-> MongoDB
    ComposeFile -.-> n8nEngine
    SetupScript -.-> ComposeFile
    DeployScript -.-> ComposeFile

    %% Click events
    click FrontendServer "https://github.com/keevingfu/creative/blob/main/frontend/server.js"
    click FrontendHTML "https://github.com/keevingfu/creative/blob/main/frontend/html/index.html"
    click FrontendCSS "https://github.com/keevingfu/creative/blob/main/frontend/css/styles.css"
    click FrontendDocker "https://github.com/keevingfu/creative/blob/main/frontend/frontend.Dockerfile"
    click APIServer "https://github.com/keevingfu/creative/blob/main/api/server.js"
    click APIModel "https://github.com/keevingfu/creative/blob/main/api/models/creative.js"
    click APIDocker "https://github.com/keevingfu/creative/blob/main/api.Dockerfile"
    click InitMongo "https://github.com/keevingfu/creative/blob/main/init-mongo.js"
    click ComposeFile "https://github.com/keevingfu/creative/blob/main/docker-compose.yml"
    click SetupScript "https://github.com/keevingfu/creative/blob/main/setup.sh"
    click DeployScript "https://github.com/keevingfu/creative/blob/main/deploy.sh"
    click n8nEngine "https://github.com/keevingfu/creative/blob/main/n8n_workflow/README.md"

    %% Styles
    classDef presentation fill:#cfe2f3,stroke:#000;
    classDef api fill:#d9ead3,stroke:#000;
    classDef data fill:#f9cb9c,stroke:#000;
    classDef infra fill:#d9d2e9,stroke:#000;
```
