# yashbhagat/smit-erp architecture

> Architecture diagram of the GitHub repository yashbhagat/smit-erp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yashbhagat/smit-erp
- Repository: https://github.com/yashbhagat/smit-erp

## Overview

##### Main Components
- Application Shell: The core Angular app encapsulated in app.module.ts, which ties together routing (app-routing.module.ts), global assets (styles.scss, index.html), and application-wide services.
- Feature Modules/Components: The project is organized into clear business domains:
- Auth – Handles authentication (with an auth interceptor and associated guard for route protection).
- Cash Employee – Manages cash-related employee records with separate components for adding and viewing records.
- Company – Manages companies including adding companies, handling employee records, viewing company details, managing departments, and data download.
- Department – Deals with creating and viewing department details.
- Employee – Manages employee records with support for adding and displaying employee details.
- Transaction – Likely handles financial or other transaction-related information.
- User – Handles user-specific functionalities.
- Toolbar – Provides overall navigation.
- Service Layer: Contains services (e.g., ApiService, LocalService, OpenPopService) that encapsulate API calls and other utility functions.
- Models: A set of data models (company, department, employee, jwt-response, login, sign-up, user) to strongly type interactions across components and services.
- Guards & Interceptors: The Auth Guard and Auth Interceptor ensure that HTTP requests include proper authentication tokens and that route access is restricted.

##### Diagramming Relationships and Interactions
- From “App Routing Module” to each feature module, indicating route mapping.
- From the Auth component to Auth Interceptor and Guard to illustrate authentication flows.
- From Services to Model components, showing the data transformations using the defined data types.

##### Key Architectural Patterns and Design Principles
- Modular Design: Each domain is implemented as its own directory/component grouping, supporting separation of concerns and easier scalability.
- Layered Architecture: Presentation (components and views), business/service layer (ApiService, LocalService), and data models.
- Dependency Injection: Angular’s dependency management is evident especially for services and guards.
- Routing and Navigation: Centralized in the App Routing module which defines navigation paths to various components.
- Authentication and Authorization: Through the use of an Auth Interceptor and Auth Guard that protect routes and manage JWT tokens.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Application Shell
    subgraph "Application Shell"
        AppModule["App Module"]:::appShell
        AppRouting["App Routing Module"]:::appShell
    end

    %% Feature Modules
    subgraph "Feature Modules"
        %% Auth Module
        subgraph "Auth Module"
            AuthComp["Auth Component"]:::auth
            AuthInter["Auth Interceptor"]:::auth
            AuthGuard["Auth Guard"]:::auth
        end

        %% Cash Employee Module
        subgraph "Cash Employee Module"
            CashEmp["Cash Employee Component"]:::cash
            CashAddRec["Add Record Component"]:::cash
            CashAltAdd["Alternative Add Component"]:::cash
            CashViewRec["View Record Component"]:::cash
        end

        %% Company Module
        subgraph "Company Module"
            CompanyMain["Company Component"]:::company
            CompanyAdd["Add Company Component"]:::company
            CompanyAddEmp["Add Employee Record Component"]:::company
            DeptAdd["Dept - Add Department Component"]:::company
            DeptList["Dept - List Component"]:::company
            CompanyDetails["Company Details Component"]:::company
            DataDownload["Download Data Component"]:::company
            CompanyViewEmp["View Employee Record Component"]:::company
        end

        %% Department Module
        subgraph "Department Module"
            DeptMain["Department Component"]:::dept
            DeptAddComp["Add Department Component"]:::dept
            DeptDetails["Dept Details Component"]:::dept
        end

        %% Employee Module
        subgraph "Employee Module"
            EmpMain["Employee Component"]:::employee
            EmpAdd["Employee - Add Component"]:::employee
            EmpDetails["Employee Details Component"]:::employee
        end

        %% Transaction Module
        subgraph "Transaction Module"
            TransactionComp["Transaction Component"]:::transaction
        end

        %% User Module
        subgraph "User Module"
            UserMain["User Component"]:::user
            UserAdd["User - Add Component"]:::user
        end

        %% Toolbar
        subgraph "Toolbar"
            ToolbarComp["Toolbar Component"]:::toolbar
        end
    end

    %% Service Layer
    subgraph "Service Layer"
        ApiService["ApiService"]:::service
        LocalService["LocalService"]:::service
        OpenPopService["OpenPopService"]:::service
    end

    %% Data Models
    subgraph "Data Models"
        CompanyModel["Company Model"]:::dataModels
        DepartmentModel["Department Model"]:::dataModels
        EmployeeModel["Employee Model"]:::dataModels
        JwtResponseModel["JwtResponse Model"]:::dataModels
        LoginModel["Login Model"]:::dataModels
        SignUpModel["SignUp Model"]:::dataModels
        UserModel["User Model"]:::dataModels
    end

    %% Relationships from Application Shell to Feature Modules
    AppModule --> AppRouting
    AppRouting -->|"routes"| AuthComp
    AppRouting -->|"routes"| CashEmp
    AppRouting -->|"routes"| CompanyMain
    AppRouting -->|"routes"| DeptMain
    AppRouting -->|"routes"| EmpMain
    AppRouting -->|"routes"| TransactionComp
    AppRouting -->|"routes"| UserMain
    AppRouting -->|"routes"| ToolbarComp

    %% Auth Module internal flow
    AuthComp -->|"triggers"| AuthInter
    AuthComp -->|"triggers"| AuthGuard

    %% Feature Modules call Service Layer (ApiService)
    AuthComp -->|"calls"| ApiService
    CashEmp -->|"calls"| ApiService
    CompanyMain -->|"calls"| ApiService
    DeptMain -->|"calls"| ApiService
    EmpMain -->|"calls"| ApiService
    TransactionComp -->|"calls"| ApiService
    UserMain -->|"calls"| ApiService
    ToolbarComp -->|"calls"| ApiService

    %% ApiService uses Data Models
    ApiService -->|"maps to"| CompanyModel
    ApiService -->|"maps to"| DepartmentModel
    ApiService -->|"maps to"| EmployeeModel
    ApiService -->|"maps to"| JwtResponseModel
    ApiService -->|"maps to"| LoginModel
    ApiService -->|"maps to"| SignUpModel
    ApiService -->|"maps to"| UserModel

    %% Styling classes
    classDef appShell fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef auth fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef cash fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef company fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef dept fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef employee fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef transaction fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef user fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;
    classDef toolbar fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef service fill:#F0B27A,stroke:#E67E22,stroke-width:2px;
    classDef dataModels fill:#AED6F1,stroke:#1F618D,stroke-width:2px;

    %% Click Events - Application Shell
    click AppModule "https://github.com/yashbhagat/smit-erp/blob/master/src/app/app.module.ts"
    click AppRouting "https://github.com/yashbhagat/smit-erp/blob/master/src/app/app-routing.module.ts"

    %% Click Events - Auth Module
    click AuthComp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/auth/auth.component.ts"
    click AuthInter "https://github.com/yashbhagat/smit-erp/blob/master/src/app/auth-interceptor.ts"
    click AuthGuard "https://github.com/yashbhagat/smit-erp/blob/master/src/app/guard/auth.guard.ts"

    %% Click Events - Cash Employee Module
    click CashEmp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/cash-employee/cash-employee.component.ts"
    click CashAddRec "https://github.com/yashbhagat/smit-erp/blob/master/src/app/cash-employee/add-record/add-record.component.ts"
    click CashAltAdd "https://github.com/yashbhagat/smit-erp/blob/master/src/app/cash-employee/add/add.component.ts"
    click CashViewRec "https://github.com/yashbhagat/smit-erp/blob/master/src/app/cash-employee/view-record/view-record.component.ts"

    %% Click Events - Company Module
    click CompanyMain "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/company.component.ts"
    click CompanyAdd "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/add-company/add-company.component.ts"
    click CompanyAddEmp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/add-employee-record/add-employee-record.component.ts"
    click DeptAdd "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/department-add/department-add.component.ts"
    click DeptList "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/department-list/department-list.component.ts"
    click CompanyDetails "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/details/details.component.ts"
    click DataDownload "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/download-data/download-data.component.ts"
    click CompanyViewEmp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/company/view-employee-record/view-employee-record.component.ts"

    %% Click Events - Department Module
    click DeptMain "https://github.com/yashbhagat/smit-erp/blob/master/src/app/department/department.component.ts"
    click DeptAddComp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/department/add-department/add-department.component.ts"
    click DeptDetails "https://github.com/yashbhagat/smit-erp/blob/master/src/app/department/details/details.component.ts"

    %% Click Events - Employee Module
    click EmpMain "https://github.com/yashbhagat/smit-erp/blob/master/src/app/employee/employee.component.ts"
    click EmpAdd "https://github.com/yashbhagat/smit-erp/blob/master/src/app/employee/add/add.component.ts"
    click EmpDetails "https://github.com/yashbhagat/smit-erp/blob/master/src/app/employee/employee-details/employee-details.component.ts"

    %% Click Event - Transaction Module
    click TransactionComp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/transaction/transaction.component.ts"

    %% Click Events - User Module
    click UserMain "https://github.com/yashbhagat/smit-erp/blob/master/src/app/user/user.component.ts"
    click UserAdd "https://github.com/yashbhagat/smit-erp/blob/master/src/app/user/add/add.component.ts"

    %% Click Event - Toolbar
    click ToolbarComp "https://github.com/yashbhagat/smit-erp/blob/master/src/app/toolbar/toolbar.component.ts"

    %% Click Events - Service Layer
    click ApiService "https://github.com/yashbhagat/smit-erp/blob/master/src/app/service/api.service.ts"
    click LocalService "https://github.com/yashbhagat/smit-erp/blob/master/src/app/service/local.service.ts"
    click OpenPopService "https://github.com/yashbhagat/smit-erp/blob/master/src/app/service/open-pop.service.ts"

    %% Click Events - Data Models
    click CompanyModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/company.ts"
    click DepartmentModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/department.ts"
    click EmployeeModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/employee.ts"
    click JwtResponseModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/jwt-response.ts"
    click LoginModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/login.ts"
    click SignUpModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/sign-up.ts"
    click UserModel "https://github.com/yashbhagat/smit-erp/blob/master/src/app/model/user.ts"
```
