Skip to content

Commit 5b10130

Browse files
committed
Start adding documentation
1 parent 6fa1294 commit 5b10130

1 file changed

Lines changed: 102 additions & 1 deletion

File tree

README.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,105 @@
22

33
# galc-api
44

5-
An API for the UC Berkeley Library [Graphic Arts Loan Collection](https://galc.lib.berkeley.edu/).
5+
An API for the UC Berkeley Library [Graphic Arts Loan
6+
Collection](https://www.lib.berkeley.edu/visit/morrison/galc).
7+
8+
For the GALC user interface, see the [`galc-ui`](/BerkeleyLibrary/galc-ui)
9+
repository.
10+
11+
## Architecture
12+
13+
`galc-api` is by and large a conventional database-backed Rails
14+
[API-only application](https://guides.rubyonrails.org/api_app.html).
15+
Areas in which it deviates from typical Rails practice include
16+
authentication / authorization (which uses [JSON Web Tokens](https://jwt.io)
17+
rather than session cookies), JSON serialization (which follows the
18+
[JSON:API](https://jsonapi.org/) specification, rather than using Rails'
19+
default JSON serialization), and the handling of image files (which are
20+
managed on the filesystem rather than via ActiveStorage or similar
21+
mechanisms). Details on each of these areas are provided below.
22+
23+
### RESTful Endpoints
24+
25+
#### Persistent resources
26+
27+
The application provides RESTful endpoints for the following resources,
28+
represented by conventional ActiveRecord database models:
29+
30+
| Endpoint | Model | Description |
31+
|-------------|------------------------------------|---------------------------------------------------------|
32+
| `/items` | [`Item`](app/models/Item.rb) | Items (i.e. prints) in the GALC collection |
33+
| `/images` | [`Image`](app/models/Image.rb) | Images of prints for display in search results |
34+
| `/facets` | [`Facet`](app/models/Facet.rb) | Search facets (read-only) |
35+
| `/terms` | [`Term`](app/models/Term.rb) | Controlled vocabulary search terms (read-only) |
36+
| `/closures` | [`Closure`](app/models/Closure.rb) | Periods when the GALC collection is closed to checkouts |
37+
38+
Note that the `/items` endpoint accepts both faceted search terms
39+
and arbitrary keywords as `filter` parameters following the [JSON:API
40+
Filtering Recommentation](https://jsonapi.org/recommendations/#filtering),
41+
and also accepts pagination paramters following the [JSON:API pagination
42+
spec](https://jsonapi.org/format/#fetching-pagination).
43+
44+
#### Synthetic resources
45+
46+
In addition, the following endpoints appear as RESTful resources, but
47+
are not represented in the database:
48+
49+
| Endpoint | Description |
50+
|-----------------|-----------------------------------------------|
51+
| `/reservations` | Requests to reserve a GALC print (write-only) |
52+
| `/users` | Application users (current user only) |
53+
| `/build_info` | Build information (read only) |
54+
55+
##### Reservations
56+
57+
Clients can POST a request to create a reservation,
58+
which returns the created reservation as a JSON object. However,
59+
reservations are not stored in the databse; "creating" a reservation
60+
simply sends an email to the configured reservation email address
61+
(set via the `$RESERVE_EMAIL_TO` environment variable).
62+
63+
##### Users
64+
65+
Cross-site cookie issues prevent using a conventional Rails
66+
session to manage login state. Instead, authentication/authorization
67+
information is sent with each request via an encrypted
68+
[JSON Web Token](https://jwt.io) in the HTTP `Authorization` header.
69+
If this token is present, clients can GET the current user either by
70+
UID or by the special value `current` — decrypting the token and
71+
returning the user information as a JSON object. (Note that the UID
72+
is only accepted if it matches the ID encoded in the token.)
73+
74+
##### Build information
75+
76+
Build information ([`BuildInfo`](app/lib/build_info.rb)) is captured in
77+
environment variables during the Docker image build process, and returned
78+
by this endpoint in JSON format.
79+
80+
### Non-RESTful endpoints
81+
82+
In addition, the following non-RESTful endpoints are implemented by
83+
[`AuthController`](app/controllers/auth_controller.rb):
84+
85+
| Endpoint | Description |
86+
|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
87+
| `/auth/calnet/callback` | Callback URL for CalNet login | |
88+
| `/logout` | Target URL for redirecting to CalNet logout |
89+
| `/` | A static webpage providing the [`galc-ui`](/BerkeleyLibrary/galc-ui) interface for testing; enabled only when `$SERVE_TEST_UI` is set |
90+
91+
### Authentication and authorization
92+
93+
**TO DO**
94+
95+
### JSON serialization
96+
97+
**TO DO**
98+
99+
### Image file handling
100+
101+
**TO DO**
102+
103+
## Build, packaging, and deployment
104+
105+
**TO DO**
106+

0 commit comments

Comments
 (0)