<?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: MOHAMED FAWAS</title>
    <description>The latest articles on Forem by MOHAMED FAWAS (@mohamedfawas1).</description>
    <link>https://forem.com/mohamedfawas1</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%2F1458238%2F7c592738-e6ec-4ff0-bb4a-1df18db3d5b1.jpg</url>
      <title>Forem: MOHAMED FAWAS</title>
      <link>https://forem.com/mohamedfawas1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohamedfawas1"/>
    <language>en</language>
    <item>
      <title>E-Commerce Platform with Golang : Setting Up Go Modules and Initial Configurations</title>
      <dc:creator>MOHAMED FAWAS</dc:creator>
      <pubDate>Fri, 04 Oct 2024 12:21:31 +0000</pubDate>
      <link>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-setting-up-go-modules-and-initial-configurations-43o1</link>
      <guid>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-setting-up-go-modules-and-initial-configurations-43o1</guid>
      <description>&lt;p&gt;Here I have provided a step-by-step guide on how to set up the project&lt;/p&gt;

&lt;p&gt;Create the project directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir rmshop-clean-architecture
cd rmshop-clean-architecture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize Go modules&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go mod init github.com/yourusername/rmshop-clean-architecture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set up the main application entry point (&lt;code&gt;cmd/api/main.go&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "log"
    "net/http"

    "github.com/yourusername/rmshop-clean-architecture/internal/config"
    "github.com/yourusername/rmshop-clean-architecture/internal/server"
)

func main() {
    cfg, err := config.Load()
    if err != nil {
        log.Fatalf("Failed to load config: %v", err)
    }

    srv, err := server.New(cfg)
    if err != nil {
        log.Fatalf("Failed to create server: %v", err)
    }

    log.Printf("Starting server on :%s", cfg.Server.Port)
    if err := http.ListenAndServe(":"+cfg.Server.Port, srv); err != nil {
        log.Fatalf("Failed to start server: %v", err)
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a basic configuration file (&lt;code&gt;internal/config/config.go&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package config

import "github.com/spf13/viper"

type Config struct {
    Server ServerConfig
    DB     DBConfig
}

type ServerConfig struct {
    Port string
}

type DBConfig struct {
    Host     string
    Port     string
    User     string
    Password string
    DBName   string
}

func Load() (*Config, error) {
    viper.SetConfigName("config")
    viper.SetConfigType("yaml")
    viper.AddConfigPath(".")
    viper.AddConfigPath("./config")

    if err := viper.ReadInConfig(); err != nil {
        return nil, err
    }

    var config Config
    if err := viper.Unmarshal(&amp;amp;config); err != nil {
        return nil, err
    }

    return &amp;amp;config, nil
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a config.yaml file in the project root&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
server:
  port: "8080"

db:
  host: "localhost"
  port: "5432"
  user: "postgres"
  password: "your_password"
  dbname: "rmshop"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initialize the basic server setup (&lt;code&gt;internal/server/server.go&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package server

import (
    "net/http"

    "github.com/yourusername/rmshop-clean-architecture/internal/config"
)

type Server struct {
    router http.Handler
}

func New(cfg *config.Config) (*Server, error) {
    // Initialize your router, database connection, and other dependencies here
    // For now, we'll just return a basic server
    return &amp;amp;Server{
        router: http.NewServeMux(),
    }, nil
}

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    s.router.ServeHTTP(w, r)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install necessary dependencies&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go get github.com/spf13/viper
go get github.com/lib/pq
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup provides a solid foundation for your e-commerce project, adhering to clean architecture principles. In the next sections, we'll build upon this structure to implement our business logic, database interactions, and API endpoints.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>E-Commerce Platform with Golang : Project Directory Structure</title>
      <dc:creator>MOHAMED FAWAS</dc:creator>
      <pubDate>Fri, 04 Oct 2024 12:15:05 +0000</pubDate>
      <link>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-project-directory-structure-53fg</link>
      <guid>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-project-directory-structure-53fg</guid>
      <description>&lt;p&gt;Our e-commerce platform will follow this directory structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rmshop-clean-architecture/
│
├── cmd/
│   ├── api/
│   │   └── main.go                 # Main application entry point
│   └── seedadmin/
│       └── main.go                 # Admin seeding command
│
├── internal/
│   ├── config/
│   │   └── config.go               # Application configuration
│   │
│   ├── delivery/
│   │   └── http/
│   │       ├── handlers/
│   │       │   ├── user_handler.go
│   │       │   ├── admin_handler.go
│   │       │   ├── product_handler.go
│   │       │   └── ...
│   │       ├── middleware/
│   │       │   ├── auth.go
│   │       │   └── ...
│   │       └── routes.go
│   │
│   ├── domain/
│   │   ├── user.go
│   │   ├── product.go
│   │   └── ...
│   │
│   ├── repository/
│   │   ├── interfaces.go
│   │   └── postgres/
│   │       ├── user_repository.go
│   │       ├── product_repository.go
│   │       └── ...
│   │
│   ├── usecase/
│   │   ├── user_usecase.go
│   │   ├── product_usecase.go
│   │   └── ...
│   │
│   └── server/
│       └── server.go
│
├── pkg/
│   ├── auth/
│   │   └── jwt.go
│   ├── database/
│   │   ├── migrations.go
│   │   └── postgres.go
│   └── ...
│
├── migrations/
│   ├── 001_create_users_table.up.sql
│   ├── 001_create_users_table.down.sql
│   └── ...
│
├── go.mod
├── go.sum
└── README.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This structure adheres to clean architecture principles&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cmd/&lt;/code&gt;: Contains the main applications of the project.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;internal/&lt;/code&gt;: Houses the core application code, inaccessible to other projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;config/&lt;/code&gt;: Application configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;delivery/&lt;/code&gt;: Handles how the data is presented to and received from the user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;domain/&lt;/code&gt;: Defines core business logic and entities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;repository/&lt;/code&gt;: Handles data storage and retrieval.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;usecase/&lt;/code&gt;: Contains application-specific business rules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;server/&lt;/code&gt;: Manages the HTTP server setup.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;pkg/&lt;/code&gt;: Shared packages that can be used by external applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;migrations/&lt;/code&gt;: Database migration files.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>go</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>E-Commerce Platform with Golang : Understanding clean architecture</title>
      <dc:creator>MOHAMED FAWAS</dc:creator>
      <pubDate>Fri, 04 Oct 2024 12:10:39 +0000</pubDate>
      <link>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-part-2-2b6h</link>
      <guid>https://forem.com/mohamedfawas1/e-commerce-platform-with-golang-part-2-2b6h</guid>
      <description>&lt;h2&gt;
  
  
  Understanding Clean Architecture
&lt;/h2&gt;

&lt;p&gt;Clean Architecture, popularized by Robert C. Martin, is a software design philosophy that separates the elements of a design into ring levels. The main rule of clean architecture is that code dependencies can only move from the outer levels inward. This means that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Business rules don't depend on UI or database.&lt;/li&gt;
&lt;li&gt;Business rules don't know anything about the outside world.&lt;/li&gt;
&lt;li&gt;The UI can change without changing the rest of the system.&lt;/li&gt;
&lt;li&gt;The database can be swapped out without affecting the business rules.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Benefits of Clean Architecture
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Independence of framework&lt;/strong&gt;: The architecture doesn't depend on the existence of some library of feature-laden software.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testability&lt;/strong&gt;: The business rules can be tested without the UI, database, web server, or any other external element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence of UI&lt;/strong&gt;: The UI can change easily, without changing the rest of the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence of Database&lt;/strong&gt;: You can swap out PostgreSQL for MongoDB, or something else entirely, without affecting the business rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Independence of any external agency&lt;/strong&gt;: Your business rules don't know anything about the outside world.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>go</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building a Robust E-Commerce Platform with Go, Clean Architecture, and PostgreSQL</title>
      <dc:creator>MOHAMED FAWAS</dc:creator>
      <pubDate>Fri, 04 Oct 2024 10:24:31 +0000</pubDate>
      <link>https://forem.com/mohamedfawas1/building-a-robust-e-commerce-platform-with-go-clean-architecture-and-postgresql-33l2</link>
      <guid>https://forem.com/mohamedfawas1/building-a-robust-e-commerce-platform-with-go-clean-architecture-and-postgresql-33l2</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Our goal is to develop a comprehensive e-commerce solution that can handle everything from product management to order processing. This platform will serve as a robust foundation for online businesses, capable of scaling to meet growing demands and adapting to changing market needs.&lt;/p&gt;

&lt;p&gt;Key features of our e-commerce platform include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User authentication and profile management&lt;/li&gt;
&lt;li&gt;Product catalog with categories and subcategories&lt;/li&gt;
&lt;li&gt;Shopping cart functionality&lt;/li&gt;
&lt;li&gt;Secure checkout process with multiple payment options (cash on delivery and razorpay)&lt;/li&gt;
&lt;li&gt;Order management &lt;/li&gt;
&lt;li&gt;Inventory management&lt;/li&gt;
&lt;li&gt;Coupon and discount system&lt;/li&gt;
&lt;li&gt;Wishlist functionality&lt;/li&gt;
&lt;li&gt;Admin panel for sales management&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Technologies and Architecture
&lt;/h2&gt;

&lt;p&gt;For this project, we're leveraging a powerful stack of modern technologies:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go (Golang): Our backend is built entirely in Go, known for its performance, simplicity, and excellent support for concurrent operations.&lt;/li&gt;
&lt;li&gt;PostgreSQL: As our primary database, PostgreSQL offers robust features for handling complex data relationships and transactions.&lt;/li&gt;
&lt;li&gt;Clean Architecture: We're structuring our application following clean architecture principles, ensuring our code is modular, testable, and maintainable.&lt;/li&gt;
&lt;li&gt;JWT (JSON Web Tokens): For secure authentication and authorization.&lt;/li&gt;
&lt;li&gt;Razorpay: Integrated for handling secure online payments.&lt;/li&gt;
&lt;li&gt;Cloudinary: For efficient management and delivery of product images.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;In the upcoming posts, we'll dive deep into each aspect of our e-commerce platform. We'll start by setting up our project structure, implementing our database schema, and gradually building out each feature.&lt;/p&gt;

&lt;p&gt;Whether you're a seasoned Go developer looking to explore clean architecture, or you're new to e-commerce development, this series will provide valuable insights and practical knowledge you can apply to your own projects.&lt;/p&gt;

&lt;p&gt;Stay tuned for our next post, where we'll set up the project structure and lay the groundwork for our e-commerce platform!&lt;/p&gt;

</description>
      <category>go</category>
      <category>webdev</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
