Skip to content

Commit 22847f4

Browse files
committed
update readme
1 parent 3f61407 commit 22847f4

File tree

1 file changed

+89
-20
lines changed

1 file changed

+89
-20
lines changed

README.md

Lines changed: 89 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
# precursor
1+
## The Pitch
22

3-
## Usage
3+
[Precursor](https://precursorapp.com) is the best way to collaborate on early prototypes with your team. Start every project with a new Precursor doc, share the link with your team, hit the speaker in the lower right to share your audio, and start sketching out your ideas. It's better than Sketch, Skype, and Slack put together.
44

5-
Fetch the Om source, which is installed as a submodule (in yaks/om):
5+
Check the [How to](https://precursorapp.com/document/How-to-17592197661008) doc to learn about some of Precursor's features.
6+
7+
## This is the code that runs Precursor
8+
9+
The Precursor founders, [Danny](https://twitter.com/dannykingme) and [Daniel](https://twitter.com/danielwoelfel), have generously released made the Precursor code open to the public. Precursor is an excellent resource if you're interested in Clojure, ClojureScript, Datomic, advanced CSS, or just how to put together a modern web app.
10+
11+
## Setting up your own instance
12+
13+
If you're a company that wants to run Precursor on your own hardware, please contact [Daniel](mailto:[email protected]) for help getting set up. We've made some effort to allow anyone to spin up their own Precursor instance, but there are still some roadblocks to work around.
14+
15+
## Contributing
16+
17+
We're still working out requirements for this. There will likely be a contributor's agreement. Please follow [@precursorapp](https://twitter.com/precursorapp) for updates.
18+
19+
## Development Requirements
20+
21+
### Frontend
22+
23+
Fetch our fork of Om, which is installed as a submodule (in yaks/om):
624

725
```
826
git submodule update --init
@@ -14,43 +32,94 @@ Install node dependencies (requires a recent version of node):
1432
npm install
1533
```
1634

17-
Download datomic from here https://my.datomic.com/downloads/free
18-
19-
unzip it and from within the directory run
35+
Compile the frontend clojurescript assets:
2036

2137
```
22-
bin/transactor config/samples/free-transactor-template.properties
38+
lein clean
39+
lein figwheel dev
2340
```
2441

25-
Start the server:
42+
### Database
43+
44+
Download Datomic Pro Starter Edition [https://my.datomic.com/starter](https://my.datomic.com/starter). You'll have to create a new account with Datomic to get a license key.
45+
46+
Unzip it Datomic and add your license key to `config/samples/dev-transactor-template.properties`
47+
48+
Start Datomic from within the datomic directory:
2649

2750
```
28-
lein run
51+
bin/transactor config/samples/dev-transactor-template.properties
2952
```
3053

31-
That will start a server on port 8080 and start an nrepl on port 6005.
54+
### Webserver
3255

56+
First, create a secrets file. Unfortunately we can't share the development secrets.
3357

34-
Compile the frontend clojurescript assets:
58+
Copy `pc.profile/ProfileSchema` into a new file, `resources/secrets/my-secrets-file.edn`.
59+
60+
Replace the values, filling in the fields with proper values. This part is not well-tested. You can try putting dummy values for most things. Please open issues on GitHub if you run into problems. PRs to simplify this process are very welcome.
61+
62+
Then encrypt the file using gpg with a symmetrical passphrase:
3563

3664
```
37-
lein clean
38-
lein figwheel dev
65+
gpg --armor --batch --symmetric --output my-secrets-file.edn.gpg my-secrets-file.edn
3966
```
4067

41-
Then go to [http://localhost:8080](http://localhost:8080)
42-
43-
### Browser REPL
68+
Enter your passphrase at the prompt (I've used "hello" as an example).
4469

45-
nrepl in to the nrepl server and run:
70+
Start the webserver:
4671

4772
```
48-
(pc.utils/connect-browser-weasel)
73+
GPG_PASSPHRASE='hello' PROFILE_SOURCE='secrets/my-secrets-file.edn.gpg' lein run
4974
```
5075

51-
Then reload the app.
76+
Now you should have a server running on port 8080 and start an nrepl server on port 6005.
77+
78+
Go to [http://localhost:8080](http://localhost:8080). If you see the app, everything worked. If not, check the output of `lein run` for errors.
79+
80+
## Project layout
81+
82+
### Backend
83+
84+
Precursor's infrastructure is laid out in this doc [https://precursor.precursorapp.com/document/Backend-Infrastructure-17592197950857](https://precursor.precursorapp.com/document/Backend-Infrastructure-17592197950857)
85+
86+
`src/pc/init.clj` is the entry point that sets up all of the server's state
87+
88+
`src/pc/views/` contains HTML generated by the backend. This is where the blog, admin pages, and the bootstrap HTML for the frontend live.
89+
90+
`src/pc/models/` contains the very light layer for fetching, creating, and updating Precursor's data abstractions. We decided to stay as close to the Datomic representation as possible, and this has worked very well for us. In general, Precursor's philosophy is to use abstractions sparingly because [abstractions are hard](https://www.amazon.com/gp/product/B00DD6YDFG). Bad abstractions are usually much worse than too few abstractions.
91+
92+
`src/pc/http/` contains the code that handles web requests lives here, except for the code that actually sets up the http server, which lives at `src/pc/server.clj`.
93+
94+
`src/pc/http/sente.clj` is a poorly-named file (Precursor switched from Sente to [Talaria](https://github.com/dwwoelfel/talaria)) that handles realtime messages to the browser over websockets. Ideally, it would be split into multiple smaller files. You can see a better approach in `src/pc/http/issues.clj`.
95+
96+
There is more, but those are the main pieces.
97+
98+
### Frontend
99+
100+
The frontend is very similar to [CircleCI's open-source frontend](https://github.com/circleci/frontend). I'd recommend watching Brandon Bloom's Clojure/West talk [Building CircleCI's Frontend with Om](https://www.youtube.com/watch?v=LNtQPSUi1iQ), for a quick overview.
101+
102+
`src-cljs/frontend/core.cljs` is the entry point.
103+
104+
`src-cljs/frontend/components/` contains all of the view code.
105+
106+
`src-cljs/frontend/controllers/` contains all of the code that changes state.
107+
108+
There is more, but those are the main pieces.
109+
110+
### Notable libraries/software
111+
112+
Database is Datomic, we've been very happy with it in conjunction with [Datascript](https://github.com/tonsky/datascript). I can't imagine building Precursor's realtime features without it. Some of the more advanced features we had planned, like forking and infinite undo would be much harder without it.
113+
114+
HTTP server is Immutant. We have found it very stable. We switched from http-kit, which was also pretty good, but doesn't support features needed to implement back pressure.
115+
116+
We manage http connections with [Talaria](https://github.com/dwwoelfel/talaria).
117+
118+
We use [Figwheel](https://github.com/bhauman/lein-figwheel) to speed up development on the frontend.
119+
120+
[Gumshoe](https://github.com/datodev/gumshoe) helps us to iterate faster on the backend.
52121

53-
### Troubleshooting
122+
## Troubleshooting
54123

55124
Try running:
56125

0 commit comments

Comments
 (0)