Skip to content

Commit 6faafc6

Browse files
google-labs-jules[bot]DevasyDelinkelinpre-commit-ci[bot]
authored
feat: Add create and join group functionality (#93)
* This commit adds the ability for you to create new groups and join existing ones. - A "Create Group" modal has been added to the home screen. - A new "Join Group" screen has been created where you can enter a join code. - The groups list on the home screen automatically refreshes after a group is created or joined. * This commit introduces several improvements to the expense creation and group details screens based on your feedback. - **Equal Split Member Selection:** You can now select which members to include when splitting an expense equally. - **Optimized Settlements Summary:** The group details page now displays a summary of optimized settlements for you, showing who you need to pay and how much. - **Transaction-level Balance Display:** Each expense in the group details now shows your financial relationship to it (e.g., "You borrowed $30"). * This commit fixes a bug in the settlement summary on the Group Details page. The previous implementation did not correctly display the scenario where you are owed money. This has been corrected. The summary now shows: - What you owe to others. - What others owe to you. - A "settled up" message when there are no outstanding debts. * This commit introduces a new "Friends" page to the application. - A "Friends" tab has been added to the main navigation. - The new screen displays a list of friends (users from shared groups). - For each friend, it shows the net balance aggregated across all shared groups. - Each friend item can be expanded to show a breakdown of balances per group. - The client-side logic fetches all group data and calculates these balances. * This commit fixes a bug that caused the Friends page to crash. The error was a `TypeError` caused by incorrectly accessing the expenses array when calculating friend balances. This has been corrected. The client-side calculation logic is now more robust and handles cases where groups may not have any expenses. * This commit introduces a new "Account" page to the application. - An "Account" tab has been added to the main navigation. - The new screen displays user information and a list of options. - You can now edit your profile information (name). - The logout functionality is accessible from this page. - Placeholders are included for future features like email settings and feedback. * This commit enhances the UI by displaying group icons. - The groups list now shows an icon for each group, with a fallback to the group's first initial. - The group details screen also displays the icon in its header for a consistent user experience. * This commit adds a new GitHub Actions workflow to automatically build the Android APK for the frontend application. The workflow is triggered on push to the main branch and can also be run manually. It performs the following steps: - Sets up the Node.js and Java environment. - Installs project dependencies. - Builds the Android APK using Expo Application Services (EAS). - Uploads the generated APK as a build artifact. An `eas.json` configuration file has also been added to the frontend project. * Update android-build.yml * Update android-build.yml updates the version of upload artifact * This commit refactors the GitHub Actions workflow to create previews for pull requests using Expo Application Services (EAS). - The workflow is now triggered on `pull_request`. - It uses the `expo/expo-github-action` to simplify the setup of the Expo environment. - The build step has been changed from `eas build` to `eas update` to create a preview of the changes, which is faster and more efficient for reviewing pull requests. - The workflow file has been renamed to `preview.yml` to better reflect its purpose. * adds eas login id * add project configuration and update channels in eas.json * Revert "add project configuration and update channels in eas.json" This reverts commit e554381. * Add permissions for pull request handling in EAS preview workflow * Refactor GroupDetailsScreen component for improved readability and maintainability * Enhance currency formatting in GroupDetailsScreen and improve settlement display * This commit fixes several bugs in the unequal split functionality and adds a feature to select who paid for an expense. - The "Exact Value" and "Percentage" split methods now correctly handle floating-point inaccuracies and rounding. - The "Split by Shares" calculation has been corrected to include rounding. - A new "Who Paid" selector has been added to the "Add Expense" screen, allowing you to select the payer from the list of group members. * Revert "This commit fixes several bugs in the unequal split functionality and adds a feature to select who paid for an expense." This reverts commit 4068a50. * Refactor AddExpenseScreen for improved structure and functionality; enhance split methods and auto-balance percentages * Refactor AddExpenseScreen to improve payer selection logic and enhance expense calculation; ensure proper handling of rounding errors * Add paidBy field to ExpenseCreateRequest and ExpenseResponse; validate payer membership in group during expense creation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add required paidBy field to ExpenseCreateRequest in expense tests * Add test for expense creation with payer not in group * Update GitHub Actions and enhance group expense handling - Upgrade actions/checkout and actions/setup-node to version 4 in preview.yml - Add caching for npm in Node.js setup - Introduce getUserBalanceSummary API call in groups.js - Improve percentage distribution logic in AddExpenseScreen.js to avoid floating-point errors - Fetch and display group settlement status in HomeScreen.js * Implement AsyncStorage for user authentication and balance calculations; refactor FriendsScreen and HomeScreen imports * Downgrade actions/checkout version from v4 to v3 in GitHub Actions workflow * Upgrade actions/checkout version from v3 to v4 in GitHub Actions workflow * Enhance bundle analysis workflow: use Expo export for builds, improve size calculations, and generate detailed reports * Add EAS update workflow and improve bundle analysis steps * Add React Native bundle analysis workflow with fallback dependency analysis --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Devasy Patel <[email protected]> Co-authored-by: patel.devasy.23 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ddea2b5 commit 6faafc6

38 files changed

+16059
-24
lines changed

.github/workflows/bundle-analysis.yml

Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,134 @@ jobs:
2727
cache-dependency-path: frontend/package-lock.json
2828

2929
- name: Install Dependencies
30-
run: |
31-
cd frontend
32-
npm ci
30+
run: npm install
31+
working-directory: ./frontend
3332

33+
- name: Setup EAS
34+
uses: expo/expo-github-action@v8
35+
with:
36+
eas-version: latest
37+
token: ${{ secrets.EXPO_TOKEN }}
38+
3439
- name: Build for Bundle Analysis
3540
run: |
36-
cd frontend
37-
# Create a production build for analysis
38-
if npm run build --dry-run 2>/dev/null; then
39-
npm run build
41+
# Try to build with Expo for web, but handle React Native compatibility issues
42+
if npx expo export --platform web --output-dir web-build 2>/dev/null; then
43+
echo "✅ Expo web export successful"
4044
else
41-
# Use Expo's build process
42-
npx expo export:web
45+
echo "⚠️ Web export failed, using alternative bundle analysis approach"
46+
# Create a basic bundle using Metro bundler directly
47+
npx metro build --entry-file index.js --platform web --bundle-output web-build/bundle.js --assets-dest web-build/static || true
48+
# If that also fails, create a minimal analysis report
49+
if [ ! -f "web-build/bundle.js" ]; then
50+
echo "📊 Creating basic size analysis from node_modules..."
51+
mkdir -p web-build/static/js
52+
# Analyze the main dependencies that would be bundled
53+
echo "# Bundle Analysis Report (Estimated)" > bundle-analysis.md
54+
echo "" >> bundle-analysis.md
55+
echo "## Bundle Size Analysis" >> bundle-analysis.md
56+
echo "- React Native web build failed due to platform-specific modules" >> bundle-analysis.md
57+
echo "- This is common with React Native apps that use platform-specific code" >> bundle-analysis.md
58+
echo "" >> bundle-analysis.md
59+
echo "## Key Dependencies Analysis" >> bundle-analysis.md
60+
du -sh node_modules/react node_modules/react-native node_modules/@expo 2>/dev/null | while read size dir; do
61+
echo "- ${dir}: ${size}" >> bundle-analysis.md
62+
done || echo "- Unable to analyze individual dependencies" >> bundle-analysis.md
63+
exit 0
64+
fi
4365
fi
66+
working-directory: ./frontend
4467

4568
- name: Analyze Bundle Size
69+
working-directory: ./frontend
4670
run: |
47-
cd frontend
48-
# Install bundle analyzer
49-
npm install --no-save webpack-bundle-analyzer
71+
# Install analysis tools
72+
npm install --no-save @expo/metro-config metro-visualizer
73+
sudo apt-get update && sudo apt-get install -y bc
74+
75+
echo "📊 Analyzing bundle size for Expo/React Native project..."
5076
51-
# Generate bundle stats (adjust path based on your build output)
77+
# Check if bundle analysis report already exists (from build step failure handling)
78+
if [ -f "bundle-analysis.md" ]; then
79+
echo "� Using existing analysis report from build step"
80+
cat bundle-analysis.md
81+
exit 0
82+
fi
83+
84+
# Check if web-build directory exists
5285
if [ -d "web-build" ]; then
53-
# Expo web build
54-
npx webpack-bundle-analyzer web-build/static/js/*.js --report --mode static --report-filename bundle-report.html
55-
elif [ -d "dist" ]; then
56-
# Standard React build
57-
npx webpack-bundle-analyzer dist/static/js/*.js --report --mode static --report-filename bundle-report.html
86+
echo "✅ Web build directory found"
87+
ls -la web-build/
88+
89+
# Look for JavaScript bundles in various locations
90+
BUNDLE_FOUND=false
91+
92+
# Check standard Expo web build structure
93+
if [ -d "web-build/static/js" ] && [ "$(ls -A web-build/static/js 2>/dev/null)" ]; then
94+
echo "📁 JavaScript bundle files in static/js:"
95+
find web-build/static/js -name "*.js" -type f -exec ls -lh {} \; | awk '{print $5 " " $9}'
96+
97+
# Calculate total bundle size
98+
TOTAL_SIZE=$(find web-build/static/js -name "*.js" -type f -exec stat -c%s {} \; | awk '{sum+=$1} END {print sum}')
99+
TOTAL_SIZE_MB=$(echo "scale=2; $TOTAL_SIZE / 1024 / 1024" | bc -l)
100+
echo "📊 Total JavaScript bundle size: ${TOTAL_SIZE_MB} MB"
101+
BUNDLE_FOUND=true
102+
elif [ -f "web-build/bundle.js" ]; then
103+
echo "📁 Single bundle file found:"
104+
ls -lh web-build/bundle.js
105+
BUNDLE_SIZE=$(stat -c%s web-build/bundle.js)
106+
TOTAL_SIZE_MB=$(echo "scale=2; $BUNDLE_SIZE / 1024 / 1024" | bc -l)
107+
echo "📊 Bundle size: ${TOTAL_SIZE_MB} MB"
108+
BUNDLE_FOUND=true
109+
fi
110+
111+
if [ "$BUNDLE_FOUND" = true ]; then
112+
# Create analysis report
113+
echo "# Bundle Analysis Report" > bundle-analysis.md
114+
echo "" >> bundle-analysis.md
115+
echo "## Bundle Size Summary" >> bundle-analysis.md
116+
echo "- Total JavaScript bundle size: **${TOTAL_SIZE_MB} MB**" >> bundle-analysis.md
117+
echo "" >> bundle-analysis.md
118+
echo "## Build Details" >> bundle-analysis.md
119+
echo "- Platform: Web (React Native)" >> bundle-analysis.md
120+
echo "- Bundler: Metro (Expo)" >> bundle-analysis.md
121+
echo "" >> bundle-analysis.md
122+
123+
if [ -d "web-build/static/js" ]; then
124+
echo "## Individual Files" >> bundle-analysis.md
125+
find web-build/static/js -name "*.js" -type f -exec ls -lh {} \; | awk '{print "- " $9 ": " $5}' >> bundle-analysis.md
126+
fi
127+
128+
cat bundle-analysis.md
129+
else
130+
echo "❌ No JavaScript bundles found in expected locations"
131+
echo "📁 Available files in web-build:"
132+
find web-build -type f -name "*.js" -o -name "*.json" | head -10
133+
fi
58134
else
59-
echo "No build output found for bundle analysis"
135+
echo "❌ No web-build directory found"
136+
echo "📁 Available directories:"
137+
ls -la
138+
139+
# Create fallback analysis
140+
echo "# Bundle Analysis Report (Fallback)" > bundle-analysis.md
141+
echo "" >> bundle-analysis.md
142+
echo "## Analysis Status" >> bundle-analysis.md
143+
echo "- Web build failed - this is common for React Native apps with platform-specific code" >> bundle-analysis.md
144+
echo "- Bundle analysis skipped for this build" >> bundle-analysis.md
60145
fi
61146
147+
- name: Upload Bundle Analysis Report
148+
if: always() && hashFiles('frontend/bundle-analysis.md') != ''
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: bundle-analysis-report
152+
path: frontend/bundle-analysis.md
153+
retention-days: 30
154+
62155
- name: Upload Bundle Analysis to Codecov
63-
uses: codecov/codecov-action@v5
64-
if: github.actor != 'dependabot[bot]'
156+
uses: codecov/codecov-action@v4
157+
if: github.actor != 'dependabot[bot]' && hashFiles('frontend/bundle-analysis.md') != ''
65158
with:
66159
token: ${{ secrets.CODECOV_TOKEN }}
67160
flags: bundle,frontend,javascript

.github/workflows/preview.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Create EAS Preview
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
10+
jobs:
11+
preview:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
22+
- name: Setup EAS
23+
uses: expo/expo-github-action@v8
24+
with:
25+
eas-version: latest
26+
token: ${{ secrets.EXPO_TOKEN }}
27+
28+
- name: Install dependencies
29+
run: npm install
30+
working-directory: ./frontend
31+
32+
- name: Create preview
33+
uses: expo/expo-github-action/preview@v8
34+
with:
35+
command: eas update --auto --branch ${{ github.event.pull_request.head.ref }}
36+
working-directory: ./frontend

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish EAS Update
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'frontend/**'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
update:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 🏗 Setup repo
18+
uses: actions/checkout@v4
19+
20+
- name: 🏗 Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 18
24+
cache: 'npm'
25+
cache-dependency-path: frontend/package-lock.json
26+
27+
- name: 🏗 Setup EAS
28+
uses: expo/expo-github-action@v8
29+
with:
30+
eas-version: latest
31+
token: ${{ secrets.EXPO_TOKEN }}
32+
33+
- name: 📦 Install dependencies
34+
run: npm install
35+
working-directory: ./frontend
36+
37+
- name: 🚀 Create update
38+
run: npx eas update --auto --non-interactive
39+
working-directory: ./frontend
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: React Native Bundle Analysis
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'frontend/**'
7+
branches: [ main, master ]
8+
push:
9+
paths:
10+
- 'frontend/**'
11+
branches: [ main, master ]
12+
13+
jobs:
14+
rn-bundle-analysis:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '18'
26+
cache: 'npm'
27+
cache-dependency-path: frontend/package-lock.json
28+
29+
- name: Setup EAS
30+
uses: expo/expo-github-action@v8
31+
with:
32+
eas-version: latest
33+
token: ${{ secrets.EXPO_TOKEN }}
34+
35+
- name: Install Dependencies
36+
run: npm install
37+
working-directory: ./frontend
38+
39+
- name: Analyze React Native Bundle Size
40+
working-directory: ./frontend
41+
run: |
42+
echo "📊 Analyzing React Native bundle size..."
43+
44+
# Install bundle analysis tools
45+
npm install --no-save metro-visualizer
46+
47+
# Create bundle for Android (this usually works better than web)
48+
echo "🤖 Creating Android bundle for analysis..."
49+
if npx expo export --platform android --output-dir android-build --max-workers 1; then
50+
echo "✅ Android export successful"
51+
52+
# Find and analyze the bundle
53+
if [ -f "android-build/bundles/android-*.js" ]; then
54+
BUNDLE_FILE=$(find android-build/bundles -name "android-*.js" | head -1)
55+
BUNDLE_SIZE=$(stat -c%s "$BUNDLE_FILE")
56+
BUNDLE_SIZE_MB=$(echo "scale=2; $BUNDLE_SIZE / 1024 / 1024" | bc -l)
57+
58+
echo "# React Native Bundle Analysis Report" > bundle-analysis.md
59+
echo "" >> bundle-analysis.md
60+
echo "## Bundle Size Summary" >> bundle-analysis.md
61+
echo "- Platform: Android (React Native)" >> bundle-analysis.md
62+
echo "- Bundle size: **${BUNDLE_SIZE_MB} MB**" >> bundle-analysis.md
63+
echo "- Bundler: Metro (Expo)" >> bundle-analysis.md
64+
echo "" >> bundle-analysis.md
65+
echo "## Bundle Details" >> bundle-analysis.md
66+
echo "- File: $(basename "$BUNDLE_FILE")" >> bundle-analysis.md
67+
echo "- Size: ${BUNDLE_SIZE_MB} MB" >> bundle-analysis.md
68+
69+
echo "📊 Bundle analysis complete: ${BUNDLE_SIZE_MB} MB"
70+
else
71+
echo "❌ No Android bundle found"
72+
ls -la android-build/
73+
fi
74+
else
75+
echo "⚠️ Android export failed, analyzing dependencies instead..."
76+
77+
# Fallback: analyze key dependencies
78+
echo "# React Native Bundle Analysis Report (Dependencies)" > bundle-analysis.md
79+
echo "" >> bundle-analysis.md
80+
echo "## Dependencies Analysis" >> bundle-analysis.md
81+
echo "Bundle creation failed, analyzing key dependencies:" >> bundle-analysis.md
82+
echo "" >> bundle-analysis.md
83+
84+
# Get sizes of major dependencies
85+
if command -v du >/dev/null 2>&1; then
86+
echo "### Core Dependencies" >> bundle-analysis.md
87+
for dep in react react-native expo @react-navigation; do
88+
if [ -d "node_modules/$dep" ]; then
89+
size=$(du -sh "node_modules/$dep" 2>/dev/null | cut -f1)
90+
echo "- $dep: $size" >> bundle-analysis.md
91+
fi
92+
done
93+
fi
94+
95+
echo "" >> bundle-analysis.md
96+
echo "Note: Bundle size analysis requires successful export. Check React Native compatibility." >> bundle-analysis.md
97+
fi
98+
99+
# Install bc for calculations if needed
100+
sudo apt-get update && sudo apt-get install -y bc
101+
102+
# Display the report
103+
if [ -f "bundle-analysis.md" ]; then
104+
cat bundle-analysis.md
105+
fi
106+
107+
- name: Upload RN Bundle Analysis Report
108+
if: always() && hashFiles('frontend/bundle-analysis.md') != ''
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: rn-bundle-analysis-report
112+
path: frontend/bundle-analysis.md
113+
retention-days: 30
114+
115+
- name: RN Bundle Analysis Skipped
116+
if: github.actor == 'dependabot[bot]'
117+
run: echo "📦 React Native bundle analysis skipped for Dependabot PR"

backend/app/expenses/schemas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ExpenseCreateRequest(BaseModel):
2828
amount: float = Field(..., gt=0)
2929
splits: List[ExpenseSplit]
3030
splitType: SplitType = SplitType.EQUAL
31+
paidBy: str = Field(..., description="User ID of who paid for the expense")
3132
tags: Optional[List[str]] = []
3233
receiptUrls: Optional[List[str]] = []
3334

@@ -89,6 +90,7 @@ class ExpenseResponse(BaseModel):
8990
id: str = Field(alias="_id")
9091
groupId: str
9192
createdBy: str
93+
paidBy: str
9294
description: str
9395
amount: float
9496
splits: List[ExpenseSplit]

0 commit comments

Comments
 (0)