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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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