Session Reviews #38
Replies: 12 comments
-
10/3/24 - Trouble-shooting our db function
|
Beta Was this translation helpful? Give feedback.
-
10/9/2024
Whenever we get all the students for a cohort from the following endpoint: students?cohort={cohortId}, the following JSON response comes back: Lazy initialization is running tons of instructions to the ORM prior to the query actually executing to fetch the data that we are requesting. Which means we are running a lot of queries prior to serialization with all of the connected tables. Running all of the queries separately is an expensive process that we need to solve. The best approach was to work from the client JSON structure to what it was receiving and work backwards to see how we could consolidate all of the queries into hopefully one query. This is an example for cohortId = 15
We had to find a way to build out the student object to optimize the speed at which the data was retrieved. At first, the call to get students by cohort ID was about 12 to 20 seconds. Then, after refactoring, we got it down to milliseconds.
First, we dove into the codebase to find out where the different Django models and Serializers were getting the data for the student object. We found that the Next, we found out that Django was making a bunch of calls to the database using the Django ORM. These several calls in several places were impacting the performance of the API call that retrieved the students by cohort. We were able to circumvent this performance impact by creating our own SQL function that was used in tandem with our own custom serializer that we created to enhance the performance of the mentioned API call.
We optimized our data retrieval by first using CTEs specifically for each student property and then tying them all together in one SQL function. However, we ran into an issue in which we were receiving duplicate records for each student. We overcame this by using a combination of
Working with the difference joins seemed straightforward until we ran into the issue of all students in a cohort not returning back in the query. We had to alternate between INNER and LEFT JOINS to get back the results we needed. Additionally, we got to our wits end with these duplicate rows, so we utilized ChatGPT to help us find a good solution for what we needed. ChatGPT suggested json_agg and json_build_object, but we had no idea how to implement that. Thankfully, Steve stepped in and showed us how that worked along with the COALESCE operator.
The issue that was going on was that proposals for student capstones had different statuses that had to be recorded. However, we didn't know of a way to record those statuses and retrieve them in our query. This is where we used a combination of a This is how we did the CTE for proposals as seen in our SQL function.
Type casting
In our
Here is the custom serializer we created in our
|
Beta Was this translation helpful? Give feedback.
-
10/16/24
Mermaid is a markdown-like language used for creating diagrams and visualizations directly within markdown documents. It allows users to generate flowcharts, sequence diagrams, Gantt charts, and more, using a simple syntax. This makes it particularly useful for documentation, technical specifications, and project planning. Mermaid is often integrated into tools like GitHub, GitLab, and Markdown editors, enhancing the ability to visualize information without needing separate graphic design software. For example, to create the following flowchart, you might use the following syntax. graph TD;
A[Start] --> B[Process];
B --> C{Decision};
C -->|Yes| D[Outcome 1];
C -->|No| E[Outcome 2];
"
|
Beta Was this translation helpful? Give feedback.
-
10/17/24
|
Beta Was this translation helpful? Give feedback.
-
10/30/2024 -Prompt chatgpt for best configuration methods for hosting our application on AWS Here are definitions and use cases for each AWS service or tool: 1. AWS CLI (Amazon Web Services Command Line Interface)
2. IAM (Identity and Access Management)
3. EC2 (Elastic Compute Cloud)
4. S3 (Simple Storage Service)
5. RDS (Relational Database Service)
6. VPC (Virtual Private Cloud)
7. Subnet
8. Amazon Elastic Beanstalk
9. Gunicorn (Green Unicorn)
10. Nginx
11. Amazon CloudFront
12. Route 53
13. AWS Certificate Manager (ACM)
14. GitHub Actions
15. CI/CD (Continuous Integration and Continuous Deployment)
16. SSHing
17. CloudWatch
18. Backup and Disaster Recovery
19. SSL & TLSSSL (Secure Sockets Layer) and TLS (Transport Layer Security) are protocols used to secure communication over computer networks, particularly the internet. Here’s a brief overview of both:
TLS (Transport Layer Security)
Key Features of Both
While the term SSL is often still used colloquially to refer to both protocols, TLS is the current standard for secure communication on the internet. |
Beta Was this translation helpful? Give feedback.
-
graph TD
%% Frontend %%
A[React Application] -->|Build and Deploy| B[S3 Bucket]
B -->|Serve via| C[Amazon CloudFront]
C -->|DNS Routing| D[Route 53]
%% SSL %%
C -->|HTTPS| ACM[AWS Certificate Manager]
%% Backend %%
E[Elastic Beanstalk or EC2 Instance] -->|Run Django API| F[Amazon RDS PostgreSQL]
%% Database %%
subgraph Backend Network [VPC Private Subnet]
E --> F
end
%% Monitoring %%
E -->|Logs and Metrics| G[CloudWatch]
%% Code Management %%
H[GitHub Repositories] -->|Push code| E
H -->|Deploy Frontend| B
%% CI/CD %%
H -->|GitHub Actions| E
H -->|GitHub Actions| B
|
Beta Was this translation helpful? Give feedback.
-
Here's a brief, step-by-step summary to set up and deploy your application using AWS: Initial Preparation
Frontend Deployment (React)
Backend Deployment (Django)
Database Setup (PostgreSQL)
Network Configuration
Security and Monitoring
Automation and CI/CD
These steps provide a structured approach to setting up and deploying your React and Django application on AWS. |
Beta Was this translation helpful? Give feedback.
-
graph TD
%% User Entry %%
User[User] -->|Requests domainName| Route53[Route 53]
%% Route 53 to S3 for Static Content %%
Route53 -->|Routes to| S3[S3 Bucket Static Content]
S3 -->|Serves static files HTML CSS JS| Browser[User's Browser]
%% API Request from Frontend in Browser %%
Browser -->|API Call to fetch dynamic data| Route53API[Route 53 API Subdomain]
Route53API -->|Routes to| ALB[Application Load Balancer]
%% Load Balancer to Elastic Beanstalk %%
ALB -->|Distributes to instances| EB[Elastic Beanstalk]
EB -->|Runs Django API| DjangoAPI[Django API]
%% Django API to Amazon RDS %%
DjangoAPI -->|Queries and updates| RDS[Amazon RDS PostgreSQL]
%% Response Flow %%
RDS -->|Returns data| DjangoAPI
DjangoAPI -->|Returns response| ALB
ALB -->|Forwards response| Browser
|
Beta Was this translation helpful? Give feedback.
-
11/7/24 -
To set up a GitHub Action for deploying your React app to an S3 bucket, you'll follow these key steps:
Step 2: Add AWS Secrets to GitHub In your GitHub repository:
Step 3: Write the GitHub Action Workflow
Explanation of Workflow Steps
Step 4: Test the Workflow
This setup will automatically deploy your app to S3 whenever you push to main. Let me know if you need further customization or additional steps!
|
Beta Was this translation helpful? Give feedback.
-
11/20/2024
Domain Configuration
|
Beta Was this translation helpful? Give feedback.
-
12/4/24 - Setting up Database -- setup DB first Env variables for the api on digital ocean when we host the api Setting up API --
return to the DB and add the trusted source and add label that we used for the API app |
Beta Was this translation helpful? Give feedback.
-
12/19/24 --
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
10/2/24
Beta Was this translation helpful? Give feedback.
All reactions