Software-Engineering-Project-Team / Online-Shopping-System

0 stars 0 forks source link

Back-End Team Setup #2

Open khenderson20 opened 3 weeks ago

khenderson20 commented 3 weeks ago

FastAPI - Back-end in Python Docs

Steps to take to implement an online shopping system using FastAPI

  1. Set up the project environment
  2. Define the database models
  3. Create the FastAPI application
  4. Set up the routes for the CRUD operations
  5. Implement authentication
  6. Test the application (optional)

Step-by-Step Plan

  1. Set up the project environment
    • Create a new directory for your project.
    • Create a virtual environment and install FastAPI and other packages (sqlalchemy for the database models, pydantic for validation)

setup in your terminal like this

python -m venv back-end-environment
source venv/bin/activate   # on Windows use`venv\Scripts\activate`
pip install fastapi uvicorn sqlalchemy pydantic
  1. Define the database models
    • Use SQLAlchemy to define your database models.
    • Define models for Users, Products, Orders, etc.
  2. Create the FastAPI application and databse connection
    • Initialize FastAPI and set up the database connection
  3. Set up the routes (also called endpoints) for the CRUD Operations
    • Define routes to handle creating, reading, updating, and deleting resources.
  4. Implement authentication
    • Use OAuth2 or JSON Web Tokens (JWT) for user authentication.
  5. Test the application (optional i think)
    • Use tools like pytest and HTTP client libraries to test the API

Enhancements on the plan above to meet project Requirements (I think)

  1. Enhance the database models

    • Add models for discount codes and sales items.
    • Add fields for images, prices, and quantities to the product model.
  2. Update the schemas

    • Include new fields in the schemas for products.
    • Create schemas for discount codes and sales items.
  3. Add CRUD operations for new functionalities

    • Implement CRUD operations for managing products, users, discount codes, and sales items.
    • Add endpoints to view and manage orders.
  4. Set up authentication and authorization

    • Ensure only admin users can access administrative endpoints.
  5. Implement sorting and filtering for orders

AWS services to build this out

Amazon EC2 (Used to host the FastAPI application)

Amazon RDS (Used to host our PostgreSQL or MYSQL database)

Amazon S3 (Store our static assets like product images and HTML, CSS, JavaScript)

Amazon API Gateway (Used to create, publish, maintain, monitor, and secure our API and can manage the API requests to the FastAPI application)

Amazon CloudWatch (Used to monitor and log app performance and metrics)

AWS CloudFormation (Used to automate the deployment of our infrastructure)

Example Architecture

Frontend Application:

Static content (HTML, CSS, JS) hosted on S3 and served via CloudFront.

Backend Application:

FastAPI application hosted on EC2. API Gateway to manage and expose API endpoints.

Database:

RDS for PostgreSQL/MySQL to store user data, products, orders, etc.

Storage:

S3 for storing product images.

Authentication and Authorization:

IAM for managing permissions and roles. Cognito (optional) for managing user sign-up, sign-in, and access control.

Monitoring and Logging:

CloudWatch for monitoring application performance and logging.

Notifications:

SNS for sending notifications. SES for sending emails.

I will make the diagram tomorrow to show the flow

khenderson20 commented 2 weeks ago

Screenshot from 2024-06-11 15-17-19

Project is consolidated down to just one AWS EC2 instance

khenderson20 commented 2 weeks ago

Screenshot from 2024-06-11 23-55-59

How I plan to merge changes (including any changes I make on feature branches)

Never ever push to main directly starting now