# nside/sqlite2rest architecture

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

- Interactive diagram: https://gitdiagram.com/nside/sqlite2rest
- Repository: https://github.com/nside/sqlite2rest

## Overview

SQLite2REST turns an SQLite database into a Flask CRUD API and can generate an OpenAPI specification. The main workflow is: a developer starts the CLI server, the app inspects database tables and registers routes, and HTTP requests invoke database operations whose results are returned as JSON. The separate spec workflow reads table and column metadata to generate YAML. The graph follows the README and sampled runtime source; unsampled integrations and internal details are omitted.

Main entry points: [`sqlite2rest/routes.py`](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/routes.py) (CRUD routes), [`sqlite2rest/openapi.py`](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/openapi.py) (OpenAPI generator), [`sqlite2rest/database.py`](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/database.py) (Database access), [`sqlite2rest/__main__.py`](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/__main__.py) (CLI commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and app"]
  node_cli["CLI commands<br/>[__main__.py]"]
  node_app["App setup<br/>[app.py]"]
end

subgraph group_api["HTTP API"]
  node_routes["CRUD routes<br/>[routes.py]"]
  node_json["JSON responses<br/>[routes.py]"]
end

subgraph group_spec["API specification"]
  node_openapi["OpenAPI generator<br/>[openapi.py]"]
  node_yaml["OpenAPI YAML<br/>[openapi.py]"]
end

subgraph group_storage["SQLite access"]
  node_database["Database access<br/>[database.py]"]
end

node_developer(("Developer"))
node_sqlite[("SQLite database")]
node_client(("API client"))

node_developer -->|"runs command"| node_cli
node_cli -->|"starts server"| node_app
node_app -->|"discovers tables"| node_database
node_app -->|"registers routes"| node_routes
node_database -->|"queries and updates"| node_sqlite
node_client -->|"sends requests"| node_routes
node_routes -->|"runs CRUD"| node_database
node_routes -->|"requests spec"| node_openapi
node_openapi -->|"reads schema"| node_database
node_routes -->|"returns JSON"| node_json
node_json -->|"sends response"| node_client
node_cli -->|"generates spec"| node_openapi
node_openapi -->|"serializes spec"| node_yaml
node_yaml -->|"prints spec"| node_developer

click node_cli "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/__main__.py"
click node_app "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/app.py"
click node_routes "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/routes.py"
click node_openapi "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/openapi.py"
click node_database "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/database.py"
click node_json "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/routes.py"
click node_yaml "https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/openapi.py"

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_cli,node_app,node_client toneBlue
class node_routes,node_json,node_sqlite toneAmber
class node_openapi,node_yaml toneMint
class node_database toneRose
class node_developer toneIndigo
```

## Components

### Entry and app

- [CLI commands](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/__main__.py): `sqlite2rest/__main__.py`
- [App setup](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/app.py): `sqlite2rest/app.py`

### HTTP API

- [CRUD routes](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/routes.py): `sqlite2rest/routes.py`
- [JSON responses](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/routes.py): `sqlite2rest/routes.py`

### API specification

- [OpenAPI generator](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/openapi.py): `sqlite2rest/openapi.py`
- [OpenAPI YAML](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/openapi.py): `sqlite2rest/openapi.py`

### SQLite access

- [Database access](https://github.com/nside/sqlite2rest/blob/main/sqlite2rest/database.py): `sqlite2rest/database.py`

### Other components

- **Developer**
- **SQLite database**
- **API client**

## Connections

- Developer → CLI commands: runs command
- CLI commands → App setup: starts server
- App setup → Database access: discovers tables
- App setup → CRUD routes: registers routes
- Database access → SQLite database: queries and updates
- API client → CRUD routes: sends requests
- CRUD routes → Database access: runs CRUD
- CRUD routes → OpenAPI generator: requests spec
- OpenAPI generator → Database access: reads schema
- CRUD routes → JSON responses: returns JSON
- JSON responses → API client: sends response
- CLI commands → OpenAPI generator: generates spec
- OpenAPI generator → OpenAPI YAML: serializes spec
- OpenAPI YAML → Developer: prints spec
