# dorkrawk/coparent architecture

> Architecture diagram of the GitHub repository dorkrawk/coparent, 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/dorkrawk/coparent
- Repository: https://github.com/dorkrawk/coparent

## Overview

##### Project type and purpose
- This is a full-stack web application (“Coparent”) consisting of:
- A React/TypeScript single-page application (SPA) frontend
- A Ruby (Sinatra-style) micro-service backend
- A SQLite database for persistence
- An external OpenWeather API integration

##### File structure
- Top-level directories:
- /frontend – Vite + React + TypeScript code, ESLint config, public assets
- /backend – Ruby app (app.rb, config.ru), ORM models, ERB views, DB setup
- Key files and patterns:
- backend/app.rb + config.ru → Sinatra entry points
- backend/models/*.rb → ActiveRecord or Sequel model layer (Kid, Task, Reward, Routine, RoutineTask, OpenWeatherApi)
- backend/db/*.rb → migrations, seed, config for SQLite (database.db)
- backend/views/*.erb → server-side templates for any server-rendered pages (although the SPA likely handles most rendering)
- frontend/src/pages + components → React component hierarchy, pages (Home, Routine)
- frontend/vite.config.ts + tsconfig → build & dev setup

##### README for additional insights
- Confirms simple dev commands:
- npm run dev → starts Vite dev server on the SPA
- ruby app.rb or shotgun app.rb → runs the backend on e.g. localhost:4567
- No explicit hosted deployment or cloud services; assume typical Node/Vite hosting for static assets and Ruby hosting for API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Browser (React SPA)"
        direction TB
        Index["index.html"]:::internal
        Main["main.tsx"]:::internal
        App["App.tsx"]:::internal
        Home["Home.tsx"]:::internal
        Routine["Routine.tsx"]:::internal
        Components["components/"]:::internal
        Public["public/"]:::internal
    end

    subgraph "Build & Dev Tools (Dev Only)" 
        direction TB
        Vite["vite.config.ts"]:::dev
        TsConfig["tsconfig.json"]:::dev
        TsApp["tsconfig.app.json"]:::dev
        TsNode["tsconfig.node.json"]:::dev
        ESLint["eslint.config.js"]:::dev
    end

    %% Backend Layer
    subgraph "API Server (Sinatra)" 
        direction TB
        AppRb["app.rb"]:::internal
        ConfigRu["config.ru"]:::internal
        Console["console.rb"]:::internal
        subgraph "Models"
            direction TB
            Kid["kid.rb"]:::internal
            Task["task.rb"]:::internal
            Reward["reward.rb"]:::internal
            RoutineModel["routine.rb"]:::internal
            RoutineTask["routine_task.rb"]:::internal
            OpenWeatherApi["open_weather_api.rb"]:::internal
        end
        subgraph "Views"
            direction TB
            Layout["layout.erb"]:::internal
            PageERB["page.erb"]:::internal
        end
    end

    %% Database Layer
    subgraph "SQLite Database" 
        direction TB
        DBFile["database.db"]:::db
        DBConfig["db/config.rb"]:::db
        Setup["db/setup.rb"]:::db
        Seed["db/seed.rb"]:::db
    end

    %% Documentation & Config
    subgraph "Project Docs & Config"
        direction TB
        ReadmeRoot["readme.md"]:::doc
        GitignoreRoot[".gitignore"]:::doc
        EnvTemplate[".env_template"]:::doc
        GitignoreFE["frontend/.gitignore"]:::doc
        ReadmeFE["frontend/README.md"]:::doc
        ReadmeBE["backend/README.md"]:::doc
    end

    %% External Service
    OpenWeather["OpenWeather API"]:::external

    %% Connections
    Index -->|"loads SPA on 5173"| AppRb
    Main -->|"imports App.tsx"| App
    App -->|"uses Home & Routine"| Home
    App -->|"uses Home & Routine"| Routine
    Home -->|"component from"| Components
    Routine -->|"component from"| Components

    Index -.->|dev server| Vite
    Main -.->|type-check| TsConfig
    Main -.->|type-check| TsApp
    Main -.->|type-check| TsNode
    Main -.->|lint| ESLint

    AppRb -->|handles HTTP REST| DBFile
    AppRb -->|handles HTTP REST| DBConfig
    AppRb -->|handles HTTP REST| Setup
    AppRb -->|handles HTTP REST| Seed

    AppRb -->|uses models| Kid
    AppRb -->|uses models| Task
    AppRb -->|uses models| Reward
    AppRb -->|uses models| RoutineModel
    AppRb -->|uses models| RoutineTask
    AppRb -->|uses models| OpenWeatherApi

    AppRb -->|renders views| Layout
    AppRb -->|renders views| PageERB

    AppRb -->|queries| DBFile
    DBFile <-->|CRUD operations| DBConfig
    DBFile <-->|CRUD operations| Setup
    DBFile <-->|CRUD operations| Seed

    AppRb -->|GET weather| OpenWeather

    ReadmeRoot -->|includes docs| GitignoreRoot
    ReadmeRoot -->|includes docs| ReadmeFE
    ReadmeRoot -->|includes docs| ReadmeBE
    EnvTemplate -->|template for| AppRb

    %% Click Events
    click Index "https://github.com/dorkrawk/coparent/blob/main/frontend/index.html"
    click Main "https://github.com/dorkrawk/coparent/blob/main/frontend/src/main.tsx"
    click App "https://github.com/dorkrawk/coparent/blob/main/frontend/src/App.tsx"
    click Home "https://github.com/dorkrawk/coparent/blob/main/frontend/src/pages/Home.tsx"
    click Routine "https://github.com/dorkrawk/coparent/blob/main/frontend/src/pages/Routine.tsx"
    click Components "https://github.com/dorkrawk/coparent/tree/main/frontend/src/components"
    click Public "https://github.com/dorkrawk/coparent/tree/main/frontend/public"
    click Vite "https://github.com/dorkrawk/coparent/blob/main/frontend/vite.config.ts"
    click TsConfig "https://github.com/dorkrawk/coparent/blob/main/frontend/tsconfig.json"
    click TsApp "https://github.com/dorkrawk/coparent/blob/main/frontend/tsconfig.app.json"
    click TsNode "https://github.com/dorkrawk/coparent/blob/main/frontend/tsconfig.node.json"
    click ESLint "https://github.com/dorkrawk/coparent/blob/main/frontend/eslint.config.js"
    click AppRb "https://github.com/dorkrawk/coparent/blob/main/backend/app.rb"
    click ConfigRu "https://github.com/dorkrawk/coparent/blob/main/backend/config.ru"
    click Console "https://github.com/dorkrawk/coparent/blob/main/backend/console.rb"
    click Kid "https://github.com/dorkrawk/coparent/blob/main/backend/models/kid.rb"
    click Task "https://github.com/dorkrawk/coparent/blob/main/backend/models/task.rb"
    click Reward "https://github.com/dorkrawk/coparent/blob/main/backend/models/reward.rb"
    click RoutineModel "https://github.com/dorkrawk/coparent/blob/main/backend/models/routine.rb"
    click RoutineTask "https://github.com/dorkrawk/coparent/blob/main/backend/models/routine_task.rb"
    click OpenWeatherApi "https://github.com/dorkrawk/coparent/blob/main/backend/models/open_weather_api.rb"
    click Layout "https://github.com/dorkrawk/coparent/blob/main/backend/views/layout.erb"
    click PageERB "https://github.com/dorkrawk/coparent/blob/main/backend/views/page.erb"
    click DBFile "https://github.com/dorkrawk/coparent/blob/main/backend/database.db"
    click DBConfig "https://github.com/dorkrawk/coparent/blob/main/backend/db/config.rb"
    click Setup "https://github.com/dorkrawk/coparent/blob/main/backend/db/setup.rb"
    click Seed "https://github.com/dorkrawk/coparent/blob/main/backend/db/seed.rb"
    click Gemfile "https://github.com/dorkrawk/coparent/tree/main/backend/Gemfile"
    click GemfileLock "https://github.com/dorkrawk/coparent/blob/main/backend/Gemfile.lock"
    click ReadmeRoot "https://github.com/dorkrawk/coparent/blob/main/readme.md"
    click GitignoreRoot "https://github.com/dorkrawk/coparent/blob/main/.gitignore"
    click EnvTemplate "https://github.com/dorkrawk/coparent/blob/main/backend/.env_template"
    click GitignoreFE "https://github.com/dorkrawk/coparent/blob/main/frontend/.gitignore"
    click ReadmeFE "https://github.com/dorkrawk/coparent/blob/main/frontend/README.md"
    click ReadmeBE "https://github.com/dorkrawk/coparent/blob/main/backend/README.md"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFFFE0,stroke:#333,stroke-width:1px
    classDef dev fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef doc fill:#F0E68C,stroke:#333,stroke-width:1px
```
