Skip to content

igor-u/jambo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jambo Web API

Overview

This project serves as an experimental exploration of the ASP.NET Core framework within the context of photovoltaic solar energy. It focuses on three core model classes: solar panels, solar inverters, and solar power plants.

Entity Relationship Diagram

%%{init: {
  "theme": "default",
  "themeCSS": [
    ".er.relationshipLabel { fill: white ; }",
    ".er.attributeBoxEven { fill : black; }",
    ".er.attributeBoxOdd { fill : black; }",
    ".er.attributeBoxEven { stroke : #e0e000; }",
    ".er.attributeBoxOdd { stroke : #e0e000; }",
    ".er.entityLabel { fill: white; }",
    ".er.relationshipLabelBox { fill: transparent; }", 
    ".er.entityBox { fill: black; }",
    ".er.entityBox { stroke: #e0e000; }"
    ]
}}%%
erDiagram
      SolarPowerPlant o|--|{ SolarPanel : has
      SolarPowerPlant o|--|{ SolarInverter : has
      SolarPowerPlant {
        bigint Id PK
        varchar(19) Coordinates
        int TotalSolarPanelWattage
        int TotalSolarInverterWattage
    }
      SolarPanel{
        varchar(12) SerialNumber PK
        int Power
        bigint SolarPowerPlantId
      }
      SolarInverter{
        varchar(12) SerialNumber PK
        int RatedPower
        int PeakPower
        bigint SolarPowerPlantId
      }
Loading

Tools

Architecture

For this practice, MVC and REST were utilized separately. The view layer is responsible for displaying data (using the GET method), while the POST method is accessible through API testing platforms such as Postman or Insomnia. A collection of requests can be found in the Jambo.postman_collection.json file. The collection can be imported into either tool to execute the requests after running the project.

Objectives

  • Learn about the C# programming language
  • Learn more about object relational mapping
  • Learn how to containerize a .NET application.

Database

This project utilizes MySQL as the primary database. The connection between the ASP.NET application and the MySQL server is established using Pomelo.EntityFrameworkCore.MySql, an open-source provider for Entity Framework Core that supports MySQL.

  • Server: Localhost was used.
  • MySQL Server: Ensure the MySQL server is operational:

To create the database, along with its tables:

  • Navigate to the project's src/ directory in your terminal.
  • Apply migrations:
dotnet ef database update

Tests

To run the tests in this .NET application, execute the following command in the project's src/ directory:

dotnet test

Running the Project

This project can be run in two ways:

  1. Using dotnet run
  • Navigate to the project's src/ directory in your terminal.
  • Run the following command:
dotnet run

The application will start and be accessible through http://localhost:5171.

  1. Using Docker
  • Navigate to the project's src/ directory in your terminal.
  • Build the Docker image:
docker build -t jambo-web-api .

Run a container using the built image:

docker run --network host jambo-web-api --rm

The --network host parameter is used to make the container share the host machine's network. This allows the container to directly access local services, such as the database.

The application will start and be accessible through http://localhost:8080.

About EF Core

For in-depth information on Entity Framework Core concepts used in this project, please refer to the official Microsoft documentation:

Conventions for relationship discovery

Eager Loading of Related Data

Shadow and Indexer Properties

About

A CRUD API that revolves around solar power systems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published