# gantrace/agrodigital--frontendapp architecture

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

- Interactive diagram: https://gitdiagram.com/gantrace/agrodigital--frontendapp
- Repository: https://github.com/gantrace/agrodigital--frontendapp

## Overview

##### Project type and purpose
- This is a single-page, role-based Angular front-end application (“AgroDigitalFrontendApp”) backed by a local JSON server (in the `server/` folder) for prototyping a REST API.
- It supports three user roles or feature areas—Public, Rancher, Veterinarian—plus shared services and utilities.

##### File structure
- Top-level configuration and build files: `angular.json`, `tsconfig*.json`, `package.json`, `.editorconfig`, etc.
- `public/`: static assets (i18n files, images).
- `src/app/`: main app folder
- `app.routes.ts` & `app.config.ts`: global routes & configuration
- `public/`, `rancher/`, `veterinarian/`: three feature areas each with components/pages + services
- `shared/services`: cross-cutting, base HTTP service
- `server/`: JSON-Server config (`db.json`, `routes.json`, start scripts) to simulate a RESTful backend.

##### README
- Confirms an Angular CLI v19 app
- Development workflow: `ng serve`, build, test runners
- No production backend described—JSON server is the only “server.”

##### Main components and interactions
a. Browser / Client
- Hosts the Angular SPA.
- Sends HTTP requests via Angular’s `HttpClient`.
b. Angular App (Container)
- Presentation Layer (Components + Templates)
– Public Module: login/register/settings, header/footer, language switching
– Rancher Module: dashboard, animals, events, economic control, medical history, reports
– Veterinarian Module: vet-dashboard, patients, patient-details, medical-appointments/records, treatments
- Routing Layer (`app.routes.ts`)
- Service Layer
– Feature services (e.g., `animal.service.ts`, `auth.service.ts`)
– Shared/base services (`base.service.ts`)
- Environment Configuration (`environment.ts`)
c. JSON Server (Backend Stub)
- `db.json`: mock data store
- `routes.json`: custom route mappings
- Exposes REST endpoints (e.g., `/animals`, `/events`, `/users`, `/appointments`)
d. Static Assets / i18n
- Served from `public/assets/i18n/*.json`
- Used by Angular’s i18n or translation service

##### Architectural patterns and design principles
- Module-based feature isolation (Angular modules for Public, Rancher, Veterinarian)
- Dependency injection for services
- Single Responsibility: each service handles one resource
- Routing + lazy loading (if configured) to split bundles by module
- Shared service abstraction (`base.service.ts`) to standardize HTTP calls

##### Summary
- Break the system into: User(s), Angular SPA (with its sub-modules and service layer), and JSON Server (data layer).
- Routing, DI, HTTP interactions, and i18n.
- Keep it detailed but focused on the three feature modules plus shared infrastructure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    subgraph "Users"
        PU["Public User"]:::actor
        RU["Rancher User"]:::actor
        VU["Veterinarian User"]:::actor
    end
    PU -->|uses| Browser["Browser"]:::browser
    RU -->|uses| Browser
    VU -->|uses| Browser

    Browser -->|loads SPA| SPA["Angular SPA<br>(Angular 19, TypeScript, RxJS)"]:::app

    %% Angular Application
    subgraph "Angular SPA"
        direction TB
        Routing["Routing Module"]:::routing
        Config["App Config"]:::config
        Env["Environment Config"]:::config
        i18nService["i18n Translation Service"]:::i18n
        subgraph "Presentation Layer"
            direction TB
            PublicModule["Public Module"]:::public
            RancherModule["Rancher Module"]:::rancher
            VeterinarianModule["Veterinarian Module"]:::veterinarian
        end
        subgraph "Service Layer"
            direction TB
            BaseService["BaseService"]:::service
            AuthService["AuthService"]:::service
            UserService["UserService"]:::service
            AnimalService["AnimalService"]:::service
            EventService["EventService"]:::service
            EconomicService["EconomicService"]:::service
            MedicalHistoryService["MedicalHistoryService"]:::service
            AppointmentService["AppointmentService"]:::service
            MedicalRecordService["MedicalRecordService"]:::service
            PatientService["PatientService"]:::service
            PatientEventService["PatientEventService"]:::service
            TreatmentsService["TreatmentsService"]:::service
        end

        %% DI and Routing
        PublicModule -->|uses| AuthService
        PublicModule -->|uses| UserService
        RancherModule -->|uses| AnimalService
        RancherModule -->|uses| EventService
        RancherModule -->|uses| EconomicService
        RancherModule -->|uses| MedicalHistoryService
        VeterinarianModule -->|uses| AppointmentService
        VeterinarianModule -->|uses| MedicalRecordService
        VeterinarianModule -->|uses| PatientService
        VeterinarianModule -->|uses| PatientEventService
        VeterinarianModule -->|uses| TreatmentsService
        BaseService -->|extended by| AuthService
        BaseService -->|extended by| UserService
        BaseService -->|extended by| AnimalService
        BaseService -->|extended by| EventService
        BaseService -->|extended by| EconomicService
        BaseService -->|extended by| MedicalHistoryService
        BaseService -->|extended by| AppointmentService
        BaseService -->|extended by| MedicalRecordService
        BaseService -->|extended by| PatientService
        BaseService -->|extended by| PatientEventService
        BaseService -->|extended by| TreatmentsService

        Routing -->|routes to| PublicModule
        Routing -->|routes to| RancherModule
        Routing -->|routes to| VeterinarianModule
        Config -->|configures| SPA
        Env -->|provides| SPA
        i18nService -->|loads assets| I18nAssets["i18n Assets"]:::asset
    end

    SPA -->|HTTP requests| JSONServer["JSON Server"]:::backend
    JSONServer -->|uses| DB["db.json"]:::database
    JSONServer -->|maps routes| Routes["routes.json"]:::backend
    I18nAssets -->|GET| SPA

    %% Click Events
    click PublicModule "https://github.com/gantrace/agrodigital--frontendapp/tree/develop/src/app/public"
    click AuthService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/public/services/auth.service.ts"
    click UserService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/public/services/user.service.ts"
    click RancherModule "https://github.com/gantrace/agrodigital--frontendapp/tree/develop/src/app/rancher"
    click AnimalService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/rancher/services/animal.service.ts"
    click EventService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/rancher/services/event.service.ts"
    click EconomicService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/rancher/services/economic.service.ts"
    click MedicalHistoryService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/rancher/services/medical-history.service.ts"
    click VeterinarianModule "https://github.com/gantrace/agrodigital--frontendapp/tree/develop/src/app/veterinarian"
    click AppointmentService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/veterinarian/services/appointment.service.ts"
    click MedicalRecordService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/veterinarian/services/medical-record.service.ts"
    click PatientService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/veterinarian/services/patient.service.ts"
    click PatientEventService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/veterinarian/services/patient-event.service.ts"
    click TreatmentsService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/veterinarian/services/treatments.service.ts"
    click BaseService "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/shared/services/base.service.ts"
    click Routing "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/app.routes.ts"
    click Config "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/app/app.config.ts"
    click Env "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/src/environments/environment.ts"
    click I18nAssets "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/public/assets/i18n/en.json"
    click DB "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/server/db.json"
    click Routes "https://github.com/gantrace/agrodigital--frontendapp/blob/develop/server/routes.json"

    %% Styles
    classDef actor fill:#f9f,stroke:#333,stroke-width:1px
    classDef browser fill:#bbf,stroke:#333,stroke-width:1px
    classDef app fill:#ddd,stroke:#333,stroke-width:1px
    classDef routing fill:#ffe082,stroke:#333,stroke-width:1px
    classDef config fill:#fff59d,stroke:#333,stroke-width:1px
    classDef i18n fill:#f8bbd0,stroke:#333,stroke-width:1px
    classDef public fill:#90caf9,stroke:#333,stroke-width:1px
    classDef rancher fill:#a5d6a7,stroke:#333,stroke-width:1px
    classDef veterinarian fill:#ffcc80,stroke:#333,stroke-width:1px
    classDef service fill:#ce93d8,stroke:#333,stroke-width:1px
    classDef backend fill:#b0bec5,stroke:#333,stroke-width:1px
    classDef database fill:#78909c,stroke:#333,stroke-width:1px
    classDef asset fill:#f48fb1,stroke:#333,stroke-width:1px
```
