Coder Social home page Coder Social logo

mohamed-malk / onion-arch-dotnet Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11.81 MB

This Repo demonstrate the implementation of Onion Architecture in dotnet Web-API app

License: Apache License 2.0

C# 60.86% CSS 0.59% HTML 17.93% JavaScript 20.61%
css dotnet-core enityframework html javascript onion-architecture webapi webapp

onion-arch-dotnet's Introduction

Onion Architecture in .NET Core with EF Code First

This repository demonstrates the implementation of the Onion Architecture in .NET Core using the Entity Framework (EF) Code First approach.

Overview

Onion Architecture is a software architectural pattern that provides a way to structure an application to manage dependencies. The core idea is to build the application around an independent domain layer, with other layers (such as infrastructure and UI) depending on the domain layer, but not on each other.

Advantages of the Onion Architecture

All of the layers interact with each other strictly through the interfaces defined in the layers below. The flow of dependencies is towards the core of the Onion.

Using dependency inversion throughout the project, depending on abstractions (interfaces) and not the implementations, allows us to switch out the implementation at runtime transparently. We are depending on abstractions at compile-time, which gives us strict contracts to work with, and we are being provided with the implementation at runtime.

Entities

The database contains two main entities:

  • Student: Represents the students in the system.
  • Department: Represents the departments to which students can belong.

EF Code First Approach

The EF Code First approach is used to define the database schema using C# classes. Migrations are used to update the database schema as the model changes over time.

Project Structure

Server Side

The project is structured into multiple layers:

  • Domain Layer: Contains the entities and business logic.
  • Service or Application Layer: Contains services that coordinate between the domain and infrastructure layers.
  • Infrastructure Layer: Contains the EF DbContext, repositories, and other infrastructure-related code.
  • Presentation Layer: The entry point of the application, typically a web API project.

Onion Arch

Client Side

Simple Web app to test a web API project:

  • Department Page: call Department Controller
  • Student Page: call Student Controller

Getting Started

To get started with this project:

  1. Clone the repository.
  2. Ensure you have .NET Core installed.
  3. Navigate to the project directory and run dotnet restore to restore the packages.
  4. Run dotnet ef migrations add InitialCreate to create the initial migration.
  5. Run dotnet ef database update to apply the migration to the database.
  6. Start the application with dotnet run.

License

This project is licensed under the Apache License - see the LICENSE file for details.

Refrences

Code Maze

onion-arch-dotnet's People

Contributors

mohamed-malk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.