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

backend rewrite #453

Merged
merged 25 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
16a430f
add ratings & users
dlustre Jun 3, 2024
fa9add5
chore: change the port number
KatyH820 Jun 3, 2024
2e944f7
create a test context to streamline api tests
dlustre Jun 6, 2024
c02d11a
Merge branch 'main' into frontend-changes
dlustre Jun 6, 2024
9585ea0
upgrade to expo 51 and tamagui 1.100.0
dlustre Jun 7, 2024
d5b1389
add authstore to barrel file
dlustre Jun 7, 2024
4b26c6b
use workaround for hamburger menu since the double forwarded ref does…
dlustre Jun 7, 2024
5edcdd7
rewrite backend to create a simpler system to minimize processing on …
dlustre Jun 16, 2024
7716b7c
feat: pull to refresh functionality with RefreshControl
dlustre Jun 17, 2024
d633be4
typescript 5.4.3 -> 5.5.3
dlustre Jul 7, 2024
5162304
adjust naming and add comments in the api package
dlustre Jul 7, 2024
e678812
add docs, remove import cycle, simplify home logic
dlustre Aug 3, 2024
d2f0c0b
update api tests
dlustre Aug 3, 2024
08fff07
migrate to pnpm catalogs
dlustre Aug 3, 2024
b46de19
fix dep from react18 to react
dlustre Aug 3, 2024
8af1558
add a db diagram gen script
dlustre Aug 3, 2024
333f382
fix lockfile
dlustre Aug 3, 2024
371bd67
add type annotations for db entities
dlustre Aug 5, 2024
80da93a
add erd diagram to readme.md
dlustre Sep 29, 2024
a622246
* fix deps to make app functional
dlustre Sep 29, 2024
8830c95
Merge branch 'main' into frontend-changes
dlustre Nov 5, 2024
2340e92
fix lockfile
dlustre Nov 5, 2024
87dc1ac
update schema based on api change (caloriesfromfat was removed)
dlustre Nov 13, 2024
7f37142
add utcToPacific()
dlustre Nov 13, 2024
0ff41e7
update diagram
dlustre Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DATABASE_URL="postgres://admin:admin@localhost:5433/zotmeal"
DATABASE_URL="postgres://admin:admin@localhost:5434/zotmeal"
55 changes: 41 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
# ZotMeal

# About
<pre style="color: green;">
__/\\\\\\\\\\\\\\\______________________________/\\\\____________/\\\\________________________________/\\\\\\____
_\////////////\\\______________________________\/\\\\\\________/\\\\\\_______________________________\////\\\____
___________/\\\/_____________________/\\\______\/\\\//\\\____/\\\//\\\__________________________________\/\\\____
_________/\\\/_________/\\\\\_____/\\\\\\\\\\\_\/\\\\///\\\/\\\/_\/\\\_____/\\\\\\\\___/\\\\\\\\\_______\/\\\____
_______/\\\/_________/\\\///\\\__\////\\\////__\/\\\__\///\\\/___\/\\\___/\\\/////\\\_\////////\\\______\/\\\____
_____/\\\/__________/\\\__\//\\\____\/\\\______\/\\\____\///_____\/\\\__/\\\\\\\\\\\____/\\\\\\\\\\_____\/\\\____
___/\\\/___________\//\\\__/\\\_____\/\\\_/\\__\/\\\_____________\/\\\_\//\\///////____/\\\/////\\\_____\/\\\____
__/\\\\\\\\\\\\\\\__\///\\\\\/______\//\\\\\___\/\\\_____________\/\\\__\//\\\\\\\\\\_\//\\\\\\\\/\\__/\\\\\\\\\_
_\///////////////_____\/////_________\/////____\///______________\///____\//////////___\////////\//__\/////////__
</pre>

## About

ZotMeal is a cross-platform React Native Expo application.
A summary of the libraries we use are listed below.

## Technology

### Web/Mobile Application
### Frontend

- [Expo](https://expo.dev) - Universal framework for React Native.
- [Tamagui](https://tamagui.dev/) - UI component library for React Native.
- [Tamagui](https://tamagui.dev/) - Universal UI component library for React Native.

### Backend

- [Drizzle](https://drizzle.dev/) - ORM for Postgres.
- [AWS](https://aws.amazon.com/) - RDS and Lambda.
- [Serverless Framework](https://www.serverless.com/) - Framework for cloud resources such as AWS Lambda.
- [tRPC](https://trpc.io/) - Typesafe RPCs.

# Getting Started
### Backend ERD Diagram

![ERD Diagram](/packages/db/diagram/erd.svg)

## Pre-requisites
## Getting Started

### Pre-requisites

1. Install `Node.js`. This allows you to run JavaScript on your computer (outside of a browser).
This is best done with a version manager that allows you to easily switch between
Expand All @@ -35,37 +56,43 @@ A summary of the libraries we use are listed below.
It's responsible for installing, uninstalling, and keeping track of the app's dependencies.
`npm install --global pnpm`

3. Make sure to have `docker` installed, which will allow you to run the local postgres database
required for backend functions. You can install it from [the official website here](https://www.docker.com/get-started/).
3. Make sure to have `docker` installed, which can be installed from [the official website](https://www.docker.com/get-started/). It will allow you to
- run the local postgres database required for backend functions.
- run backend tests that rely on Testcontainers.

## Developing
### Developing

1. Clone the ZotMeal repository or your fork.
`git clone https://github.com/icssc/ZotMeal.git`

2. Change your node version to the one specified in .nvmrc
`nvm use`
`nvm use` or `fnm use`
3. Navigate to the root directory and install the dependencies.
`cd ZotMeal && pnpm install`

4. To start a local Postgres container database run the `docker compose up` in the root directory.
This will automatically set up and run a test database using docker.

5. Create a .env based on the example given in `.env.development`

6. Run `pnpm db:push` to push the schema to the docker database.

7. Start the local development servers for expo and server with `pnpm dev`.
6. Run `pnpm db:push` to push the schema to the docker database.

7. Start local development by running `pnpm dev` in `/apps/expo` and `pnpm dev` in `/apps/server` (or `turbo dev` in the root directory).
The tRPC procedures are available on <http://localhost:3000/><router.procedure\>?input={field: value}

```sh
# example
http://localhost:3000/events.get
```

8. View the local website at <http://localhost:8081> and/or with the [Expo Go mobile app](https://expo.dev/client).
As you make changes to the Expo application, those changes will be automatically
reflected on the local website as well as the mobile app.

## Testing
### Testing

Run `turbo test` at the root of the project.

## Adding Workspaces
### Adding Workspaces

To add a new package run `turbo gen workspace` and follow the prompts
32 changes: 19 additions & 13 deletions apps/expo/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import type { ExpoConfig } from "expo/config";
import type { ConfigContext, ExpoConfig } from "expo/config";

const defineConfig = (): ExpoConfig => ({
name: "expo",
slug: "expo",
scheme: "expo",
const image = "./assets/zotmeal.png";
const name = "ZotMeal";
const backgroundColor = "#161B22";

export default ({ config }: ConfigContext): ExpoConfig => ({
...config,
name,
slug: name.toLowerCase(),
scheme: name.toLowerCase(),
version: "0.1.0",
orientation: "portrait",
icon: "./assets/icon.png",
icon: image,
userInterfaceStyle: "automatic",
splash: {
image: "./assets/icon.png",
image,
resizeMode: "contain",
backgroundColor: "#1F104A",
backgroundColor,
},
updates: {
fallbackToCacheTimeout: 0,
Expand All @@ -24,10 +29,13 @@ const defineConfig = (): ExpoConfig => ({
android: {
package: "your.bundle.identifier",
adaptiveIcon: {
foregroundImage: "./assets/icon.png",
backgroundColor: "#1F104A",
foregroundImage: image,
backgroundColor,
},
},
web: {
favicon: image,
},
extra: {
eas: {
projectId: "e5b5d2cd-098b-4fe4-85ed-ac05e395552d", // dennis' project id for now
Expand All @@ -38,7 +46,5 @@ const defineConfig = (): ExpoConfig => ({
tsconfigPaths: true,
typedRoutes: true,
},
plugins: ["expo-router"],
plugins: ["expo-router", "expo-font"],
});

export default defineConfig;
Binary file added apps/expo/assets/anteatery.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/expo/assets/brandywine.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/expo/assets/zotmeal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/expo/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
presets: ["babel-preset-expo", "@babel/preset-typescript"],
plugins: [
[
"@tamagui/babel-plugin",
Expand Down
121 changes: 59 additions & 62 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,67 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@clerk/clerk-expo": "^1.1.4",
"@expo/metro-config": "^0.17.6",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-community/datetimepicker": "7.6.1",
"@react-native-picker/picker": "2.6.1",
"@react-navigation/drawer": "^6.6.11",
"@rehookify/datepicker": "^6.6.1",
"@shopify/flash-list": "1.6.3",
"@tamagui/babel-plugin": "^1.94.4",
"@tamagui/config": "^1.94.4",
"@tamagui/lucide-icons": "^1.94.4",
"@tamagui/toast": "^1.94.4",
"@tanstack/react-query": "^5.25.0",
"@trpc/client": "11.0.0-rc.330",
"@trpc/react-query": "11.0.0-rc.330",
"@trpc/server": "11.0.0-rc.330",
"@zotmeal/api": "workspace:^",
"@zotmeal/db": "workspace:^",
"@zotmeal/utils": "workspace:^",
"burnt": "^0.12.2",
"expo": "~50.0.8",
"expo-constants": "~15.4.5",
"expo-font": "^11.10.3",
"expo-linear-gradient": "~12.7.2",
"expo-linking": "~6.2.2",
"expo-router": "~3.4.8",
"expo-secure-store": "^13.0.1",
"expo-splash-screen": "~0.26.4",
"expo-status-bar": "~1.11.1",
"react": "18.2.0",
"react-datepicker": "^6.9.0",
"react-dom": "18.2.0",
"react-native": "~0.73.6",
"react-native-css-interop": "~0.0.34",
"react-native-gesture-handler": "~2.16.0",
"react-native-reanimated": "~3.8.1",
"react-native-safe-area-context": "~4.9.0",
"react-native-screens": "~3.30.1",
"react-native-svg": "^15.1.0",
"superjson": "2.2.1",
"tamagui": "^1.94.4",
"zod": "^3.22.4",
"zustand": "^4.5.2"
"@clerk/clerk-expo": "catalog:",
"@expo/metro-config": "catalog:",
"@react-native-async-storage/async-storage": "catalog:",
"@react-native-community/datetimepicker": "catalog:",
"@react-native-picker/picker": "catalog:",
"@react-navigation/drawer": "catalog:",
"@rehookify/datepicker": "catalog:",
"@shopify/flash-list": "catalog:",
"@tamagui/babel-plugin": "catalog:tamagui1",
"@tamagui/config": "catalog:tamagui1",
"@tamagui/lucide-icons": "catalog:tamagui1",
"@tamagui/toast": "catalog:tamagui1",
"@tanstack/react-query": "catalog:",
"@trpc/client": "catalog:",
"@trpc/react-query": "catalog:",
"@trpc/server": "catalog:",
"@zotmeal/api": "workspace:*",
"burnt": "catalog:",
"date-fns": "catalog:",
"expo": "catalog:",
"expo-constants": "catalog:",
"expo-font": "catalog:",
"expo-linear-gradient": "catalog:",
"expo-linking": "catalog:",
"expo-router": "catalog:",
"expo-secure-store": "catalog:",
"expo-splash-screen": "catalog:",
"expo-status-bar": "catalog:",
"react": "catalog:react18",
"react-datepicker": "catalog:",
"react-native": "catalog:",
"react-native-css-interop": "catalog:",
"react-native-gesture-handler": "catalog:",
"react-native-reanimated": "catalog:",
"react-native-safe-area-context": "catalog:",
"react-native-screens": "catalog:",
"react-native-svg": "catalog:",
"superjson": "catalog:",
"tamagui": "catalog:tamagui1",
"zod": "catalog:",
"zustand": "catalog:"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-typescript": "^7.24.6",
"@babel/runtime": "^7.24.0",
"@jest/globals": "^29.7.0",
"@testing-library/react-native": "^12.5.1",
"@types/react-datepicker": "^6.2.0",
"@zotmeal/eslint-config": "workspace:^0.2.0",
"@zotmeal/prettier-config": "workspace:^0.1.0",
"@zotmeal/tailwind-config": "workspace:^0.1.0",
"@babel/core": "catalog:",
"@babel/preset-env": "catalog:",
"@babel/preset-typescript": "catalog:",
"@babel/runtime": "catalog:",
"@jest/globals": "catalog:",
"@testing-library/react-native": "catalog:",
"@types/react-datepicker": "catalog:",
"@zotmeal/eslint-config": "workspace:*",
"@zotmeal/prettier-config": "workspace:*",
"@zotmeal/tailwind-config": "workspace:*",
"@zotmeal/tsconfig": "workspace:^0.1.0",
"eslint": "^8.57.0",
"jest": "^29.7.0",
"jest-expo": "^50.0.4",
"prettier": "^3.2.5",
"react-test-renderer": "^18.2.0",
"tailwindcss": "^3.4.3",
"ts-jest": "^29.1.4",
"typescript": "^5.4.3"
"eslint": "catalog:",
"jest": "catalog:",
"jest-expo": "catalog:",
"prettier": "catalog:",
"tailwindcss": "catalog:",
"ts-jest": "catalog:",
"typescript": "catalog:"
},
"eslintConfig": {
"root": true,
Expand All @@ -93,4 +90,4 @@
]
},
"prettier": "@zotmeal/prettier-config"
}
}
3 changes: 2 additions & 1 deletion apps/expo/src/__tests__/app.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import renderer from "react-test-renderer";
import { Logo } from "~/components";

import { Logo } from "~/components/ui";

describe("<App />", () => {
it("has 1 child", () => {
Expand Down
Loading
Loading