# ahsanu123/planerp architecture

> Architecture diagram of the GitHub repository ahsanu123/planerp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahsanu123/planerp
- Repository: https://github.com/ahsanu123/planerp

## Overview

##### Main Components

Frontend Layer:
- Angular SPA (spa directory)
- React SPA (spa_react directory)
- Both as they seem to be alternative frontends
- UI components and state management

API Layer:
- ASP.NET Core Backend (api directory)
- GraphQL endpoints
- REST Controllers
- OpenID Connect/OAuth authentication

Service Layer:
- Event Bus (RabbitMQ implementation)
- Authentication/Authorization service (learn-auth directory)
- File storage service
- PostgreSQL database service

##### Key Relationships to Highlight

a. Client-Server Communication:
- Frontend → API (HTTP/GraphQL)
- Authentication flows
- Real-time updates via event bus

b. Service Integration:
- API → Database
- API → Message Queue
- API → File Storage
- Authentication service interactions

##### Specific Implementation Details

Database:
- PostgreSQL with custom types
- Dapper for data access
- FluentMigrator for schema management

Authentication:
- OpenIddict implementation
- Custom identity providers
- Role-based access control

Event Processing:
- RabbitMQ message broker
- Event bus abstraction
- Integration events

**[Frontend Layer]**
**Angular SPA ←→ React SPA**
- ↓         ↓
**[API Gateway Layer]**
- REST/GraphQL APIs
- ↓         ↓
**[Service Layer]**
**Auth Service  Event Bus  File Service**
- ↓         ↓          ↓
**[Data Layer]**
- PostgreSQL Database

##### Additional Elements

Security Layer:
- OAuth2/OpenID Connect flows
- Identity provider integration
- Role-based access control

Deployment Components:
- Docker containers (shown from dockerfile directory)
- Service orchestration
- Infrastructure components

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#9b59b6,stroke:#8e44ad,color:white
    classDef eventbus fill:#e67e22,stroke:#d35400,color:white
    classDef file fill:#1abc9c,stroke:#16a085,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Angular["Angular SPA"]
        React["React SPA"]
        AngularComponents["Components"]
        AngularPages["Pages"]
        AngularServices["Services"]
        ReactComponents["Components"]
        ReactPages["Pages"]
        ReactAPI["API Integration"]
    end

    %% API Gateway Layer
    subgraph APIGateway
        REST["REST Controllers"]
        GraphQL["GraphQL Endpoint"]
        DBContext["Database Context"]
        Models["Data Models"]
    end

    %% Service Layer
    subgraph Services
        AuthService["Authentication Service"]
        EventBus["Event Bus (RabbitMQ)"]
        FileService["File Storage Service"]
        
        subgraph AuthComponents
            CoreAuth["Core Auth"]
            IdentityProviders["Identity Providers"]
            OAuth["OAuth Implementation"]
        end
    end

    %% Data Layer
    subgraph DataLayer
        PostgreSQL[(PostgreSQL Database)]
        Schema["Database Schema"]
        Migrations["Database Migrations"]
        CustomTypes["Custom Types"]
    end

    %% Relationships
    Angular --> REST & GraphQL
    React --> REST & GraphQL
    
    Angular --- AngularComponents & AngularPages & AngularServices
    React --- ReactComponents & ReactPages & ReactAPI
    
    REST & GraphQL --> DBContext
    DBContext --> Models
    
    REST & GraphQL --> AuthService
    REST & GraphQL --> EventBus
    REST & GraphQL --> FileService
    
    AuthService --- CoreAuth & IdentityProviders & OAuth
    
    DBContext --> PostgreSQL
    PostgreSQL --- Schema & Migrations & CustomTypes
    
    %% Click Events
    click Angular "https://github.com/ahsanu123/planerp/tree/main/spa"
    click AngularComponents "https://github.com/ahsanu123/planerp/tree/main/spa/src/app/component"
    click AngularPages "https://github.com/ahsanu123/planerp/tree/main/spa/src/app/page"
    click AngularServices "https://github.com/ahsanu123/planerp/tree/main/spa/src/app/services"
    
    click React "https://github.com/ahsanu123/planerp/tree/main/spa_react"
    click ReactComponents "https://github.com/ahsanu123/planerp/tree/main/spa_react/src/component"
    click ReactPages "https://github.com/ahsanu123/planerp/tree/main/spa_react/src/page"
    click ReactAPI "https://github.com/ahsanu123/planerp/tree/main/spa_react/src/api"
    
    click REST "https://github.com/ahsanu123/planerp/tree/main/api/Controllers"
    click GraphQL "https://github.com/ahsanu123/planerp/tree/main/api/GraphQLController"
    click DBContext "https://github.com/ahsanu123/planerp/tree/main/api/DbContext"
    click Models "https://github.com/ahsanu123/planerp/tree/main/api/Model"
    
    click EventBus "https://github.com/ahsanu123/planerp/tree/main/api/EventBus"
    click AuthService "https://github.com/ahsanu123/planerp/tree/main/learn-auth"
    click CoreAuth "https://github.com/ahsanu123/planerp/tree/main/learn-auth/Authorization"
    click IdentityProviders "https://github.com/ahsanu123/planerp/tree/main/learn-auth/Identity"
    click OAuth "https://github.com/ahsanu123/planerp/tree/main/learn-auth/Identity/OAuth"
    
    click Schema "https://github.com/ahsanu123/planerp/tree/main/sql/public"
    click Migrations "https://github.com/ahsanu123/planerp/tree/main/api/Migration"
    click CustomTypes "https://github.com/ahsanu123/planerp/tree/main/api/Sql/types"
    
    click FileService "https://github.com/ahsanu123/planerp/blob/main/api/Services/FileUtilService.cs"
    
    %% Style Applications
    class Angular,AngularComponents,AngularPages,AngularServices,React,ReactComponents,ReactPages,ReactAPI frontend
    class REST,GraphQL,DBContext,Models api
    class AuthService,CoreAuth,IdentityProviders,OAuth auth
    class EventBus eventbus
    class FileService file
    class PostgreSQL,Schema,Migrations,CustomTypes database
```
