Run it locally from my main.py file.
python3 -m uvicorn main:app --reloadssh -i "splitz_ec2.pem" ubuntu@ec2-3-14-255-133.us-east-2.compute.amazonaws.com
- Create a migration file:
alembic revision -m "remove temporary users column and add profile and room picture S3 URL columns"
>>> Generating /home/ubuntu/splitz/alembic/versions/9ff2d6bc8ce3_remove_temporary_users_column_and_add_.py ... done2: Modify the migration file 9ff2d6bc8ce3_remove_temporary_users_column_and_add_.py
- Run the migration:
alembic upgrade headThis is the backend API for Splitz It consists of a backend API which stores the data in XXXX and listens on port 8000. Authentication is done using Twilio xxxxx The frontend is in React, and the app can be downloaded from xxxx. It connects to the API for all functionality.
Requires Python, ideally on Linux or else Mac.
- Download source code from Github
GitHub blah blah
- Copy entire source folder into /usr/local/splitz (INSTALL_DIR)
- Edit xxxx.init and set the Postgres directory and AWS S3 bucket and also Twilio xxxx and also INSTALL_DIR
- Start the API using (cd $INSTALL_DIR ; python main.py) &
- Test the API by doing a : python test_api.py
- Look in $INSTALL_DIR/logs directory to see if there are any errors
There is no CI/CD pipeline, so for all updated code to show up in prod, a log of manual work needs to be done. Obviously, a CI/CD pipeline needs to be set up to streamline this process.
The backend is run on an AWS EC2 instance. In simple terms, you know when you run this command locally?
python3 -m uvicorn main:app --reloadIts the same principle except we are running it in a computer somwhere in AWS.
To update the backend code in prod, do the following:
- Make sure .pem file is downloaded on your computer. This is the 'key' that will allow you ot SSH into EC2 instance. The file is:
splitz_ec2.pem
DO NOT LOSE THIS FILE. ONCE YOU LOSE IT YOU CAN NEVER CONNECT TO THIS EC2 INSTANCE EVER AGAIN
- SSH into EC2 instance:
ssh -i "splitz_ec2.pem" ubuntu@ec2-3-14-255-133.us-east-2.compute.amazonaws.com- attach to detached terminal session:
tmux attach-
stop the uvicorn instance running by doing CTRL + C
-
Pull the latest code from github:
git pull- start the server again:
python3 -m uvicorn main:app --reload- detach from tmux terminal session. Press CTRL + B, then D
You're done!
in order to deploy the frontend application for other people to actually use, you basically will be following the commands from this website:
https://docs.expo.dev/build/setup/
- Install eas-cli
npm install -g eas-cli- login to eas
eas loginCredentials: expo credentials
- configure build
eas build:configure- Build for ios
eas build --platform iosIt is going to ask you to login to apple developer account: apple developer account login
-
Wait for build to complete
-
Deploy the build:
https://docs.expo.dev/submit/introduction
Data is stored in Postgres and in EC2.
The application follows a modular, object-oriented design that separates concerns into distinct classes, each with their own responsibilities. This design includes a Database class for database operations, a UserService class for user-related business logic, and a UserController class for handling HTTP requests and responses.
-
Modularity: Each class has a specific role, making the code easier to understand and maintain.
-
Reusability: The classes can be reused across the application, promoting code efficiency and consistency.
-
Testability: Each class can be tested independently, facilitating robust and comprehensive testing.
-
Flexibility: Changes in one class (e.g., database interactions) do not affect others, making the codebase more adaptable to future modifications.
This design does not inherently add security but provides a structured framework within which secure coding practices can be effectively implemented.
Do what i did in Scaleable software architectures class. First, create a way to upload images sent from the clients side. Then the backend takes that image and puts it into an s3 bucket with a UUID as its folder name. This folder on s3 represents the GROUP UUID to which all these uploaded receipt images belong. Anyone that has this UUID in their "groups" field of their database record, can access all the images within subdirectory on s3. Maybe even add a list of all Group UUID's a User is in.
a room is going to represented as a UUID as the primary key. the User and Rooms table will be a many-to-many relationship. For this we will be using an association table:
UserRoom Association Table:
user_id: Foreign Key referencing Users
room_id: Foreign Key referencing Rooms
Rooms Table:
room_id:Primary key (UUID)
room_name: Name of the room
room_password: Password for the room (hashed + salt)
