GithubHelp home page GithubHelp logo

turhany / immicro Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 905 KB

This is a simple/reusable micro/macro service template/playground project.

License: GNU General Public License v3.0

C# 97.92% Dockerfile 2.08%

immicro's Introduction

ImMicro

alt tag alt tag

This is a simple/reusable micro/macro service template/playground project.

Features

  • Simple Login flow
  • User List(Search), CRUD flow
  • AuditLog List(Search), Export, Get flow
  • Product List(Search), CRUD flow
  • MessageQueue flow
  • AOP flow (PerformanceAspect)
  • Multi Language support
  • Api Versionun
  • Rate Limiting (InMemory mode)
  • Swagger implementation
  • Hangfire background task flow
  • Unit/Benchmark Test projects

Structure

  • API: Endpoint project for client usage
  • Business: Project for business logic
  • Common: Cross cutting consern items (like cache, lock...)
  • Container: DI configuration project
  • Contract: Dtos, layer transfer and api response - request objects
  • Data: Database layer files (Ef(Core) implementations and repositories)
  • Model: Database entity models
  • Resources: Language resx files project
  • Messaging/Consumer: Message service(RabbitMQ) implementation project
  • ScheduleService: Schedule tasks project
  • Tests: Unit and Benchmark test projects
    alt tag

Technologies

Before Usage

  • If you want to use local environment, you need to update Redis and PostgreSql connection strings in API project (appsettings.json)
    • DBConnectionString field for PostgreSql
    • RedisConnectionString field for DistributedCache
    • Distributed Lock Settings (RedLockSettings)
      • RedLockHostAddress
      • RedLockHostPort
      • RedLockHostPassword > if you dont have pass you need to set it null
      • RedLockHostSsl
    • Message Queue Settings (RabbitMqSettings)
      • HostAddress
      • UserName
      • Password
      • Also need to add your queue names here like "SampleQueue" and in C# "RabbitMqOption" class for option mapping
  • Also project has ready to run Docker support
    • docker-compose file store in solution directory
    • All connection string stores in appsettings.DockerCompose.json environment file

For local Development - Docker Run Codes

  • PostgreSQL > docker run --name postgressqlcontainer -p 5432:5432 -e POSTGRES_PASSWORD=123456789.tY -d postgres
  • Redis > docker run --name redis -p 6379:6379 -d redis --requirepass 123456789.tY
  • RabbitMQ > docker run -d --hostname rabbitmq --name rabbitmq -p 15672:15672 -p 5672:5672 rabbitmq:3.10.1-management
    • Default username and password: guest

GUI's

SonarQube Test Preperation

  • docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9000:9000 sonarqube:latest
  • SonarQube need java install it before continue https://www.oracle.com/java/technologies/downloads/
  • SonarQube Url: http://localhost:9000
    • Username: admin
    • Password: admin
  • Open SonarQube and login the system
  • Select "Manually" project type
  • Fill the "Display Name" and "Key" area for example "ImMicro" and clik setup
  • Select "Locally" option
  • Fill "Token Name" for example "ImMicroToken" and click generate
  • Then you will see you token copy it and click continue
  • Select ".Net" after that select ".Net Core" build tool then you will see you SonarQube run commands like this ss
  • Open command propt in your app foler and run them step by step alt tag

EF Migration Codes

  • update-database -context ImMicro.Data.DataContext
  • add-migration migrationName -context ImMicro.Data.DataContext

Database Maintenance (PostgreSql)

--ReIndex
REINDEX TABLE "AuditLog";
REINDEX TABLE "Category";
REINDEX TABLE "Product";
REINDEX TABLE "RequestLog";
REINDEX TABLE "User" ;

--Vacuum
Vacuum full Verbose "AuditLog";
Vacuum full Verbose "Category";
Vacuum full Verbose "Product";
Vacuum full Verbose "RequestLog";
Vacuum full Verbose "User";

-- Find Expensive Queries
SELECT queryid, calls, mean_time, substring(query for 100)
FROM pg_stat_statements 
ORDER BY total_time DESC LIMIT 3;

--Analyze Expensive Query Sample
--Online Suggestion Website > https://explain.depesz.com/
EXPLAIN ANALYZE SELECT * FROM "User" WHERE "Email" = '[email protected]';

Usages

  • Application has multi language support for demo pupose now TR and EN
  • Before request auth need endpoints like User and Product endpoints first need to Login over login/token enpoint
    • Accept-Language can set "tr-TR" or "en-US"
    • Login Email: [email protected]
    • Login Pass: 123456789.tY
  • When you get token from login/token Endpoint "accessToken" field can set swagger "Authorize" area with "Bearer {accessToken}" syntax

Swagger Endpoint

Schedule Service Hangfire Endpoint

Healt Check Endpoints

All Routes List Endpoint

Code Coverage

alt tag

SonarQube Test Results

alt tag

immicro's People

Contributors

turhany avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

immicro's Issues

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.