# splitwise/api-docs architecture

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

- Interactive diagram: https://gitdiagram.com/splitwise/api-docs
- Repository: https://github.com/splitwise/api-docs

## Overview

Summary / project type and purpose
- This repository is an API documentation site: a static site generated from OpenAPI v3 source files (splitwise.yaml + paths/, schemas/, responses/). It uses Redoc/Redocly (via npm scripts) to render OpenAPI into a browsable HTML doc (docs/index.html). The site is intended to publish the official Splitwise API docs (dev.splitwise.com) and is built/served locally for development and compiled to a zero-dependency HTML file for deployment (docs/index.html). CI and hosting hooks (e.g., .travis.yml and docs/CNAME) indicate automated build/deploy to GitHub Pages / custom domain.

How I inspected the repo to reach that conclusion
- README explicitly: "powered by OpenAPI + redocly" and commands npm run serve / npm run build.
- File tree shows standard OpenAPI layout:
- splitwise.yaml: root OpenAPI bundle/entrypoint
- paths/: per-endpoint YAML files (paths/create_expense.yaml, get_expenses.yaml, ...)
- schemas/: component schemas (users, expense, comment, etc.)
- responses/: shared response objects (forbidden, not_found, unauthorized)
- docs/index.html and docs/CNAME indicate build output and a custom domain for hosting.
- package.json & .travis.yml imply build tooling and CI integration.

- The documentation pipeline (source → build → artifact → host → consumer).
- The logical separation between:
- Source OpenAPI artifacts (authoring content)
- Build toolchain (npm scripts, redocly/redoc)
- CI/CD (Travis or other automation)
- Hosting / Delivery (GitHub Pages + custom domain, possible CDN)
- End users (developers, API consumers) and external services (npm registry, GitHub)
- Important internal components: paths, schemas, responses, splitwise.yaml, docs/ (artifact).

##### Authoring/Source (blue)
- splitwise.yaml (entrypoint)
- paths/ (all endpoint definitions)
- schemas/ (model definitions and sub-schemas)
- responses/ (shared responses/errors)
- docs/ (static assets, CNAME)
- package.json / package-lock.json (build scripts & dependencies)
##### Build Toolchain (green)
- npm (scripts: serve, build)
- redoc / redocly (OpenAPI renderer)
- optional linters/validators (OpenAPI linter / redocly config if used)
##### Development Server (light green)
- local dev server (npm run serve) — live reloading
##### CI/CD (cyan)
- .travis.yml (or alternate CI) triggers build
- CI job: run npm install → validate → npm run build → publish
##### Artifact / Hosting (purple)
- docs/index.html (single-file HTML artifact)
- docs/CNAME (custom domain config)
- GitHub Pages (or other static host), optionally a CDN in front (e.g., Cloudflare)
##### External Services / Dependencies (orange)
- npm registry (fetch redoc/redocly and other deps)
- GitHub (repo + issues, PRs)
##### Consumers (grey)
- Developers viewing dev.splitwise.com
- API integrators using the docs
- Versioning/branches (how multiple versions of API could be handled)
- Automated validation steps (OpenAPI validation/linting)
- Publishing step to a package registry or different hosting

- Developer (author) → modifies source files (paths/, schemas/, splitwise.yaml).
- Local workflow:
- Developer → npm run serve → local dev server (redoc) → renders docs from source → developer views in browser.
- Live-reload feedback loop: change source → build toolchain regenerates → dev server serves updated docs.
- Build/CI workflow:
- Git push → CI (.travis.yml) triggers → runs npm install (→ npm registry) → runs linters/validators (optional) → npm run build → produces docs/index.html.
- CI → pushes artifact to GitHub Pages (docs folder) or deploys to host.
- Hosting/delivery:
- GitHub Pages / hosting serves docs/index.html via docs/CNAME (custom domain).
- Browser/Developer (end-user) requests docs → served from GitHub Pages/CDN → consumes content.
- External dependencies:
- Build step pulls packages from npm registry.
- Redocly used to render OpenAPI; might call its tooling locally (or API if using hosted services).

Architectural patterns & design principles to call out
- Content-as-code: the API docs are authored in YAML files in source control (single source of truth).
- Static site generation: source -> build -> static artifact (zero-dependency HTML).
- Schema-driven documentation: API surface and models are generated from OpenAPI schemas and paths.
- Single artifact deployment: a compiled self-contained HTML file (docs/index.html) can be deployed anywhere static HTML is served.
- Separation of concerns: authoring (source files) is distinct from rendering/build (toolchain) and delivery (hosting).
- Extensibility points: adding new paths/schemas; adding lint rules or CI checks; versioning or multi-version docs can be introduced.

- OpenAPI v3 (splitwise.yaml, paths/, schemas/)
- Redoc / Redocly (rendering tool)
- Node / npm (package.json scripts)
- GitHub (repo, issues, PRs)
- GitHub Pages (docs/ hosting) or alternative static host
- CI system (.travis.yml shown)
- npm registry (external dependency source)

##### Logical/Conceptual view (keep simple)
- Source → Build → Host → Consumer
##### Development workflow view
- Developer editing local files → local dev server → browser.
- Live reload loop.
##### CI/CD & Deployment view
- Git push → CI job → build artifacts → GitHub Pages (docs/) → CDN → browser.
##### File-to-component mapping (detailed)
- Directories to components: paths/ → Endpoint definitions, schemas/ → Models, responses/ → Common responses.

- Blue for source/content (paths/, schemas/, splitwise.yaml)
- Green for build/tooling (npm, redoc)
- Cyan for CI/CD
- Purple for hosting/delivery
- Orange for external dependencies (npm)
- Grey for consumers/users
- From developer → source (edit)
- From source → build tools (serve/build)
- From build → artifact (docs/index.html)
- From CI → build & publish → hosting
- From browser → hosting (request)
- From build → npm registry (dependency fetch)

What to label in each component (recommended)
- For Source: list splitwise.yaml, paths/, schemas/, responses/, package.json
- For Build: "npm run serve" (local), "npm run build" (compile to docs/index.html), redoc/redocly rendering
- For CI: .travis.yml — steps (install, validate, build, deploy)
- For Hosting: docs/index.html (artifact), docs/CNAME (custom domain), GitHub Pages/CDN
- For External: npm registry, GitHub (repo)

- Linter/validator stage: OpenAPI lint → prevents bad merges
- Versioning: separate branch → different docs versions
- Analytics/tracking on docs site (if used)

- Clear component names and file/directory mappings
- Annotations for key files (.travis.yml, docs/CNAME, splitwise.yaml)
- External dependencies (npm registry) and services (GitHub, GitHub Pages)
- Single-source-of-truth nature of splitwise.yaml + paths + schemas

- Be explicit about the source files that drive the site — the most valuable clarity for maintainers is exactly which files are authoritative (splitwise.yaml, paths/, schemas/).
- Validation & CI safeguards as first-class components (OpenAPI linting) — they’re important for doc correctness.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top: Author / Developer
    Dev(["Developer / Author"]):::actor

    %% Repository / Source (blue)
    subgraph "Repository / Authoring (Content-as-Code)" 
        direction TB
        SplitwiseYAML["splitwise.yaml\n(OpenAPI v3 entrypoint)"]:::source
        PathsDir["paths/\n(endpoint definitions)"]:::source
        SchemasDir["schemas/\n(models & sub-schemas)"]:::source
        ExpenseSubSchemas["schemas/expense/\n(expense sub-schemas)"]:::source
        ResponsesDir["responses/\n(shared responses/errors)"]:::source
        DocsDir["docs/\n(static assets & built output)"]:::artifact
        PackageJSON["package.json\n(npm scripts & deps)"]:::source
        GitRepoFiles["repo files\nREADME.md, .gitignore, CODE_OF_CONDUCT.md"]:::repo
    end

    %% Local Development / Build Toolchain (green)
    subgraph "Local Development & Build Toolchain"
        direction TB
        NPM["npm\n(runs scripts: serve, build)"]:::build
        Redoc["Redoc / Redocly\n(OpenAPI renderer)"]:::build
        LocalServer["Local Dev Server\n(npm run serve)\nlive-reload"]:::devserver
        BuildCmd["Build: npm run build\n(compiles to docs/index.html)"]:::build
        Linter["OpenAPI Linter / Validator\n(optional)"]:::build
    end

    %% CI/CD (cyan)
    subgraph "CI / CD (Automated)" 
        direction TB
        Travis[".travis.yml\n(CI config)"]:::ci
        CIJob["CI Job\ninstall→validate→build→deploy"]:::ci
    end

    %% Hosting / Artifact (purple)
    subgraph "Hosting / Delivery"
        direction TB
        Artifact["docs/index.html\n(single-file static artifact)"]:::artifact
        CNAME["docs/CNAME\n(custom domain)"]:::artifact
        GitHubPages["GitHub Pages\n(static host)"]:::host
        CDN["CDN (optional)\n(e.g., Cloudflare)"]:::host
    end

    %% External Services (orange)
    subgraph "External Services & Dependencies"
        direction TB
        NPMRegistry["npm Registry\n(fetch packages)"]:::external
        GitHub["GitHub\n(repo, PRs, issues)"]:::external
    end

    %% Consumers (grey)
    Consumers(["Developers / API Integrators\n(view docs via browser)"]):::consumer

    %% Vertical layout connections (top-down)
    Dev -->|"edit"| SplitwiseYAML
    Dev -->|"edit"| PathsDir
    Dev -->|"edit"| SchemasDir
    Dev -->|"edit"| ResponsesDir
    Dev -->|"edit"| PackageJSON

    %% Source composition
    SplitwiseYAML -->|"references/includes"| PathsDir
    SplitwiseYAML -->|"references/includes"| SchemasDir
    SchemasDir -->|"contains"| ExpenseSubSchemas
    SplitwiseYAML -->|"references"| ResponsesDir

    %% Local dev flow
    SplitwiseYAML -->|"serve input"| NPM
    PathsDir -->|"serve input"| NPM
    SchemasDir -->|"serve input"| NPM
    ResponsesDir -->|"serve input"| NPM
    PackageJSON -->|"scripts"| NPM
    NPM -->|"invokes"| Redoc
    Redoc -->|"renders"| LocalServer
    LocalServer -->|"serves"| Dev
    LocalServer -->|"live-reload"| Dev

    %% Build flow (local or CI)
    NPM -->|"npm run build"| BuildCmd
    Redoc -->|"renders static"| BuildCmd
    Linter -->|"validate"| BuildCmd

    %% Build produces artifact in repo docs/
    BuildCmd -->|"outputs"| DocsDir
    DocsDir -->|"contains"| Artifact
    DocsDir -->|"contains"| CNAME

    %% CI/CD flow
    GitHub -->|"push/PR triggers"| Travis
    Travis -->|"runs"| CIJob
    CIJob -->|"runs npm install(fetch deps)"| NPMRegistry
    CIJob -->|"runs npm scripts"| BuildCmd
    CIJob -->|"publishes docs to"| GitHubPages

    %% Hosting / delivery
    DocsDir -->|"deployed to"| GitHubPages
    GitHubPages -->|"optionally fronted by"| CDN
    CDN -->|"serves"| Consumers
    GitHubPages -->|"serves"| Consumers

    %% Repo collaboration
    Dev -->|"push/PR"| GitHub
    GitHub -->|"stores source"| SplitwiseYAML
    GitHub -->|"stores source"| PathsDir
    GitHub -->|"stores source"| SchemasDir
    GitHub -->|"stores source"| ResponsesDir
    GitHub -->|"stores source"| PackageJSON
    GitHub -->|"stores CI config"| Travis
    GitHub -->|"stores docs artifact (docs/)"| DocsDir

    %% External dependencies used during build
    PackageJSON -->|"declares deps"| NPMRegistry
    PackageJSON -->|"package-lock"| NPMRegistry

    %% Optional validation/PR preview (dashed)
    PRPreview["PR Preview (optional)\n(Netlify/preview)"]:::optional
    GitHub -->|"optional preview"| PRPreview
    PRPreview -->|"renders from branch"| Consumers

    %% Click events mapping to file paths (component_mapping)
    click SplitwiseYAML "https://github.com/splitwise/api-docs/blob/main/splitwise.yaml"
    click PathsDir "https://github.com/splitwise/api-docs/tree/main/paths/"
    click SchemasDir "https://github.com/splitwise/api-docs/tree/main/schemas/"
    click ExpenseSubSchemas "https://github.com/splitwise/api-docs/tree/main/schemas/expense/"
    click ResponsesDir "https://github.com/splitwise/api-docs/tree/main/responses/"
    click PackageJSON "https://github.com/splitwise/api-docs/blob/main/package.json"
    click NPM "https://github.com/splitwise/api-docs/blob/main/package.json"
    click LocalServer "https://github.com/splitwise/api-docs/blob/main/package.json"
    click BuildCmd "https://github.com/splitwise/api-docs/blob/main/package.json"
    click Artifact "https://github.com/splitwise/api-docs/blob/main/docs/index.html"
    click CNAME "https://github.com/splitwise/api-docs/tree/main/docs/CNAME"
    click Travis "https://github.com/splitwise/api-docs/blob/main/.travis.yml"
    click GitRepoFiles "https://github.com/splitwise/api-docs/blob/main/README.md"

    %% Styles / classes
    classDef source fill:#D6E9FF,stroke:#2B6CB0,stroke-width:1px,color:#0B3B67
    classDef artifact fill:#F3E8FF,stroke:#6B21A8,stroke-width:1px,color:#3F0F5F
    classDef build fill:#DFF6E6,stroke:#15803D,stroke-width:1px,color:#064E3B
    classDef devserver fill:#E6FFFA,stroke:#065F46,stroke-width:1px,color:#064E3B
    classDef ci fill:#E6F7FF,stroke:#0EA5E9,stroke-width:1px,color:#014F86
    classDef host fill:#F5F3FF,stroke:#7C3AED,stroke-width:1px,color:#3C1361
    classDef external fill:#FFF4E6,stroke:#D97706,stroke-width:1px,color:#7C2D12
    classDef consumer fill:#F3F4F6,stroke:#374151,stroke-width:1px,color:#111827
    classDef actor fill:#EEF2FF,stroke:#4338CA,stroke-width:1px,color:#1E293B
    classDef repo fill:#EEF2FF,stroke:#374151,stroke-width:1px,color:#0F172A
    classDef optional fill:#FFFFFF,stroke:#94A3B8,stroke-width:1px,color:#475569,stroke-dasharray: 5 5

    %% Apply specific classes to nodes not covered above (ensure colors)
    class Dev actor
    class GitHub external
    class NPMRegistry external
    class GitRepoFiles repo
    class Travis ci
    class CIJob ci
    class Redoc build
    class Linter build
    class PRPreview optional

    %% Notes / Annotations
    note1["Architecture notes:\n- Content-as-code: splitwise.yaml + paths/ + schemas/\n- Static SSG: Redoc produces docs/index.html\n- CI builds & deploys to GitHub Pages (docs/)"]:::repo
    DocsDir --- note1

    %% Ensure vertical orientation by forcing TB in main graph
    style Dev stroke-width:1px
    style SplitwiseYAML stroke-width:1px
    style PathsDir stroke-width:1px
    style SchemasDir stroke-width:1px
    style ResponsesDir stroke-width:1px
    style PackageJSON stroke-width:1px
    style NPM stroke-width:1px
    style Redoc stroke-width:1px
    style LocalServer stroke-width:1px
    style BuildCmd stroke-width:1px
    style Travis stroke-width:1px
    style GitHubPages stroke-width:1px
    style Artifact stroke-width:1px
```
