-
Notifications
You must be signed in to change notification settings - Fork 23
Refactor installation commands and add AI coding guide for Splitwiser project #52
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Splitwiser - AI Coding Guide | ||
|
|
||
| This document provides essential context for AI assistants working with the Splitwiser codebase. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Splitwiser is an expense tracking and splitting application with: | ||
| - Backend: FastAPI + MongoDB | ||
| - Frontend POC: Streamlit | ||
| - Planned Frontend: Expo/React Native (in development) | ||
|
|
||
| The app allows users to create groups, add expenses with flexible splitting options, track balances, and handle settlements. | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Backend (FastAPI) | ||
| - Located in `/backend/` | ||
| - RESTful API using FastAPI with Python 3.9+ | ||
| - MongoDB for database (nonrelational schema) | ||
| - JWT authentication with refresh token rotation | ||
| - Modular design with services: | ||
| - `app/auth/`: Authentication & user registration | ||
| - `app/user/`: User profile management | ||
| - `app/groups/`: Group creation & management | ||
| - `app/expenses/`: Expense tracking & splitting | ||
|
|
||
| ### Frontend POC (Streamlit) | ||
| - Located in `/ui-poc/` | ||
| - `Home.py`: Entry point with login/registration | ||
| - `pages/`: Contains main application pages | ||
| - `Groups.py`: Group management & expense creation | ||
| - `Friends.py`: Friend balance tracking | ||
|
|
||
| ## Key Development Patterns | ||
|
|
||
| ### API Communication | ||
| ```python | ||
| # Example API call with retry logic from Groups.py | ||
| response = make_api_request( | ||
| method="get", | ||
| url=f"{API_URL}/groups/{group_id}", | ||
| headers={"Authorization": f"Bearer {st.session_state.access_token}"}, | ||
| max_retries=3 | ||
| ) | ||
| ``` | ||
|
|
||
| ### State Management | ||
| - Backend: MongoDB stores persistent data | ||
| - Frontend: Streamlit session state manages user session | ||
| ```python | ||
| # Session state initialization (see Home.py) | ||
| if "access_token" not in st.session_state: | ||
| st.session_state.access_token = None | ||
| ``` | ||
|
|
||
| ### Expense Handling | ||
| - Support for different split types: equal, unequal, percentage-based | ||
| - Each expense has a payer and multiple splits (recipients) | ||
| - Settlements track debt resolution between users | ||
|
|
||
| ## Developer Workflows | ||
|
|
||
| ### Setup & Running | ||
| 1. Backend: | ||
| ```bash | ||
| cd backend | ||
| pip install -r requirements.txt | ||
| uvicorn main:app --reload | ||
| ``` | ||
| 2. Frontend POC: | ||
| ```bash | ||
| cd ui-poc | ||
| pip install -r requirements.txt | ||
| streamlit run Home.py | ||
| ``` | ||
| 3. Test Data Generation: | ||
| ```bash | ||
| cd ui-poc | ||
| python setup_test_data.py | ||
| ``` | ||
|
|
||
| ### Testing | ||
| - Backend tests in `/backend/tests/` | ||
| - Run tests with: `cd backend && pytest` | ||
| - Test data setup script: `/ui-poc/setup_test_data.py` | ||
|
|
||
| ## Critical Files & Dependencies | ||
|
|
||
| - `backend/main.py`: Main FastAPI application entry point | ||
| - `backend/app/config.py`: Configuration settings | ||
| - `backend/app/database.py`: MongoDB connection | ||
| - `ui-poc/Home.py`: Streamlit application entry point | ||
| - `ui-poc/openapi.json`: API specification for frontend reference | ||
|
|
||
| ## Common Tasks | ||
|
|
||
| - Adding new API endpoint: Add route to appropriate service router file | ||
| - Adding new UI component: Modify files in `/ui-poc/pages/` | ||
| - Testing data flow: Use the `setup_test_data.py` to create test scenarios | ||
| - Troubleshooting auth: Check JWT token handling in `app/auth/security.py` | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,23 +1,17 @@ | ||||||||||||||
| [phases.setup] | ||||||||||||||
| nixPkgs = ["python312", "pip"] | ||||||||||||||
|
|
||||||||||||||
| # Completely override the install command to avoid duplicate processes | ||||||||||||||
| # Use the default Python install behavior but ensure we use the right requirements file | ||||||||||||||
| [phases.install] | ||||||||||||||
| cmds = [ | ||||||||||||||
| "python -m pip install --upgrade pip", | ||||||||||||||
| "pip install --upgrade pip", | ||||||||||||||
| "pip install -r requirements.txt" | ||||||||||||||
| ] | ||||||||||||||
|
|
||||||||||||||
| # Skip Python's default install phase entirely | ||||||||||||||
| [phases.python:install] | ||||||||||||||
| dependsOn = ["install"] | ||||||||||||||
| cmds = [] | ||||||||||||||
|
|
||||||||||||||
| [phases.build] | ||||||||||||||
| cmds = [ | ||||||||||||||
| "echo 'Build phase complete'", | ||||||||||||||
| # Copy backend files to the root for simpler execution | ||||||||||||||
| "cp -r backend/* ." | ||||||||||||||
| "echo 'Build phase: Copying backend files'", | ||||||||||||||
| "cp -r backend/* . || echo 'Backend files already in place'" | ||||||||||||||
| ] | ||||||||||||||
|
Comment on lines
+13
to
15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
A safer, idempotent alternative: -"cp -r backend/* . || echo 'Backend files already in place'"
+"shopt -s dotglob && cp -R backend/* . 2>/dev/null || echo 'No backend directory to copy'"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| [start] | ||||||||||||||
|
|
@@ -28,7 +22,5 @@ cmd = "uvicorn main:app --host 0.0.0.0 --port $PORT" | |||||||||||||
| PYTHONPATH = "/app" | ||||||||||||||
| PYTHONUNBUFFERED = "1" | ||||||||||||||
|
|
||||||||||||||
| # Specify we're using plain pip without a venv | ||||||||||||||
| # Let Nixpacks handle virtual environment creation automatically | ||||||||||||||
| [nixpacks] | ||||||||||||||
| plan-path = "disabled" | ||||||||||||||
| create-venv = false | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Python version mismatch between docs and build configuration.
Docs say “Python 3.9+” while
nixpacks.tomlpins 3.12. Align them to avoid on-boarding confusion and runtime surprises (e.g., 3.12 deprecations).🤖 Prompt for AI Agents