Skip to content

Commit 24d21ff

Browse files
committed
update readme
1 parent 3f61407 commit 24d21ff

File tree

1 file changed

+88
-19
lines changed

1 file changed

+88
-19
lines changed

README.md

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
11
# precursor
22

3-
## Usage
3+
## The Pitch
44

5-
Fetch the Om source, which is installed as a submodule (in yaks/om):
5+
[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.
6+
7+
Check the [How to](https://precursorapp.com/document/How-to-17592197661008) doc to learn about some of Precursor's features.
8+
9+
## This is the code that runs Precursor
10+
11+
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.
12+
13+
## Setting up your own instance
14+
15+
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.
16+
17+
## Contributing
18+
19+
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.
20+
21+
## Development Requirements
22+
23+
### Frontend
24+
25+
Fetch our fork of Om, which is installed as a submodule (in yaks/om):
626

727
```
828
git submodule update --init
@@ -14,43 +34,92 @@ Install node dependencies (requires a recent version of node):
1434
npm install
1535
```
1636

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

2139
```
22-
bin/transactor config/samples/free-transactor-template.properties
40+
lein clean
41+
lein figwheel dev
2342
```
2443

25-
Start the server:
44+
### Database
45+
46+
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.
47+
48+
Unzip it Datomic and add your license key to `config/samples/dev-transactor-template.properties`
49+
50+
Start Datomic from within the datomic directory:
2651

2752
```
28-
lein run
53+
bin/transactor config/samples/dev-transactor-template.properties
2954
```
3055

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

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

34-
Compile the frontend clojurescript assets:
60+
Copy `pc.profile/ProfileSchema` into a new file, `resources/secrets/my-secrets-file.edn`.
61+
62+
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.
63+
64+
Then encrypt the file using gpg with a symmetrical passphrase:
3565

3666
```
37-
lein clean
38-
lein figwheel dev
67+
gpg --armor --batch --symmetric --output my-secrets-file.edn.gpg my-secrets-file.edn
3968
```
4069

41-
Then go to [http://localhost:8080](http://localhost:8080)
70+
Enter your passphrase at the prompt (I've used "hello" as an example).
4271

43-
### Browser REPL
44-
45-
nrepl in to the nrepl server and run:
72+
Start the webserver:
4673

4774
```
48-
(pc.utils/connect-browser-weasel)
75+
GPG_PASSPHRASE='hello' PROFILE_SOURCE='secrets/my-secrets-file.edn.gpg' lein run
4976
```
5077

51-
Then reload the app.
78+
Now you should have a server running on port 8080 and start an nrepl server on port 6005.
79+
80+
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.
81+
82+
## Project layout
83+
84+
### Backend
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)