Skip to content

Commit 6248901

Browse files
committed
Removing kulu-website and kulu-mobile
* They’ve been moved back to their individual repos * This repo now only contains contents from backend * This repo name should eventually be renamed to be called kulu-backend
1 parent 952bd6a commit 6248901

File tree

405 files changed

+158
-68721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+158
-68721
lines changed

backend/Procfile Procfile

File renamed without changes.

README.md

+139-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,144 @@
1-
# kulu
2-
Service and mobile app for handling corporate reimbursements
1+
# kulu-backend
32

4-
- The backend is written in clojure and can be found [here](https://github.com/nilenso/kulu/tree/readme/backend)
5-
- The rails front end can be found [here](https://github.com/nilenso/kulu/tree/master/website)
6-
- The android app can be found [here](https://github.com/nilenso/kulu/tree/master/android)
3+
The main backend service for the Kulu app.
74

8-
All the info on how to set up and get things started are mentioned in the readmes of the respective services.
5+
## Set up
96

10-
# Update
7+
* Clone the app
118

12-
Making this a monolith was a bad idea. We're planning to migrate these back into individual repos. Steps:
9+
* Create the secret config from the sample:
10+
```
11+
cp config/kulu-backend-secrets-sample.edn config/kulu-backend-secrets.edn
12+
```
13+
* Fill in the placeholder vals in the above file. Read on to learn
14+
more about our configuration management.
1315

14-
1. Remove `website` and `mobile` from this monolith repo
15-
2. Rename this repo to become the new kulu-backend
16-
3. Deprecate https://github.com/nilenso/kulu-backend
16+
* Ensure that you're running postgres 9.5 or 9.6 (postgres >=10 is not supported)
17+
* Set up dev and test dbs:
18+
```
19+
$ psql
20+
create database kulu_backend_dev;
21+
\c kulu_backend_dev
22+
create extension "uuid-ossp";
23+
24+
create database kulu_backend_test;
25+
\c kulu_backend_test
26+
create extension "uuid-ossp";
27+
```
28+
* `lein deps` to get all the dependencies
29+
* Migration script expects DATABASE_URL in the enviroment
30+
```
31+
DATABASE_URL=postgres://$USER\:@localhost:5432/kulu_backend_dev lein clj-sql-up migrate
32+
```
33+
34+
### Running
35+
36+
In dev, run `bin/server-start`. It sets up some needed env vars and
37+
starts the server with lein. Or you can directly run `lein run -m kulu-backend.web 3001
38+
` (takes defaults for the env vars).
39+
40+
Once started, visit [http://localhost:3001/](http://localhost:3001/)
41+
42+
#### In heroku
43+
44+
* Push to heroku with `git push heroku master`
45+
* Interact on
46+
[kulu-backend.herokuapp.com](https://kulu-backend.herokuapp.com).
47+
* To run migrations, `heroku run lein clj-sql-up migrate`
48+
49+
## Developer info
50+
51+
### Peculiarities in requests and responses
52+
53+
You may have noticed that our HTTP requests come in with
54+
`under_scored` params but everywhere inside the app we use the
55+
`kabab-case`. This is done with
56+
`kulu-backend.utils.api/idiomatize-keys` and it's friends:
57+
58+
+ On incoming HTTP requests (at the handler level) we convert params
59+
to the `kabab-case` (`dasherize` them).
60+
+ Once the response is ready, we convert the response body back to the
61+
`under_score` flavor.
62+
63+
See example [here](src/kulu_backend/handler.clj) and read the
64+
[code documentation here](src/kulu_backend/utils/api.clj) for more
65+
details.
66+
67+
Similarly, we apply the inverse transform (`under_scorize` on the way
68+
in, `dasherize` on the way out) while sending data to SQL.
69+
70+
### Configuration
71+
72+
We use [nomad](https://github.com/james-henderson/nomad) to read our
73+
app's configuration from edn files. The config related files are:
74+
75+
#### Database
76+
77+
In prod, we read the `DATABASE_URL` env var. The dev and test
78+
databases are specified in the config. In test, every DB command is
79+
run in a transaction and rolled back after the test, so we always a
80+
clean slate.
81+
82+
The connection string in test comes from Nomad configs
83+
84+
(expand further)
85+
86+
#### AWS
87+
88+
We use seperate IAM accounts for dev and prod (we stub out AWS usage
89+
in test).
90+
91+
See the AWS Console's IAM tab (for [email protected]) for the various
92+
IAM accounts we use. Similarly we have separate S3 buckets and SQS
93+
queues for dev/prod and IAM account's permissions make sure that the
94+
dev AWS IAM account can't read/write from the prod resources and vice-versa.
95+
96+
#### ElasticSearch
97+
98+
###### OS X
99+
+ `brew install elasticsearch`
100+
101+
+ Install the KOPF UI plugin to handle all ES administration: https://github.com/lmenezes/elasticsearch-kopf in `/usr/local/var/lib/elasticsearch/plugins`
102+
103+
+ `$ lein run -m kulu-backend.tasks setup dev` to migrate indices.
104+
105+
+ Run `elasticsearch`
106+
107+
###### Elsewhere
108+
109+
+ Go to http://www.elasticsearch.com/download/ and download the latest version of elasticsearch (assumingly as zip).
110+
111+
+ unzip it.
112+
113+
+ `chmod +x bin/elasticsearch`
114+
115+
+ `$ lein run -m kulu-backend.tasks setup dev` to migrate indices.
116+
117+
+ `bin/elasticsearch`
118+
119+
+ this starts a process that binds to port 9200.
120+
121+
+ `curl -X GET http://localhost:9200/`
122+
123+
to get something like:
124+
125+
{
126+
"status" : 200,
127+
"name" : "Mop Man",
128+
"version" : {
129+
"number" : "1.3.4",
130+
"build_hash" : "a70f3ccb52200f8f2c87e9c370c6597448eb3e45",
131+
"build_timestamp" : "2014-09-30T09:07:17Z",
132+
"build_snapshot" : false,
133+
"lucene_version" : "4.9"
134+
},
135+
"tagline" : "You Know, for Search"
136+
}
137+
138+
+ Or install the KOPF UI in your plugins directory from: https://github.com/lmenezes/elasticsearch-kopf
139+
140+
### Tests
141+
142+
Run `lein test` to run tests. It will automatically set the `NOMAD_ENV=test` and pick up the right configuration.
143+
144+
Make sure you run `elasticsearch` before running tests, as some of the tests in the suite test end-to-end making real calls to ES on a test index.

android/.gitignore

-34
This file was deleted.

android/README.md

-10
This file was deleted.

android/app/.gitignore

-4
This file was deleted.

android/app/app.iml

-108
This file was deleted.

android/app/build.gradle

-36
This file was deleted.

android/app/libs/Simpl3r-1.2.0.jar

-12.2 KB
Binary file not shown.
-3.28 MB
Binary file not shown.
-348 KB
Binary file not shown.

android/app/libs/commons-io-2.4.jar

-181 KB
Binary file not shown.

android/app/libs/gson-2.3.1.jar

-206 KB
Binary file not shown.

android/app/libs/okhttp-2.0.0.jar

-255 KB
Binary file not shown.

android/app/libs/okio-1.0.1.jar

-51.6 KB
Binary file not shown.

android/app/libs/realm-0.77.0.jar

-2.9 MB
Binary file not shown.

0 commit comments

Comments
 (0)