# thav/freehub architecture

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

- Interactive diagram: https://gitdiagram.com/thav/freehub
- Repository: https://github.com/thav/freehub

## Overview

Freehub is a multi-tenant Rails application for community bike shops to manage members and track shop visits. Users enter through organization-scoped routes, then staff manage people, visits, services, notes, and tags; reporting actions query shop activity and offer HTML, XML, or CSV results. Authentication and organization management support this workflow. The graph includes the documented tagging and reporting capabilities and the indexed calendar and drag-and-drop client modules; unsampled controller behavior and links between those client modules and screens are not asserted.

Main entry points: [`config/routes.rb`](https://github.com/thav/freehub/blob/master/config/routes.rb) (Rails routes), [`app/controllers/reports_controller.rb`](https://github.com/thav/freehub/blob/master/app/controllers/reports_controller.rb) (Report actions), [`app/controllers/visits_controller.rb`](https://github.com/thav/freehub/blob/master/app/controllers/visits_controller.rb) (Visit actions), [`app/models/service.rb`](https://github.com/thav/freehub/blob/master/app/models/service.rb) (Service records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request and access"]
  node_routes["Rails routes<br/>[routes.rb]"]
  node_application["Application controller"]
  node_auth["Authentication"]
  node_sessions["Session actions"]
  node_organizations["Organization actions"]
  node_users_controller["User actions"]
  node_user_model[("User records<br/>[user.rb]")]
end

subgraph group_people["People and membership"]
  node_organization_model[("Organization records<br/>[organization.rb]")]
  node_people_controller["People actions"]
  node_person_model[("Person records<br/>[person.rb]")]
end

subgraph group_activity["Shop activity"]
  node_visits_controller["Visit actions"]
  node_visit_model[("Visit records<br/>[visit.rb]")]
  node_services_controller["Service actions"]
  node_service_model[("Service records<br/>[service.rb]")]
  node_service_types["Service types<br/>[service_type.rb]"]
  node_notes_controller["Note actions"]
  node_note_model[("Notes<br/>[note.rb]")]
  node_tagging_controller["Tag assignments"]
  node_tags_controller["Tag lookup<br/>[tags_controller.rb]"]
end

subgraph group_insights["Reports and summaries"]
  node_reports_controller["Report actions"]
  node_summary_model["Visit summaries<br/>[visits_summary.rb]"]
end

subgraph group_client["Browser interface"]
  node_calendar["Date calendar"]
  node_dragdrop["Drag and drop<br/>[dragdrop.js]"]
  node_tag_ui["Tag controls<br/>[tags.jquery.js]"]
end

node_shop_staff(("Shop staff"))

node_shop_staff -.->|"sends requests"| node_routes
node_routes -->|"routes organization"| node_organizations
node_routes -->|"routes users"| node_users_controller
node_routes -->|"routes sessions"| node_sessions
node_routes -->|"routes people"| node_people_controller
node_routes -->|"routes visits"| node_visits_controller
node_routes -->|"routes services"| node_services_controller
node_routes -->|"routes notes"| node_notes_controller
node_routes -->|"routes taggings"| node_tagging_controller
node_routes -->|"routes tags"| node_tags_controller
node_routes -->|"routes reports"| node_reports_controller
node_visits_controller -->|"creates and updates"| node_visit_model
node_visits_controller -->|"creates notes"| node_note_model
node_reports_controller -->|"queries visits"| node_visit_model
node_reports_controller -->|"queries services"| node_service_model
node_reports_controller -->|"loads types"| node_service_types
node_reports_controller -->|"queries people"| node_person_model
node_reports_controller -->|"builds summary"| node_summary_model
node_auth -->|"authenticates users"| node_user_model
node_users_controller -->|"creates and finds"| node_user_model
node_service_model -->|"associates note"| node_note_model
node_service_model -->|"belongs to"| node_person_model
node_tag_ui -->|"sends tag requests"| node_tagging_controller

click node_routes "https://github.com/thav/freehub/blob/master/config/routes.rb"
click node_application "https://github.com/thav/freehub/blob/master/app/controllers/application_controller.rb"
click node_auth "https://github.com/thav/freehub/blob/master/lib/authenticated_system.rb"
click node_sessions "https://github.com/thav/freehub/blob/master/app/controllers/sessions_controller.rb"
click node_organizations "https://github.com/thav/freehub/blob/master/app/controllers/organizations_controller.rb"
click node_organization_model "https://github.com/thav/freehub/blob/master/app/models/organization.rb"
click node_people_controller "https://github.com/thav/freehub/blob/master/app/controllers/people_controller.rb"
click node_person_model "https://github.com/thav/freehub/blob/master/app/models/person.rb"
click node_users_controller "https://github.com/thav/freehub/blob/master/app/controllers/users_controller.rb"
click node_user_model "https://github.com/thav/freehub/blob/master/app/models/user.rb"
click node_visits_controller "https://github.com/thav/freehub/blob/master/app/controllers/visits_controller.rb"
click node_visit_model "https://github.com/thav/freehub/blob/master/app/models/visit.rb"
click node_services_controller "https://github.com/thav/freehub/blob/master/app/controllers/services_controller.rb"
click node_service_model "https://github.com/thav/freehub/blob/master/app/models/service.rb"
click node_service_types "https://github.com/thav/freehub/blob/master/app/models/service_type.rb"
click node_notes_controller "https://github.com/thav/freehub/blob/master/app/controllers/notes_controller.rb"
click node_note_model "https://github.com/thav/freehub/blob/master/app/models/note.rb"
click node_tagging_controller "https://github.com/thav/freehub/blob/master/app/controllers/taggings_controller.rb"
click node_tags_controller "https://github.com/thav/freehub/blob/master/app/controllers/tags_controller.rb"
click node_reports_controller "https://github.com/thav/freehub/blob/master/app/controllers/reports_controller.rb"
click node_summary_model "https://github.com/thav/freehub/blob/master/app/models/visits_summary.rb"
click node_calendar "https://github.com/thav/freehub/blob/master/public/javascripts/calendar_date_select/calendar_date_select.js"
click node_dragdrop "https://github.com/thav/freehub/blob/master/public/javascripts/dragdrop.js"
click node_tag_ui "https://github.com/thav/freehub/blob/master/public/javascripts/tags.jquery.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routes,node_application,node_auth,node_sessions,node_organizations,node_users_controller,node_user_model toneBlue
class node_organization_model,node_people_controller,node_person_model toneAmber
class node_visits_controller,node_visit_model,node_services_controller,node_service_model,node_service_types,node_notes_controller,node_note_model,node_tagging_controller,node_tags_controller toneMint
class node_reports_controller,node_summary_model toneRose
class node_calendar,node_dragdrop,node_tag_ui,node_shop_staff toneIndigo
```

## Components

### Request and access

- [Rails routes](https://github.com/thav/freehub/blob/master/config/routes.rb): `config/routes.rb`
- [Application controller](https://github.com/thav/freehub/blob/master/app/controllers/application_controller.rb): `app/controllers/application_controller.rb`
- [Authentication](https://github.com/thav/freehub/blob/master/lib/authenticated_system.rb): `lib/authenticated_system.rb`
- [Session actions](https://github.com/thav/freehub/blob/master/app/controllers/sessions_controller.rb): `app/controllers/sessions_controller.rb`
- [Organization actions](https://github.com/thav/freehub/blob/master/app/controllers/organizations_controller.rb): `app/controllers/organizations_controller.rb`
- [User actions](https://github.com/thav/freehub/blob/master/app/controllers/users_controller.rb): `app/controllers/users_controller.rb`
- [User records](https://github.com/thav/freehub/blob/master/app/models/user.rb): `app/models/user.rb`

### People and membership

- [Organization records](https://github.com/thav/freehub/blob/master/app/models/organization.rb): `app/models/organization.rb`
- [People actions](https://github.com/thav/freehub/blob/master/app/controllers/people_controller.rb): `app/controllers/people_controller.rb`
- [Person records](https://github.com/thav/freehub/blob/master/app/models/person.rb): `app/models/person.rb`

### Shop activity

- [Visit actions](https://github.com/thav/freehub/blob/master/app/controllers/visits_controller.rb): `app/controllers/visits_controller.rb`
- [Visit records](https://github.com/thav/freehub/blob/master/app/models/visit.rb): `app/models/visit.rb`
- [Service actions](https://github.com/thav/freehub/blob/master/app/controllers/services_controller.rb): `app/controllers/services_controller.rb`
- [Service records](https://github.com/thav/freehub/blob/master/app/models/service.rb): `app/models/service.rb`
- [Service types](https://github.com/thav/freehub/blob/master/app/models/service_type.rb): `app/models/service_type.rb`
- [Note actions](https://github.com/thav/freehub/blob/master/app/controllers/notes_controller.rb): `app/controllers/notes_controller.rb`
- [Notes](https://github.com/thav/freehub/blob/master/app/models/note.rb): `app/models/note.rb`
- [Tag assignments](https://github.com/thav/freehub/blob/master/app/controllers/taggings_controller.rb): `app/controllers/taggings_controller.rb`
- [Tag lookup](https://github.com/thav/freehub/blob/master/app/controllers/tags_controller.rb): `app/controllers/tags_controller.rb`

### Reports and summaries

- [Report actions](https://github.com/thav/freehub/blob/master/app/controllers/reports_controller.rb): `app/controllers/reports_controller.rb`
- [Visit summaries](https://github.com/thav/freehub/blob/master/app/models/visits_summary.rb): `app/models/visits_summary.rb`

### Browser interface

- [Date calendar](https://github.com/thav/freehub/blob/master/public/javascripts/calendar_date_select/calendar_date_select.js): `public/javascripts/calendar_date_select/calendar_date_select.js`
- [Drag and drop](https://github.com/thav/freehub/blob/master/public/javascripts/dragdrop.js): `public/javascripts/dragdrop.js`
- [Tag controls](https://github.com/thav/freehub/blob/master/public/javascripts/tags.jquery.js): `public/javascripts/tags.jquery.js`

### Other components

- **Shop staff**

## Connections

- Shop staff → Rails routes: sends requests
- Rails routes → Organization actions: routes organization (evidence: `config/routes.rb`)
- Rails routes → User actions: routes users (evidence: `config/routes.rb`)
- Rails routes → Session actions: routes sessions (evidence: `config/routes.rb`)
- Rails routes → People actions: routes people (evidence: `config/routes.rb`)
- Rails routes → Visit actions: routes visits (evidence: `config/routes.rb`)
- Rails routes → Service actions: routes services (evidence: `config/routes.rb`)
- Rails routes → Note actions: routes notes (evidence: `config/routes.rb`)
- Rails routes → Tag assignments: routes taggings (evidence: `config/routes.rb`)
- Rails routes → Tag lookup: routes tags (evidence: `config/routes.rb`)
- Rails routes → Report actions: routes reports (evidence: `config/routes.rb`)
- Visit actions → Visit records: creates and updates (evidence: `app/controllers/visits_controller.rb`)
- Visit actions → Notes: creates notes (evidence: `app/controllers/visits_controller.rb`)
- Report actions → Visit records: queries visits (evidence: `app/controllers/reports_controller.rb`)
- Report actions → Service records: queries services (evidence: `app/controllers/reports_controller.rb`)
- Report actions → Service types: loads types (evidence: `app/controllers/reports_controller.rb`)
- Report actions → Person records: queries people (evidence: `app/controllers/reports_controller.rb`)
- Report actions → Visit summaries: builds summary (evidence: `app/controllers/reports_controller.rb`)
- Authentication → User records: authenticates users (evidence: `lib/authenticated_system.rb`)
- User actions → User records: creates and finds (evidence: `app/controllers/users_controller.rb`)
- Service records → Notes: associates note (evidence: `app/models/service.rb`)
- Service records → Person records: belongs to (evidence: `app/models/service.rb`)
- Tag controls → Tag assignments: sends tag requests (evidence: `public/javascripts/tags.jquery.js`)
