# cleancookie/coggo architecture

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

- Interactive diagram: https://gitdiagram.com/cleancookie/coggo
- Repository: https://github.com/cleancookie/coggo

## Overview

##### Project type and purpose
- This is a small Node.js-based MVC web framework or web application skeleton named “Bones.”
- It provides:
- A custom HTTP server bootstrap (core/BoneServer.js)
- A routing layer (core/BoneRouter.js)
- A controllers directory for business logic (controllers/)
- EJS-based view rendering (views/)
- A configuration entry (server.config.js) and an application entrypoint (index.js)

##### File structure
- Top level:
- index.js           → Application bootstrap
- server.config.js   → Server settings (port, middleware toggles)
- package.json       → Dependency declarations
- Directory “core/”:
- BoneServer.js      → Creates an HTTP server, applies middleware, attaches router
- BoneRouter.js      → Parses routes, matches URLs to controller actions
- Directory “controllers/”:
- HomeController.js  → Example controller implementing request handlers
- Directory “views/”:
- index.ejs          → Template for HomeController’s view
- layouts/main.ejs   → Shared layout wrapper
- Configuration files: .eslintrc, .gitignore, .nvmrc

##### README for additional insights
- Minimal README—project is under construction

##### Detailed callout suggestions
- Index.js loading server.config.js and then initializing BoneServer.
- Inside BoneServer, illustrate where BoneRouter is registered.
- Within BoneRouter, map URL patterns (e.g., “/”) to HomeController methods.
- Render pipeline: Controller returns a view name and data object → EJS compiles and returns HTML.
- Response is sent back via the HTTP server to the client.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Bootstrap
    subgraph "Bootstrap"
        Index["index.js"]:::entry
        Config["server.config.js"]:::config
    end
    Index --> Config
    Index --> BoneServer

    %% Client Request Flow
    HTTPClient["HTTP Client"]:::client
    HTTPClient -->|"HTTP Request"| BoneServer

    %% Server Components
    BoneServer["BoneServer"]:::server
    BoneServer -->|"register router"| BoneRouter

    BoneRouter["BoneRouter"]:::server
    BoneRouter -->|"match URL"| Controllers

    %% Controllers Layer
    subgraph "Controllers"
        ControllersDir["controllers/"]:::logic
        HomeCtrl["HomeController.js"]:::logic
    end
    Controllers --> ControllersDir
    ControllersDir --> HomeCtrl
    HomeCtrl -->|"invokes"| ViewEngine

    %% View Layer
    ViewEngine["EJS View Engine"]:::view
    subgraph "Views"
        ViewsDir["views/"]:::view
        IndexEJS["index.ejs"]:::view
        LayoutsDir["views/layouts/"]:::view
        MainEJS["main.ejs"]:::view
    end
    ViewEngine --> ViewsDir
    ViewsDir --> IndexEJS
    ViewsDir --> LayoutsDir
    LayoutsDir --> MainEJS
    ViewEngine -->|"renders HTML"| BoneServer

    BoneServer -->|"HTTP Response"| HTTPClient

    %% Click Events
    click Index "https://github.com/cleancookie/coggo/blob/master/index.js"
    click Config "https://github.com/cleancookie/coggo/blob/master/server.config.js"
    click BoneServer "https://github.com/cleancookie/coggo/blob/master/core/BoneServer.js"
    click BoneRouter "https://github.com/cleancookie/coggo/blob/master/core/BoneRouter.js"
    click ControllersDir "https://github.com/cleancookie/coggo/tree/master/controllers/"
    click HomeCtrl "https://github.com/cleancookie/coggo/blob/master/controllers/HomeController.js"
    click ViewsDir "https://github.com/cleancookie/coggo/tree/master/views/"
    click IndexEJS "https://github.com/cleancookie/coggo/blob/master/views/index.ejs"
    click LayoutsDir "https://github.com/cleancookie/coggo/tree/master/views/layouts/"
    click MainEJS "https://github.com/cleancookie/coggo/blob/master/views/layouts/main.ejs"

    %% Styles
    classDef client fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef server fill:#cce5ff,stroke:#1976d2,color:#0d47a1;
    classDef logic fill:#c8e6c9,stroke:#2e7d32,color:#1b5e20;
    classDef view fill:#ffe0b2,stroke:#ef6c00,color:#e65100;
    classDef config fill:#e0e0e0,stroke:#9e9e9e,color:#424242;
    classDef entry fill:#d1c4e9,stroke:#5e35b1,color:#311b92;
```
