<?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>Forem: Salima Dergoul</title>
    <description>The latest articles on Forem by Salima Dergoul (@sdsalima).</description>
    <link>https://forem.com/sdsalima</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%2F3482320%2F424112fa-08e0-472a-898f-8f21a919bbb7.jpeg</url>
      <title>Forem: Salima Dergoul</title>
      <link>https://forem.com/sdsalima</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sdsalima"/>
    <language>en</language>
    <item>
      <title>Bridging Databases and JSON with SQLAlchemy &amp; Marshmallow</title>
      <dc:creator>Salima Dergoul</dc:creator>
      <pubDate>Tue, 20 Jan 2026 00:39:07 +0000</pubDate>
      <link>https://forem.com/sdsalima/bridging-databases-and-json-with-sqlalchemy-marshmallow-4pf5</link>
      <guid>https://forem.com/sdsalima/bridging-databases-and-json-with-sqlalchemy-marshmallow-4pf5</guid>
      <description>&lt;p&gt;As backend developers, one of our recurring challenges is making data flow seamlessly between the database and the API layer.&lt;/p&gt;

&lt;p&gt;That’s where the combination of SQLAlchemy (for ORM and database modeling) and Marshmallow (for serialization/validation) shines:&lt;/p&gt;

&lt;p&gt;🗂 SQLAlchemy gives us robust, Pythonic models and query power.&lt;/p&gt;

&lt;p&gt;🧩 Marshmallow transforms those models into clean, validated JSON responses.&lt;/p&gt;

&lt;p&gt;🔐 Together, they enable secure, scalable APIs with minimal boilerplate.&lt;/p&gt;

&lt;p&gt;In my recent work, I’ve been architecting CRUD routes with dynamic JSON serialization, and this stack has proven invaluable for:&lt;/p&gt;

&lt;p&gt;Streamlining onboarding for collaborators&lt;/p&gt;

&lt;p&gt;Enforcing clear validation rules&lt;/p&gt;

&lt;p&gt;Building APIs that are both developer-friendly and user-centric&lt;/p&gt;

&lt;p&gt;💡 My takeaway: mastering this duo isn’t just about writing code—it’s about designing workflows that empower teams and make data communication intuitive.&lt;/p&gt;

&lt;p&gt;👉 If you’re building APIs, I highly recommend exploring how SQLAlchemy and Marshmallow complement each other. It’s a small investment that pays off in clarity, scalability, and professional polish.&lt;br&gt;
------------Code example-----------------&lt;br&gt;
`from app import db&lt;br&gt;
from models import User, Post, Comment&lt;br&gt;
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema&lt;/p&gt;

&lt;p&gt;class UserSchema(SQLAlchemyAutoSchema):&lt;br&gt;
  #  automatically generates fields based on your SQLAlchemy model User, saves you from manually writing every field mapping.&lt;br&gt;
  class Meta:     #  Meta class provides configuration for the schema: &lt;br&gt;
    model=User         # which model &lt;br&gt;
    load_instance=True      # when deserializing JSON, Marshmallow will return actual User &lt;br&gt;
    sqla_session = db.session  # inks the schema to your SQLAlchemy session so it can interact with the database &lt;/p&gt;

&lt;h1&gt;
  
  
  Schema instances   for serializing/deserializing
&lt;/h1&gt;

&lt;p&gt;user_schema = UserSchema()          # for single objects&lt;br&gt;
users_schema = UserSchema(many=True) # for lists of objects&lt;br&gt;
`&lt;/p&gt;

</description>
      <category>flaskmarshmallow</category>
      <category>flaskdevelopment</category>
      <category>apidevelopment</category>
      <category>backenddeve</category>
    </item>
    <item>
      <title>Avoiding Circular Imports in Flask Projects</title>
      <dc:creator>Salima Dergoul</dc:creator>
      <pubDate>Sun, 18 Jan 2026 14:15:29 +0000</pubDate>
      <link>https://forem.com/sdsalima/avoiding-circular-imports-in-flask-projects-3i6e</link>
      <guid>https://forem.com/sdsalima/avoiding-circular-imports-in-flask-projects-3i6e</guid>
      <description>&lt;p&gt;For avoiding the circular import in flask projects, we do the import at the bottom of our code.&lt;br&gt;
For example, in the routes.py file I have two imports app and db  like so:&lt;br&gt;
&lt;strong&gt;from&lt;/strong&gt; app &lt;strong&gt;import&lt;/strong&gt; app, db&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you import routes at the top of app.py, Python will try to load routes.py before app and db are fully defined.&lt;br&gt;
&lt;strong&gt;- That creates a circular dependency:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;app.py imports routes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;routes.py imports app&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Neither file finishes loading → error or undefined objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By placing import routes at the bottom, you ensure:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;app, db, jwt, and migrate are initialized first.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then routes.py can safely attach endpoints to app.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;in the app.py file:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`from flask import Flask&lt;br&gt;
from flask_sqlalchemy import SQLAlchemy&lt;br&gt;
from flask_jwt_extended import JWTManager&lt;br&gt;
from flask_migrate import Migrate&lt;/p&gt;

&lt;h1&gt;
  
  
  Create the Flask application instance
&lt;/h1&gt;

&lt;p&gt;app = Flask(&lt;strong&gt;name&lt;/strong&gt;)&lt;/p&gt;

&lt;h1&gt;
  
  
  Load configuration settings (e.g., DB URI, JWT secret key) from config.py
&lt;/h1&gt;

&lt;p&gt;app.config.from_object("config.Config")&lt;/p&gt;

&lt;h1&gt;
  
  
  Initialize SQLAlchemy ORM with the app
&lt;/h1&gt;

&lt;p&gt;db = SQLAlchemy(app)&lt;/p&gt;

&lt;h1&gt;
  
  
  Initialize JWT manager for authentication
&lt;/h1&gt;

&lt;p&gt;jwt = JWTManager(app)&lt;/p&gt;

&lt;h1&gt;
  
  
  Initialize Flask-Migrate for database migrations
&lt;/h1&gt;

&lt;p&gt;migrate = Migrate(app, db)&lt;/p&gt;

&lt;h1&gt;
  
  
  Custom CLI command: create all database tables
&lt;/h1&gt;

&lt;p&gt;@app.cli.command("db_create")&lt;br&gt;
def db_create():&lt;br&gt;
    db.create_all()&lt;br&gt;
    print("db created!.")&lt;/p&gt;

&lt;h1&gt;
  
  
  Custom CLI command: drop all database tables
&lt;/h1&gt;

&lt;p&gt;@app.cli.command("db_drop")&lt;br&gt;
def db_drop():&lt;br&gt;
    db.drop_all()&lt;br&gt;
    print("db dropped!.")&lt;/p&gt;

&lt;h1&gt;
  
  
  Import routes AFTER app, db, jwt, migrate are defined
&lt;/h1&gt;

&lt;h1&gt;
  
  
  This avoids circular imports (routes.py needs app and db)
&lt;/h1&gt;

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

&lt;p&gt;&lt;strong&gt;in the routes.py file:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;`from flask import jsonify, request&lt;br&gt;
from flask_jwt_extended import jwt_required, get_jwt_identity&lt;br&gt;
from app import db&lt;br&gt;
from app.models import Post&lt;/p&gt;

&lt;p&gt;def register_routes(app):&lt;br&gt;
    @app.route("/v1/post", methods=["POST"])&lt;br&gt;
    @jwt_required()&lt;br&gt;
    def add_post():&lt;br&gt;
        user_id = int(get_jwt_identity())&lt;br&gt;
        data = request.get_json()&lt;br&gt;
        post = Post(title=data["title"], body=data["body"], author_id=user_id)&lt;br&gt;
        db.session.add(post)&lt;br&gt;
        db.session.commit()&lt;br&gt;
        return jsonify(message="Post created successfully"), 201`&lt;/p&gt;

</description>
      <category>python</category>
      <category>flask</category>
      <category>development</category>
    </item>
    <item>
      <title>Artificial Intelligence in Freelance Software Development A Technical and Structural Analysis Beyond Productivity Narratives</title>
      <dc:creator>Salima Dergoul</dc:creator>
      <pubDate>Thu, 15 Jan 2026 11:59:03 +0000</pubDate>
      <link>https://forem.com/sdsalima/artificial-intelligence-in-freelance-software-development-a-technical-and-structural-analysis-1fkp</link>
      <guid>https://forem.com/sdsalima/artificial-intelligence-in-freelance-software-development-a-technical-and-structural-analysis-1fkp</guid>
      <description>&lt;p&gt;💡 AI isn’t magic—it’s infrastructure. Behind every “smart” response lies a complex choreography of models, APIs, and orchestration layers that most freelancers never see. What feels like seamless intelligence is actually a pipeline of tokenization, context management, filtering, and backend decisions that quietly shape the limits of what AI can and cannot do. If you’ve ever wondered why your prompts sometimes fall flat, why responses get truncated, or why outputs feel inconsistent, the answer often isn’t the model—it’s the invisible architecture around it. Understanding these hidden layers is the key to using AI responsibly, predicting failure modes, and knowing when to trust automation versus when to lean on human judgment. 🚀&lt;/p&gt;

&lt;p&gt;👉 Curious to see how these design choices impact your daily workflow as a freelancer? Dive into the full article here:&lt;br&gt;
&lt;a href="https://lnkd.in/ew_wnbq2" rel="noopener noreferrer"&gt;click here for read the article&lt;/a&gt;&lt;br&gt;
 →You can also connect with us directly from there.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ai</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
