Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a way to run Paper Playground without PostreSQL #239

Closed
jessegreenberg opened this issue Apr 29, 2024 · 4 comments
Closed

Figure out a way to run Paper Playground without PostreSQL #239

jessegreenberg opened this issue Apr 29, 2024 · 4 comments
Assignees

Comments

@jessegreenberg
Copy link
Contributor

We want to investigate running this project without a database. Though shared spaces wouldn't work, it would make it really easy for anyone to start creating projects with Creator/Paper Playground.

@jessegreenberg jessegreenberg self-assigned this Apr 29, 2024
@jessegreenberg
Copy link
Contributor Author

jessegreenberg commented Apr 30, 2024

Earlier, we discussed possibly using local storage for this or a server-side solution.

After thinking about this a bit more I think using the server is the best way to go.

  1. It will be quite a bit easier. If we do this all with local storage (in the front end client) we need to modify all usages of xhr to communicate with local storage instead of the server. If we use the server, we can just update the api file to serve from local files in a "local" mode. This means we only make changes to one file.
  2. It is probably better practice. This keeps the server/client (model/view) modularity. It puts less burden on the front end.
  3. Pre-populated projects/spaces/programs will be easier to put in. We can track them with git, and just put json files into the directory. A localStorage solution means things only get added/changed during runtime.

I wanted to note that its currently possible to use a local postgreSQL database to run paper playground. But switching to a JSON representation of saved projects/data on the server means that people will be able to run projects locally without setting up a database (very complicated and huge barrier to overcome).

@jessegreenberg
Copy link
Contributor Author

jessegreenberg commented Apr 30, 2024

This is likely the process:

  1. Add a mode to the .env file that makes the project run in "local" mode.
  2. In that mode, opt out of knex since we are going to use file handling instead.
  3. Update routes to use file handling instead of knex. Consider a service layer that performs operations on JSON files mimicking the database oprations.
  4. The save operations likely write directly to files instead of updating an in-memory state. This is more simple and paper playground doesn't need immediate persistence of changes.
  5. Other than the template files, saves should likely be excluded from git.

Consider a service layer that performs operations on JSON files mimicking the database oprations.

Brainstorming a path:
Create IDataService.js - an interface for querying the data with the api.
Create KnexDataService.js - An implementation of IDataService.js, using knex (as is currently done).
Create LocalFileDataService.js - An implementation of IDataService, using file IO to get the data in the same format.

The IDataService defines the signatures so we can confirm that the output is the same (I wish we had TypeScript for this).

@jessegreenberg
Copy link
Contributor Author

A branch was started for this called local-file-serving.

@jessegreenberg
Copy link
Contributor Author

local-file-serving was merged into main. So far it is working quite well! We will create new issues as problems come up, the bulk of the work is done. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant