# chrishson/tracky architecture

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

- Interactive diagram: https://gitdiagram.com/chrishson/tracky
- Repository: https://github.com/chrishson/tracky

## Overview

This project is a Ruby on Rails web application that integrates a modern frontend using Inertia.js and React (likely with TypeScript support). The project leverages Rails as the backend API layer accompanied by a frontend built in JavaScript/TypeScript, bundled with Vite. The use of Inertia.js bridges the frontend (React) and backend (Rails) without the overhead of a traditional SPA framework separation.

##### Main Components
- Backend (Rails):
- Controllers, models, views, assets, jobs, mailers, channels.
- Configuration files in the config directory (including environment-specific settings).
- Database configuration (config/database.yml) and seeds (db/seeds.rb).
- Frontend (Inertia.js + React):
- Located under app/frontend with dedicated entrypoints (application.js, application.css, inertia.ts) and pages.
- Vite configuration files (vite.config.ts and tsconfig.*) indicate modern bundling and TypeScript support.
- Inertia Bridge:
- The initializer (config/initializers/inertia_rails.rb) integrates Inertia into Rails, providing a communication layer.
- Additional Support Components:
- Assets in app/assets (separate from app/frontend) used for conventional Rails asset pipeline.
- External tools like Docker (Dockerfile, .dockerignore) and Overmind for process management (Procfile.dev).

##### Relationships and Interactions
- The Rails backend serves as the core of the application, managing business logic, data persistence, and server-side rendering.
- Inertia.js acts as the connection layer that sends data from Rails controllers to the React components in the frontend. Requests are managed by Rails, which then delivers pages rendered by React.
- Vite is responsible for bundling and serving the frontend assets. Ensure that the output is in sync with the Rails views.
- The database layer (configured in config/database.yml) is used by Rails models and interacts through ActiveRecord.
- Assets (stylesheets, images, etc.) are served through Rails asset pipelines and static asset management.

##### Architectural Patterns and Design Principles
- MVC (Model-View-Controller): Rails follows this pattern in organizing business logic.
- Separation of Concerns: Distinct directories for the Rails backend (controllers, models, etc.) and the modern frontend (Inertia/React) ensure that each part of the stack is maintained separately.
- Progressive Enhancement: Using Inertia.js maintains the simplicity of Rails while enhancing the client-side experience.
- Containerization and Development Processes: Inclusion of Docker configurations and process managers indicates considerations for deployment and local development setups.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Rails Backend"
        subgraph "Controllers"
            AC["ApplicationController"]:::backend
            IEC["InertiaExampleController"]:::backend
        end
        subgraph "Models"
            AR["ApplicationRecord"]:::backend
        end
        subgraph "Views"
            AL["Application Layout"]:::backend
        end
        subgraph "Jobs"
            AJ["ApplicationJob"]:::backend
        end
        subgraph "Mailers"
            AM["ApplicationMailer"]:::backend
        end
        subgraph "Channels"
            CH["Channel"]:::backend
            CN["Connection"]:::backend
        end
    end

    I["Inertia.js Integration Layer"]:::inertia

    subgraph "React Frontend"
        FE1["Entrypoint (application.js)"]:::frontend
        FE2["Entrypoint (inertia.ts)"]:::frontend
        FE3["Page (InertiaExample.tsx)"]:::frontend
    end

    subgraph "Vite Bundler"
        ViteConfig["Vite Config"]:::bundler
        TsConfig["TypeScript Config"]:::bundler
        TsConfigApp["TypeScript App Config"]:::bundler
        TsConfigNode["TypeScript Node Config"]:::bundler
        ViteEnv["Vite Environment"]:::bundler
    end

    subgraph "Database & External Services"
        DConf["Database Config"]:::db
        Seeds["Seeds"]:::db
        subgraph "Rails Assets"
            Styles["Stylesheets"]:::db
            Manifest["Manifest"]:::db
        end
        subgraph "External Tools"
            Docker["Dockerfile"]:::external
            DockerIgnore[".dockerignore"]:::external
            Procfile["Procfile.dev"]:::external
        end
    end

    AC -->|"calls_Inertia"| I
    IEC -->|"calls_Inertia"| I
    I -->|"renders_Page"| FE3
    AR -->|"DB_Access"| DConf
    AL -->|"loads_Assets"| Styles
    ViteConfig -->|"bundles_for"| FE1
    ViteConfig -->|"bundles_for"| FE2

    classDef backend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef inertia fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef frontend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef bundler fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef db fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;

    click AC "https://github.com/chrishson/tracky/blob/main/app/controllers/application_controller.rb"
    click IEC "https://github.com/chrishson/tracky/blob/main/app/controllers/inertia_example_controller.rb"
    click AR "https://github.com/chrishson/tracky/blob/main/app/models/application_record.rb"
    click AL "https://github.com/chrishson/tracky/blob/main/app/views/layouts/application.html.erb"
    click AJ "https://github.com/chrishson/tracky/blob/main/app/jobs/application_job.rb"
    click AM "https://github.com/chrishson/tracky/blob/main/app/mailers/application_mailer.rb"
    click CH "https://github.com/chrishson/tracky/blob/main/app/channels/application_cable/channel.rb"
    click CN "https://github.com/chrishson/tracky/blob/main/app/channels/application_cable/connection.rb"
    click I "https://github.com/chrishson/tracky/blob/main/config/initializers/inertia_rails.rb"
    click FE1 "https://github.com/chrishson/tracky/blob/main/app/frontend/entrypoints/application.js"
    click FE2 "https://github.com/chrishson/tracky/blob/main/app/frontend/entrypoints/inertia.ts"
    click FE3 "https://github.com/chrishson/tracky/blob/main/app/frontend/pages/InertiaExample.tsx"
    click ViteConfig "https://github.com/chrishson/tracky/blob/main/vite.config.ts"
    click TsConfig "https://github.com/chrishson/tracky/blob/main/tsconfig.json"
    click TsConfigApp "https://github.com/chrishson/tracky/blob/main/tsconfig.app.json"
    click TsConfigNode "https://github.com/chrishson/tracky/blob/main/tsconfig.node.json"
    click ViteEnv "https://github.com/chrishson/tracky/blob/main/app/frontend/vite-env.d.ts"
    click DConf "https://github.com/chrishson/tracky/blob/main/config/database.yml"
    click Seeds "https://github.com/chrishson/tracky/blob/main/db/seeds.rb"
    click Styles "https://github.com/chrishson/tracky/blob/main/app/assets/stylesheets/application.css"
    click Manifest "https://github.com/chrishson/tracky/blob/main/app/assets/config/manifest.js"
    click Docker "https://github.com/chrishson/tracky/tree/main/Dockerfile"
    click DockerIgnore "https://github.com/chrishson/tracky/blob/main/.dockerignore"
    click Procfile "https://github.com/chrishson/tracky/blob/main/Procfile.dev"
```
