<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rishi Sharma</title>
    <description>The latest articles on DEV Community by Rishi Sharma (@rishisharma).</description>
    <link>https://dev.to/rishisharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1777793%2Fa796fbbe-b7da-4763-826c-370d9875905f.png</url>
      <title>DEV Community: Rishi Sharma</title>
      <link>https://dev.to/rishisharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rishisharma"/>
    <language>en</language>
    <item>
      <title>Exploring New Features in PostgreSQL 17 with Python</title>
      <dc:creator>Rishi Sharma</dc:creator>
      <pubDate>Sat, 24 Aug 2024 11:14:20 +0000</pubDate>
      <link>https://dev.to/rishisharma/exploring-new-features-in-postgresql-17-with-python-1jhc</link>
      <guid>https://dev.to/rishisharma/exploring-new-features-in-postgresql-17-with-python-1jhc</guid>
      <description>&lt;p&gt;PostgreSQL 17 brings a host of exciting new features and enhancements that cater to developers, data scientists, and database administrators. This article will explore some of the most significant additions and improvements in PostgreSQL 17 and demonstrate how to use these features with Python.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improved Query Performance with Incremental Sort
One of the standout features of PostgreSQL 17 is the enhancement of the incremental sort algorithm, which now supports a wider range of use cases. Incremental sort can significantly reduce the time taken to execute queries that involve large datasets, especially when dealing with sorted data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python Example: Incremental Sort with PostgreSQL 17&lt;/p&gt;

&lt;p&gt;To use this feature, let's first set up a PostgreSQL connection using Python's psycopg2 library:&lt;/p&gt;

&lt;p&gt;`import psycopg2&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect to PostgreSQL database
&lt;/h2&gt;

&lt;p&gt;conn = psycopg2.connect(&lt;br&gt;
    host="localhost",&lt;br&gt;
    database="test_db",&lt;br&gt;
    user="postgres",&lt;br&gt;
    password="your_password"&lt;br&gt;
)&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a cursor object
&lt;/h2&gt;

&lt;p&gt;cur = conn.cursor()&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a table and insert data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
CREATE TABLE IF NOT EXISTS large_dataset (&lt;br&gt;
    id SERIAL PRIMARY KEY,&lt;br&gt;
    category VARCHAR(50),&lt;br&gt;
    value INT&lt;br&gt;
);&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Insert sample data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
INSERT INTO large_dataset (category, value)&lt;br&gt;
SELECT&lt;br&gt;
    'Category ' || (i % 10),&lt;br&gt;
    random() * 1000&lt;br&gt;
FROM generate_series(1, 1000000) i;&lt;br&gt;
""")&lt;/p&gt;

&lt;p&gt;conn.commit()&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Incremental Sort
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
EXPLAIN ANALYZE &lt;br&gt;
SELECT * FROM large_dataset &lt;br&gt;
ORDER BY category, value;&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetch and print the query plan
&lt;/h2&gt;

&lt;p&gt;query_plan = cur.fetchall()&lt;br&gt;
for line in query_plan:&lt;br&gt;
    print(line)&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the cursor and connection
&lt;/h2&gt;

&lt;p&gt;cur.close()&lt;br&gt;
conn.close()&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;In this example, PostgreSQL 17's improved incremental sort efficiently handles the ORDER BY clause, sorting data incrementally and reducing overall query execution time.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;JSON Path Enhancements
PostgreSQL 17 introduces enhancements to JSONPath, making it easier to query and manipulate JSON data. This is particularly useful for applications that heavily rely on JSON for data interchange.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python Example: Using JSONPath Enhancements&lt;br&gt;
`## Reconnect to the database&lt;br&gt;
conn = psycopg2.connect(&lt;br&gt;
    host="localhost",&lt;br&gt;
    database="test_db",&lt;br&gt;
    user="postgres",&lt;br&gt;
    password="your_password"&lt;br&gt;
)&lt;br&gt;
cur = conn.cursor()&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a table with JSON data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
CREATE TABLE IF NOT EXISTS json_data (&lt;br&gt;
    id SERIAL PRIMARY KEY,&lt;br&gt;
    data JSONB&lt;br&gt;
);&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Insert sample JSON data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
INSERT INTO json_data (data)&lt;br&gt;
VALUES&lt;br&gt;
    ('{"name": "Alice", "age": 30, "skills": ["Python", "SQL"]}'),&lt;br&gt;
    ('{"name": "Bob", "age": 25, "skills": ["Java", "C++"]}');&lt;br&gt;
""")&lt;/p&gt;

&lt;p&gt;conn.commit()&lt;/p&gt;

&lt;h2&gt;
  
  
  Query JSON data using JSONPath
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
SELECT data -&amp;gt;&amp;gt; 'name' AS name, data -&amp;gt;&amp;gt; 'age' AS age&lt;br&gt;
FROM json_data&lt;br&gt;
WHERE data @? '$.skills ? (@ == "Python")';&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetch and print the results
&lt;/h2&gt;

&lt;p&gt;results = cur.fetchall()&lt;br&gt;
for row in results:&lt;br&gt;
    print(row)&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the cursor and connection
&lt;/h2&gt;

&lt;p&gt;cur.close()&lt;br&gt;
conn.close()&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;This code demonstrates how PostgreSQL 17’s enhanced JSONPath capabilities simplify extracting data from JSON fields based on complex conditions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enhanced Parallelism for Index Creation
Index creation in PostgreSQL 17 is now more efficient due to improved parallelism, allowing for faster indexing on large datasets.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python Example: Parallel Index Creation&lt;br&gt;
`## Reconnect to the database&lt;br&gt;
conn = psycopg2.connect(&lt;br&gt;
    host="localhost",&lt;br&gt;
    database="test_db",&lt;br&gt;
    user="postgres",&lt;br&gt;
    password="your_password"&lt;br&gt;
)&lt;br&gt;
cur = conn.cursor()&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a large table
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
CREATE TABLE IF NOT EXISTS large_table (&lt;br&gt;
    id SERIAL PRIMARY KEY,&lt;br&gt;
    data VARCHAR(255)&lt;br&gt;
);&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Insert a large number of rows
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
INSERT INTO large_table (data)&lt;br&gt;
SELECT&lt;br&gt;
    md5(random()::text)&lt;br&gt;
FROM generate_series(1, 5000000);&lt;br&gt;
""")&lt;/p&gt;

&lt;p&gt;conn.commit()&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an index with parallelism
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
CREATE INDEX CONCURRENTLY large_table_data_idx ON large_table (data);&lt;br&gt;
""")&lt;/p&gt;

&lt;p&gt;conn.commit()&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the cursor and connection
&lt;/h2&gt;

&lt;p&gt;cur.close()&lt;br&gt;
conn.close()&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;This example showcases PostgreSQL 17's improved ability to create indexes concurrently using multiple CPU cores, which is highly beneficial when working with massive tables.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SQL/JSON Standard Compliant Functions
PostgreSQL 17 has added support for more SQL/JSON standard-compliant functions, enhancing its ability to handle JSON data with more SQL-standard syntax.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Python Example: SQL/JSON Standard Functions&lt;br&gt;
`## Reconnect to the database&lt;br&gt;
conn = psycopg2.connect(&lt;br&gt;
    host="localhost",&lt;br&gt;
    database="test_db",&lt;br&gt;
    user="postgres",&lt;br&gt;
    password="your_password"&lt;br&gt;
)&lt;br&gt;
cur = conn.cursor()&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a table with JSON data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
CREATE TABLE IF NOT EXISTS employee_data (&lt;br&gt;
    id SERIAL PRIMARY KEY,&lt;br&gt;
    info JSONB&lt;br&gt;
);&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Insert sample JSON data
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
INSERT INTO employee_data (info)&lt;br&gt;
VALUES&lt;br&gt;
    ('{"name": "John", "department": "Sales", "salary": 5000}'),&lt;br&gt;
    ('{"name": "Jane", "department": "IT", "salary": 7000}');&lt;br&gt;
""")&lt;/p&gt;

&lt;p&gt;conn.commit()&lt;/p&gt;

&lt;h2&gt;
  
  
  Query using SQL/JSON functions
&lt;/h2&gt;

&lt;p&gt;cur.execute("""&lt;br&gt;
SELECT jsonb_path_query_first(info, '$.department') AS department&lt;br&gt;
FROM employee_data&lt;br&gt;
WHERE jsonb_path_exists(info, '$.salary ? (@ &amp;gt; 6000)');&lt;br&gt;
""")&lt;/p&gt;

&lt;h2&gt;
  
  
  Fetch and print the results
&lt;/h2&gt;

&lt;p&gt;results = cur.fetchall()&lt;br&gt;
for row in results:&lt;br&gt;
    print(row)&lt;/p&gt;

&lt;h2&gt;
  
  
  Close the cursor and connection
&lt;/h2&gt;

&lt;p&gt;cur.close()&lt;br&gt;
conn.close()&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;In this example, we demonstrate how to use SQL/JSON standard functions to query JSON data, showcasing PostgreSQL 17's compliance with new SQL standards.&lt;/p&gt;

&lt;p&gt;For more information on PostgreSQL 17 and its new features, refer to the official documentation.&lt;/p&gt;

</description>
      <category>python</category>
      <category>postgres</category>
      <category>database</category>
      <category>sql</category>
    </item>
    <item>
      <title>Introduction to Scrum: A Framework for Agile Project Management</title>
      <dc:creator>Rishi Sharma</dc:creator>
      <pubDate>Wed, 14 Aug 2024 12:16:32 +0000</pubDate>
      <link>https://dev.to/rishisharma/introduction-to-scrum-a-framework-for-agile-project-management-4jbe</link>
      <guid>https://dev.to/rishisharma/introduction-to-scrum-a-framework-for-agile-project-management-4jbe</guid>
      <description>&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Overview of Scrum&lt;br&gt;
Scrum is a widely-adopted framework for agile project management, particularly popular in software development but increasingly used in other industries like marketing, finance, and human resources. Originating in the early 1990s, Scrum facilitates iterative development, allowing teams to deliver small increments of work over short time periods called Sprints. This article will explore the fundamentals of Scrum, its core components, and best practices for implementation within organizations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Philosophy and Principles of Scrum&lt;br&gt;
At the heart of Scrum lies the principle of empiricism, which emphasizes making decisions based on observation, experience, and experimentation rather than extensive upfront planning. This approach is underpinned by three key pillars: transparency, inspection, and adaptation. These pillars guide the team in monitoring progress, identifying challenges, and adapting the plan as necessary to achieve the desired outcome.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Scrum’s lightweight framework is designed to be adaptable, providing a structure within which teams can develop their workflow based on real-world conditions and feedback. The framework’s flexibility makes it suitable for various industries beyond its traditional use in software development.&lt;/p&gt;

&lt;p&gt;3 Core Components of Scrum&lt;/p&gt;

&lt;p&gt;3.1 Scrum Team Roles&lt;br&gt;
The Scrum Team is a self-managing, cross-functional team consisting of the following roles:&lt;/p&gt;

&lt;p&gt;Product Owner: The Product Owner represents the customer and is responsible for maximizing the value of the product by managing the Product Backlog and ensuring the team understands the work required to achieve the Product Goal.&lt;/p&gt;

&lt;p&gt;Scrum Master: Acting as a coach and facilitator, the Scrum Master ensures that the team adheres to Scrum practices and principles, helping to remove obstacles that might impede progress.&lt;/p&gt;

&lt;p&gt;Developers (Development Team): This group includes all the professionals required to deliver a potentially releasable Increment of the product at the end of each Sprint. Developers work collaboratively, often across different specializations, to achieve the Sprint Goal.&lt;/p&gt;

&lt;p&gt;3.2 Scrum Artifacts&lt;/p&gt;

&lt;p&gt;Scrum uses specific artifacts to help manage work and ensure transparency:&lt;/p&gt;

&lt;p&gt;Product Backlog: A dynamic list of tasks, features, and requirements needed to deliver a product. Managed by the Product Owner, it is regularly updated based on the project's progress and any new insights.&lt;/p&gt;

&lt;p&gt;Sprint Backlog: A subset of the Product Backlog, this list includes tasks to be completed during the current Sprint. The Development Team takes ownership of this artifact and updates it as they progress.&lt;/p&gt;

&lt;p&gt;Increment: The sum of all completed work items that meet the Definition of Done, representing a step toward the final product.&lt;/p&gt;

&lt;p&gt;4 Scrum Events&lt;/p&gt;

&lt;p&gt;Scrum structures its work around a set of recurring events that provide opportunities for planning, inspection, and adaptation:&lt;/p&gt;

&lt;p&gt;Sprint: The core unit of Scrum, a Sprint is a time-boxed period (usually 1-4 weeks) during which the team works on completing a set of tasks. Sprints ensure regular delivery of product increments and provide a rhythm for the team’s activities.&lt;/p&gt;

&lt;p&gt;Sprint Planning: At the beginning of each Sprint, the Scrum Team meets to plan the work to be completed. The Product Owner discusses the Product Backlog items, and the team selects the tasks they will work on during the Sprint.&lt;/p&gt;

&lt;p&gt;Daily Scrum: A short, daily meeting (15 minutes) where the Development Team reviews progress and plans the day’s activities. This meeting is crucial for maintaining alignment and quickly addressing any issues.&lt;/p&gt;

&lt;p&gt;Sprint Review: Held at the end of the Sprint, this meeting involves stakeholders and the Scrum Team. The team presents the Increment and discusses what was accomplished, while stakeholders provide feedback.&lt;/p&gt;

&lt;p&gt;Sprint Retrospective: After the Sprint Review, the Scrum Team holds a retrospective to reflect on the Sprint and identify areas for improvement. This continuous feedback loop is essential for fostering a culture of learning and adaptation.&lt;/p&gt;

&lt;p&gt;5 Implementing Scrum in Organizations&lt;br&gt;
While Scrum is a powerful framework, implementing it effectively requires careful consideration of the organization’s structure and culture. Key factors include:&lt;/p&gt;

&lt;p&gt;Role of the Scrum Master: A critical role in successful Scrum implementation, the Scrum Master must guide the team through the transition, ensuring adherence to Scrum principles while addressing any resistance or challenges that arise.&lt;/p&gt;

&lt;p&gt;Team Composition: Building an effective Scrum Team requires careful selection of members with complementary skills and the ability to work collaboratively. In many cases, existing organizational structures may need to be adjusted to accommodate the interdisciplinary nature of Scrum Teams.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1horrmrdr6gmns6kz5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1horrmrdr6gmns6kz5r.png" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maintaining Focus: One common challenge during implementation is ensuring that the Scrum Team remains focused on their Sprint Goals without being distracted by external demands. Establishing clear boundaries and protecting the team from unnecessary interruptions is essential.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
Scrum has proven to be an effective framework for managing complex projects across various industries. Its focus on collaboration, continuous improvement, and adaptability aligns well with the needs of modern organizations seeking to thrive in an ever-changing environment. However, successful implementation requires commitment from both leadership and the Scrum Team, along with a willingness to embrace the agile mindset fully.&lt;/p&gt;

</description>
      <category>agile</category>
      <category>scrum</category>
      <category>standup</category>
      <category>weeklyretro</category>
    </item>
    <item>
      <title>Building a Decentralized Finance (DeFi) Application using Python Ecosystem</title>
      <dc:creator>Rishi Sharma</dc:creator>
      <pubDate>Mon, 15 Jul 2024 14:17:12 +0000</pubDate>
      <link>https://dev.to/rishisharma/building-a-decentralized-finance-defi-application-using-python-ecosystem-o6j</link>
      <guid>https://dev.to/rishisharma/building-a-decentralized-finance-defi-application-using-python-ecosystem-o6j</guid>
      <description>&lt;p&gt;Decentralized Finance (DeFi) is revolutionizing the financial industry by providing open, transparent, and permissionless financial services using blockchain technology. In this article, we will explore how to build a simple DeFi application using the Python ecosystem. We will cover the following topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction to DeFi&lt;/li&gt;
&lt;li&gt;Setting Up the Development Environment&lt;/li&gt;
&lt;li&gt;Interacting with Blockchain&lt;/li&gt;
&lt;li&gt;Creating Smart Contracts&lt;/li&gt;
&lt;li&gt;Building a Backend with FastAPI&lt;/li&gt;
&lt;li&gt;Integrating Frontend with Web3.py&lt;/li&gt;
&lt;li&gt;Deploying the Application&lt;/li&gt;
&lt;li&gt;Testing the DeFi Application&lt;/li&gt;
&lt;li&gt;Security Considerations&lt;/li&gt;
&lt;li&gt;Conclusion and Future Directions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction to DeFi
&lt;/h2&gt;

&lt;p&gt;DeFi leverages blockchain technology to provide financial services such as lending, borrowing, trading, and earning interest without relying on traditional financial intermediaries like banks. The key components of DeFi include smart contracts, decentralized applications (dApps), and blockchain platforms like Ethereum.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Development Environment
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have Python installed. We will use several Python libraries including Web3.py, FastAPI, and Brownie. Create a virtual environment and install the required packages:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python -m venv venv&lt;br&gt;
source venv/bin/activate   # On Windows, use&lt;/code&gt;venv\Scripts\activate&lt;code&gt;&lt;br&gt;
pip install web3 fastapi uvicorn pydantic brownie&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Interacting with Blockchain
&lt;/h2&gt;

&lt;p&gt;We will use Web3.py to interact with the Ethereum blockchain. Let's start by connecting to a blockchain network (we will use the Ropsten testnet) and checking the balance of an address.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;blockchain.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from web3 import Web3

# Connect to the Ropsten testnet
infura_url = 'https://ropsten.infura.io/v3/YOUR_INFURA_PROJECT_ID'
web3 = Web3(Web3.HTTPProvider(infura_url))

def check_balance(address):
    balance = web3.eth.get_balance(address)
    return web3.fromWei(balance, 'ether')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating Smart Contracts
&lt;/h2&gt;

&lt;p&gt;Smart contracts are self-executing contracts with the terms of the agreement directly written into code. We will use Solidity to write a simple smart contract for a token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;contracts/Token.sol&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Token {
    string public name = "MyToken";
    string public symbol = "MTK";
    uint8 public decimals = 18;
    uint256 public totalSupply = 1000000 * (10 ** uint256(decimals));
    mapping(address =&amp;gt; uint256) public balanceOf;
    mapping(address =&amp;gt; mapping(address =&amp;gt; uint256)) public allowance;

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);

    constructor() {
        balanceOf[msg.sender] = totalSupply;
    }

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0));
        require(balanceOf[msg.sender] &amp;gt;= _value);

        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;

        emit Transfer(msg.sender, _to, _value);
        return true;
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowance[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0));
        require(balanceOf[_from] &amp;gt;= _value);
        require(allowance[_from][msg.sender] &amp;gt;= _value);

        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        allowance[_from][msg.sender] -= _value;

        emit Transfer(_from, _to, _value);
        return true;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compile and deploy the contract using Brownie:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;brownie init&lt;br&gt;
brownie compile&lt;br&gt;
brownie accounts new deployer&lt;br&gt;
brownie run scripts/deploy.py&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;scripts/deploy.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from brownie import Token, accounts

def main():
    deployer = accounts.load('deployer')
    token = Token.deploy({'from': deployer})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zrru75nby8w8fma2fzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zrru75nby8w8fma2fzv.png" alt="Defi diagram" width="800" height="535"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a Backend with FastAPI
&lt;/h2&gt;

&lt;p&gt;We will create a FastAPI backend to interact with our smart contract. The backend will provide endpoints for checking balances and transferring tokens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;app.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from web3 import Web3
import json

app = FastAPI()

infura_url = 'https://ropsten.infura.io/v3/YOUR_INFURA_PROJECT_ID'
web3 = Web3(Web3.HTTPProvider(infura_url))
contract_address = 'YOUR_CONTRACT_ADDRESS'
abi = json.loads('[YOUR_CONTRACT_ABI]')

contract = web3.eth.contract(address=contract_address, abi=abi)
deployer = web3.eth.account.privateKeyToAccount('YOUR_PRIVATE_KEY')

class TransferRequest(BaseModel):
    to: str
    amount: float

@app.get("/balance/{address}")
async def get_balance(address: str):
    try:
        balance = contract.functions.balanceOf(address).call()
        return {"balance": web3.fromWei(balance, 'ether')}
    except Exception as e:
        raise HTTPException(status_code=400, detail=str(e))

@app.post("/transfer")
async def transfer_tokens(transfer_request: TransferRequest):
    try:
        to_address = transfer_request.to
        amount = web3.toWei(transfer_request.amount, 'ether')
        nonce = web3.eth.getTransactionCount(deployer.address)
        txn = contract.functions.transfer(to_address, amount).buildTransaction({
            'chainId': 3,
            'gas': 70000,
            'gasPrice': web3.toWei('1', 'gwei'),
            'nonce': nonce,
        })
        signed_txn = web3.eth.account.signTransaction(txn, private_key=deployer.key)
        tx_hash = web3.eth.sendRawTransaction(signed_txn.rawTransaction)
        return {"transaction_hash": web3.toHex(tx_hash)}
    except Exception as e:
        raise HTTPException(status_code=400, detail=str(e))

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Integrating Frontend with Web3.py
&lt;/h2&gt;

&lt;p&gt;We can build a simple frontend to interact with our FastAPI backend and display token balances and facilitate transfers. Here, we'll use a minimal HTML and JavaScript setup to demonstrate this interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;index.html&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;DeFi Application&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;DeFi Application&amp;lt;/h1&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;h2&amp;gt;Check Balance&amp;lt;/h2&amp;gt;
        &amp;lt;input type="text" id="address" placeholder="Enter address"&amp;gt;
        &amp;lt;button onclick="checkBalance()"&amp;gt;Check Balance&amp;lt;/button&amp;gt;
        &amp;lt;p id="balance"&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;h2&amp;gt;Transfer Tokens&amp;lt;/h2&amp;gt;
        &amp;lt;input type="text" id="to" placeholder="To address"&amp;gt;
        &amp;lt;input type="text" id="amount" placeholder="Amount"&amp;gt;
        &amp;lt;button onclick="transferTokens()"&amp;gt;Transfer&amp;lt;/button&amp;gt;
        &amp;lt;p id="transaction"&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;script&amp;gt;
        async function checkBalance() {
            const address = document.getElementById('address').value;
            const response = await fetch(`http://localhost:8000/balance/${address}`);
            const data = await response.json();
            document.getElementById('balance').innerText = `Balance: ${data.balance} MTK`;
        }

        async function transferTokens() {
            const to = document.getElementById('to').value;
            const amount = document.getElementById('amount').value;
            const response = await fetch('http://localhost:8000/transfer', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({ to, amount })
            });
            const data = await response.json();
            document.getElementById('transaction').innerText = `Transaction Hash: ${data.transaction_hash}`;
        }
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Deploying the Application
&lt;/h2&gt;

&lt;p&gt;To deploy the FastAPI application, we can use Uvicorn. Run the following command to start the server:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uvicorn app:app --reload&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the DeFi Application
&lt;/h2&gt;

&lt;p&gt;To test our DeFi application, open the index.html file in a web browser and use the provided interface to check balances and transfer tokens.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Check Balance: Enter an Ethereum address and click "Check Balance" to see the token balance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transfer Tokens: Enter a recipient address and the amount of tokens to transfer, then click "Transfer" to initiate the transaction.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;When building DeFi applications, security is of paramount importance. Consider the following best practices:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Smart Contract Audits: Have your smart contracts audited by a professional security firm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Private Key Management: Never hardcode private keys in your application. Use secure key management systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Input Validation: Validate and sanitize all user inputs to prevent common vulnerabilities such as reentrancy attacks and overflows.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rate Limiting: Implement rate limiting on your endpoints to prevent abuse.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Regular Updates: Keep your libraries and dependencies up to date to mitigate known vulnerabilities.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion and Future Directions
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkc52x06i608x69sjozfg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkc52x06i608x69sjozfg.jpg" alt="Defi" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this article, we've built a simple DeFi application using the Python ecosystem. We covered the basics of DeFi, interacted with the Ethereum blockchain using Web3.py, created a smart contract, built a backend with FastAPI, and integrated a frontend.&lt;/p&gt;

&lt;p&gt;DeFi is a rapidly evolving field with immense potential. Future directions for your project could include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Integrating More DeFi Protocols: Explore integrating other DeFi protocols like lending platforms (e.g., Aave) or decentralized exchanges (e.g., Uniswap).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enhancing the Frontend: Build a more sophisticated frontend using frameworks like React.js or Vue.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adding User Authentication: Implement user authentication and authorization to create a more personalized experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expanding Smart Contract Functionality: Add more features to your smart contract, such as staking, governance, or yield farming.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Feel free to expand upon this system and experiment with new features and protocols. Happy coding!&lt;/p&gt;

</description>
      <category>defi</category>
      <category>python</category>
      <category>blockchain</category>
      <category>web3</category>
    </item>
    <item>
      <title>Building JWT Auth Chaining with FastAPI and Python</title>
      <dc:creator>Rishi Sharma</dc:creator>
      <pubDate>Sun, 14 Jul 2024 09:09:24 +0000</pubDate>
      <link>https://dev.to/rishisharma/building-jwt-auth-chaining-with-fastapi-and-python-11hn</link>
      <guid>https://dev.to/rishisharma/building-jwt-auth-chaining-with-fastapi-and-python-11hn</guid>
      <description>&lt;p&gt;In this article, we'll explore how to implement JWT (JSON Web Token) authentication in a FastAPI application. We'll cover everything from setting up the project to securing endpoints with JWT. By the end, you'll have a fully functional authentication system with chained JWT verification.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON Web Token&lt;/li&gt;
&lt;li&gt;Setting Up FastAPI Project&lt;/li&gt;
&lt;li&gt;Creating User Models and Database&lt;/li&gt;
&lt;li&gt;Implementing JWT Authentication&lt;/li&gt;
&lt;li&gt;Securing Endpoints&lt;/li&gt;
&lt;li&gt;Testing the Authentication System&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3bs6nq3lhkps06czddv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3bs6nq3lhkps06czddv.png" alt="JWT Flow" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  JSON Web Token ( JWT )
&lt;/h2&gt;

&lt;p&gt;JWT is a compact, URL-safe token format that is commonly used for securely transmitting information between parties. JWT tokens are often used for authentication and authorization purposes in web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up FastAPI Project
&lt;/h2&gt;

&lt;p&gt;First, let's set up a new FastAPI project. Ensure you have Python installed and then create a virtual environment:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python -m venv venv&lt;br&gt;
source venv/bin/activate   # On Windows, use&lt;/code&gt;venv\Scripts\activate&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, install FastAPI and Uvicorn (an ASGI server):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install fastapi uvicorn[standard] python-jose passlib[bcrypt] pydantic sqlalchemy&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a new directory for your project and add the following files:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;my_fastapi_app/&lt;br&gt;
│&lt;br&gt;
├── main.py&lt;br&gt;
├── models.py&lt;br&gt;
├── database.py&lt;br&gt;
├── schemas.py&lt;br&gt;
└── auth.py&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating User Models and Database
&lt;/h2&gt;

&lt;p&gt;Let's start by defining our database models and setting up the database connection. We'll use SQLAlchemy for ORM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;database.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

SQLALCHEMY_DATABASE_URL = "sqlite:///./test.db"

engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()

def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;models.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sqlalchemy import Column, Integer, String, Boolean
from .database import Base

class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    username = Column(String, unique=True, index=True)
    email = Column(String, unique=True, index=True)
    hashed_password = Column(String)
    is_active = Column(Boolean, default=True)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;schemas.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from pydantic import BaseModel
from typing import Optional

class UserBase(BaseModel):
    username: str
    email: str

class UserCreate(UserBase):
    password: str

class User(UserBase):
    id: int
    is_active: bool

    class Config:
        orm_mode = True

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Implementing JWT
&lt;/h2&gt;

&lt;p&gt;We need to implement JWT token creation and verification. We'll use the python-jose library for handling JWTs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;auth.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jose import JWTError, jwt
from passlib.context import CryptContext
from sqlalchemy.orm import Session
from datetime import datetime, timedelta
from . import models, schemas, database

# Secret key to encode JWT tokens
SECRET_KEY = "your_secret_key"
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")

def verify_password(plain_password, hashed_password):
    return pwd_context.verify(plain_password, hashed_password)

def get_password_hash(password):
    return pwd_context.hash(password)

def authenticate_user(db: Session, username: str, password: str):
    user = db.query(models.User).filter(models.User.username == username).first()
    if not user or not verify_password(password, user.hashed_password):
        return False
    return user

def create_access_token(data: dict, expires_delta: Optional[timedelta] = None):
    to_encode = data.copy()
    if expires_delta:
        expire = datetime.utcnow() + expires_delta
    else:
        expire = datetime.utcnow() + timedelta(minutes=15)
    to_encode.update({"exp": expire})
    encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
    return encoded_jwt

async def get_current_user(token: str = Depends(oauth2_scheme), db: Session = Depends(database.get_db)):
    credentials_exception = HTTPException(
        status_code=status.HTTP_401_UNAUTHORIZED,
        detail="Could not validate credentials",
        headers={"WWW-Authenticate": "Bearer"},
    )
    try:
        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
        username: str = payload.get("sub")
        if username is None:
            raise credentials_exception
        token_data = schemas.TokenData(username=username)
    except JWTError:
        raise credentials_exception
    user = db.query(models.User).filter(models.User.username == token_data.username).first()
    if user is None:
        raise credentials_exception
    return user

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Securing end points
&lt;/h2&gt;

&lt;p&gt;Now, let's create our FastAPI application and secure endpoints with JWT authentication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;main.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from fastapi import FastAPI, Depends, HTTPException, status
from sqlalchemy.orm import Session
from . import models, schemas, database, auth

app = FastAPI()

models.Base.metadata.create_all(bind=database.engine)

@app.post("/users/", response_model=schemas.User)
def create_user(user: schemas.UserCreate, db: Session = Depends(database.get_db)):
    db_user = db.query(models.User).filter(models.User.email == user.email).first()
    if db_user:
        raise HTTPException(status_code=400, detail="Email already registered")
    hashed_password = auth.get_password_hash(user.password)
    db_user = models.User(username=user.username, email=user.email, hashed_password=hashed_password)
    db.add(db_user)
    db.commit()
    db.refresh(db_user)
    return db_user

@app.post("/token", response_model=schemas.Token)
def login_for_access_token(db: Session = Depends(database.get_db), form_data: OAuth2PasswordRequestForm = Depends()):
    user = auth.authenticate_user(db, form_data.username, form_data.password)
    if not user:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Incorrect username or password",
            headers={"WWW-Authenticate": "Bearer"},
        )
    access_token_expires = timedelta(minutes=auth.ACCESS_TOKEN_EXPIRE_MINUTES)
    access_token = auth.create_access_token(
        data={"sub": user.username}, expires_delta=access_token_expires
    )
    return {"access_token": access_token, "token_type": "bearer"}

@app.get("/users/me/", response_model=schemas.User)
async def read_users_me(current_user: schemas.User = Depends(auth.get_current_user)):
    return current_user

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Testing the Authentication System
&lt;/h2&gt;

&lt;p&gt;To test our authentication system, we need to run the FastAPI application and use an HTTP client like &lt;strong&gt;curl&lt;/strong&gt; or &lt;strong&gt;Postman&lt;/strong&gt; to interact with our endpoints.&lt;/p&gt;

&lt;p&gt;Run the application:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uvicorn main:app --reload&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Now, let's test our endpoints using curl:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create a new user&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;curl -X POST "http://127.0.0.1:8000/users/" -H "Content-Type: application/json" -d '{"username": "testuser", "email": "test@example.com", "password": "testpassword"}'&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Obtain a JWT token:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;curl -X POST "http://127.0.0.1:8000/token" -d "username=testuser&amp;amp;password=testpassword"&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Access a protected endpoint:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;curl -X GET "http://127.0.0.1:8000/users/me/" -H "Authorization: Bearer YOUR_ACCESS_TOKEN"&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Replace YOUR_ACCESS_TOKEN with the token obtained in step 2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this article, we've built a complete JWT authentication system using FastAPI and Python. We've covered the basics of JWT, set up a FastAPI project, created user models and a database, implemented JWT authentication, secured endpoints, and tested our system. This setup provides a robust foundation for any application requiring user authentication and authorization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsv8odgh05hvd3lixif9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhsv8odgh05hvd3lixif9.png" alt="JWT Structure" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to expand upon this system by adding more features such as role-based access control, refresh tokens, and more advanced user management. Happy coding!&lt;/p&gt;

&lt;p&gt;If you found this article helpful, please leave a comment or reach out with any questions.&lt;/p&gt;

</description>
      <category>python</category>
      <category>fastapi</category>
      <category>jwt</category>
      <category>security</category>
    </item>
  </channel>
</rss>
