Dudes of 708's knowledge base for getting started and tools we use
Back to homepage • software development guides
Congratulations! So you want to get involved in ChompChomp’s development. Your contributions will be greatly appreciated.
You’ll need the following already set up in order to follow the setup portion of this guide:
git
: You can follow the git setup guide in order to set up git.ChompChomp
repository.You can go the table of contents in order to jump to any section of setup.
Note: if you are a Linux user, you may have to access a NodeSource distribution. It is assumed that if you are a Linux user you know what you are doing.
Open a Terminal and run
npm i expo-cli --global
Log in to expo with the command:
expo login
This will bring up a page in your web browser where you can either login or create an account on Expo’s servers. Join the Dudes of 708 development team (owner: Gideon Tong).
If you have an Android device, jump to the Android device setup section. If you have an iOS device, jump to the iOS device setup section. You can set up both if you have both.
Optional Steps:
C:\Software\platform-tools
on Windows or /home/<username>/platform-tools
on macOS or Linux.cd
(change directory) command. For example, if I extracted it to C:\Software\platform-tools
, I would write cd C:\Software\platform-tools
.adb devices
on Windows or ./adb devices
for macOS and Linux computers.If you own a Mac, there are additional advanced setup steps you can take advantage of, but they will not be covered in this guide beacuse I don’t own a Mac. If you are a Mac user and would like to contribute usage of Xcode or other iOS debugging tools, by all means, please submit an improvement for this section.
If you already have an editor you like, jump to project structure.
I personally use VS Code, but I’m going to try to cover all the potential ways you may want to develop. If you don’t already use an editor, download VS Code and head on to the VS Code section
Otherwise, pick your editor of choice:
You can download VS Code at this link. Thankfully, because VS Code is designed as an Electron app, it provides Javascript/Typescript extensions, debugging, and IntelliSense out of the box. ChompChomp is written in pure Javascript with React extensions, and does not support Typescript at this time.
This is really all you need, but you should set up Expo Tools and React Native Tools (both are one click extensions to add) for your VS Code environment.
Next, proceed to setting up.
Why are you reading this if you already know your way around Vim? Set it up for JavaScript/TypeScript bindings and you’ll be fine. Next, proceed to setting up.
This isn’t actually a screenshot of the code, but this is Expo Snack.
Expo Snack runs in the browser and basically acts like a Repl.it, if you have used that before. It provides a way to develop and test without leaving your browser. You can access it here.
It provides all the libraries and tools built-in, and is a conveneint way to develop. It isn’t officially supported by ChompChomp but you are free to use this to develop if you wish to sync your changes to git
manually.
Next, proceed to setting up.
Xcode is the official code editor by Apple for Macs, and is only available for macOS. You can download it at this link. It is also the only way to self-compile the iOS version of ChompChomp, so you’ll need to follow this setup guide even if you don’t use Xcode normally so you can compile.
Download Xcode from the link above and run it. Apple will set up all the developer tools for you automatically. You’ll also need an Apple ID, which frankly is weird if you have a Mac but don’t have one.
Next, proceed to setting up.
ChompChomp
repository. If you don’t know how, please see the setting up git guide.Open Terminal or Command Prompt and navigate to the ChompChomp repository you cloned. Then run
npm ci
This process will take several minutes to complete if you’re running for the first time. If you need to update your packages, use the following command instead:
npm i
If you are curious how the files are laid out, please see file structure, or you can see the code structure if you want to get a sense of how the code is formatted so you can make similar contributions.
The project is broken up into a few important folders and files (you can click on the names of files and folders to view them):
assets
: Stores asset files, images, icons, and other such static files that remain largely unchangedcomponents
: Small Javascript files that may be used once or more than once, but do not represent an entire view
ErrorDialog.js
: Dialog box for errorsLoadingDialog.js
: Loading dialog boxOfflineBanner.js
: Banner that shows an alert if you are offlineSmallOfflineBanner.js
: Small offline banner for specific item adding screensStoreSelector.js
: The dialog box that allows you to select a storeUploadErrorDialog.js
: The dialog box that shows up when the upload failsconfig
: Config files for various parts of the appviews
: Different screens for the app
CameraScreen.js
: Screen for taking photosConfigScreen.js
: Screen for changing settingsHistoryScreen.js
: Screen for looking at your upload historyHomeScreen.js
: The home screenItemUploadScreen.js
: Screen to create a new item or add data about an existing itemQueueScreen.js
: Screen to check items you’ve yet to uploadQuickAddScreen.js
: Screen if you don’t want to add data while walking aroundScannerScreen.js
: Screen for scanning barcodesApp.js
: Main entrypoint of the app, defines the screens of the appapp.json
: App definition fileA quick overview of the way our code is structured:
Components appear in the components
folder and represent parts of views that may or may not be reused. This can include selection boxes, dialog boxes, repeated text input boxes, etc.
Views appear in the views
folder, and there is one file/function for every view that appears in the app. Each one is linked to the App.js
file.
The app stores a few pieces of information
Queue data is stored in the key queue
and is stored as a JSON string array. Each element is a JSON object containing several keys:
type
: One of new
, update
, or quick
. New items contain full information, updates contain only the barcode, store, and price, and quick items contain only barcode and images.payload
: The relevant payload to upload.An example is below:
[
{
"type": "new",
"payload": {
"date": "2021-04-18T22:34:11.088180+00:00",
"store": "7 West Los Angeles, CA",
"name": "String Cheese",
"price": "1.99",
"weight": "16",
"barcode": "01234567"
}
},
{
"type": "update",
"payload": {
"barcode": "87654321",
"store": "65 Danville, CA",
"date": "2021-04-19T22:34:29.089034+00:00",
"price": "2.99"
}
},
{
"type": "quick",
"payload": {
"barcode": "55555555",
"images": [
...
]
}
}
]
History data is stored in the key history
and is stored as a JSON string array. Each element is a string containing the name of the item uploaded to the database. If there is more than the maximum in the list, the oldest is pushed off the list (it behaves as a queue).
An example is below:
[
"String Cheese",
"Cheddar Cheese",
"Mozarella Cheese",
"American Cheese",
"Feta Cheese"
]
Use an editor of your choice to edit a file, and the commit it. If you don’t know how, see the guide to using git.
Run this command to start the development server:
expo start
Your changes are automatically built whenever you change the version number in app.json
. Simply bump the minor revision number by 1 and you’ll get a build back within the hour. Typically builds on the server take about 20-30 minutes for Android and 10-20 minutes for iOS. iOS builds are currently not supported by the ChompChomp development server, as you get a package back, so you’ll need to build iOS manually.
Step by step:
app.json
file.To build for iOS and test it on your device as a fully compiled app, head below to iOS Builds. To build it for Android instead, head below to Android Builds.
Warning: You can only build iOS builds on macOS.
Run the following command:
expo build:ios
This builds an IPA for distribution on Expo’s servers, which will take approximately 5-30 minutes. We do not currently have a macOS development server, and are looking to fundraise some money to host such a server.
You will be able to use this IPA provided you are either in the team (and have access to the development account), or you have your own development account.
Run the following command:
expo build:android -t apk
This builds an APK for distribution on Expo’s servers, which will take approximately 5-30 minutes. If you’d like to use the Dudes of 708 development server instead, please contact Gideon for the server information and additional setup instructions.
Upload the new build to the Dudes of 708 Google Drive in the format for iOS builds: ChompChomp-vX.X.X-archive.ipa
or for Android builds: ChompChomp-vX.X.X-signed.apk
. The build will be automatically deployed. Ensure you do not overwrite an existing file, because then the build will not be deployed.