react-app-demo.mp4
Photo Repository is a web application designed to demonstrate the deployment of AWS services for IT231. It provides users with a platform to upload, store, and view images. The project showcases the integration of AWS services, including:
- React Frontend: The web interface for users to interact with the photo repository.
- Flask Backend: Facilitates communication between the frontend and the AWS services.
- S3 Bucket: Stores uploaded images and makes them accessible for display on the website.
- EC2 Instance: Hosts the frontend and backend services in the cloud.
- VPC (Virtual Private Cloud): Manages the network connectivity between AWS resources and ensures secure, public access to the application.
- Upload photos to the repository.
- View photos in a responsive gallery with a lightbox feature.
- Backend integration with AWS S3 for storage.
- Deployment-ready architecture for AWS using EC2 and VPC.
To test the app locally in its current "dev" state, follow these instructions:
- Node.js (v16+): Install Node.js
- Python (3.8+): Install Python
- Pip: Comes with Python, but ensure it's installed (
pip --version
). - Virtual Environment: (Optional) Recommended for Python dependencies.
- SQLite3: You can quickly check if you have SQLite3 installed by running:
sqlite3 --version
git clone https://github.com/ochrebasis/photo-repository-react-app.git
cd photo-repository
- Navigate to the
frontend/
directory:cd frontend
- Install dependencies:
npm install
- Start the development server:
npm start
- Open your browser at http://localhost:3000.
- Navigate to the
backend/
directory:cd ../backend
- Create and activate a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows
- Install dependencies:
pip install -r requirements.txt
- Start the Flask server:
python app_local.py
- The backend will run on http://localhost:5000.
- Any images uploaded to the website will be stored locally in
backend/uploads/
. - Photo metadata will be saved in the
backend/photo_repo.db
SQLite database.
To deploy this application on AWS, follow these steps:
- AWS Account: Sign up at AWS.
- AWS CLI: Install and configure with
aws configure
.
-
Create an EC2 Instance:
- Launch an EC2 instance with a publicly accessible IP.
- Use an Ubuntu or Amazon Linux AMI.
-
Install Dependencies: SSH into the instance and install the required software:
sudo apt update sudo apt install python3 python3-pip sudo pip3 install flask boto3
-
Deploy the Flask App:
- Copy your
backend/
directory to the EC2 instance. - Start the app using:
python3 app_aws.py
- Copy your
-
Allow HTTP Traffic:
- Configure the security group to allow traffic on port
5000
or use a reverse proxy (e.g., Nginx) to serve the app on port80
.
- Configure the security group to allow traffic on port
-
Build the React App:
- Navigate to the
frontend/
directory and run:npm run build
- This generates a production-ready app in the
frontend/build/
folder.
- Navigate to the
-
Deploy to EC2:
- Copy the
frontend/build/
folder to your EC2 instance. - Serve it using a web server like Nginx or Apache.
- Copy the
-
Create an S3 Bucket:
- Name the bucket (e.g.,
photo-repository-bucket
) and enable public access.
- Name the bucket (e.g.,
-
Update the Flask Backend:
- Modify the Flask app to upload images to S3.
- Use AWS SDK (Boto3) to interact with the bucket.
-
Set Permissions:
- Attach an IAM role to the EC2 instance with
AmazonS3FullAccess
.
- Attach an IAM role to the EC2 instance with