# karthikeyanvk18/e-medicare architecture

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

- Interactive diagram: https://gitdiagram.com/karthikeyanvk18/e-medicare
- Repository: https://github.com/karthikeyanvk18/e-medicare

## Overview

##### Project Type and Purpose
- This is a single-page application built with Angular (TypeScript), serving as an e-commerce front end (“E-medicare”) for browsing and purchasing medicines.
- It uses a JSON file (db.json) as a mock REST API (e.g., via json-server).

##### Main Architectural Layers
A. Presentation Layer (Client Browser / Angular UI)
- Angular Components (in src/app/…):
– HomeComponent, AboutComponent, ContactComponent
– CategoryComponents: Analgesics, Antibiotics, Antipyretics, AllProducts
– Shopping Flow: CartComponent (+ CartService), CheckoutComponent, BillingComponent
– Authentication: UserLoginComponent, AdminLoginComponent, SignupComponent, LogoutComponent
– Misc: EmployeeUIComponent, ChangeComponent, ChecktqComponent
- Pipes: filter.pipe.ts, pipe.filter.ts
- Assets: images under src/assets
B. Service Layer (Business Logic)
- ApiService (api.service.ts): issues HTTP calls to the REST endpoints
- CartService (cart.service.ts): manages client-side cart state
C. Data Layer (Mock Backend)
- db.json: static JSON acting as data store for products, users, orders, etc.
- (Implicit) json-server or similar to expose REST endpoints at e.g. GET /products, POST /orders

##### Relationships & Data Flow
- User in Browser interacts with Angular Components (UI)
→ Components call ApiService / CartService
→ ApiService issues HTTP requests to JSON server (db.json)
→ JSON server returns data (medicine listings, user info, orders)
← ApiService returns Observable/data to Component
← Component updates view; CartService updates local cart model
- Login/Signup flows call ApiService endpoints (e.g. /users)
- Checkout calls ApiService to create orders, then BillingComponent displays confirmation

##### Important Patterns and Principles
- Component-Based Architecture: each feature is isolated in its own folder
- Service-Oriented: reusable services handle HTTP and state
- Angular’s Module System: app.module.ts wires Components, Services, Routing
- Single-Page App / Client-Side Routing: app-routing.module.ts
- Separation of Concerns: UI vs. business logic vs. data store

1. Client Browser / Presentation
2. Service Layer
3. Data Layer
– Component → ApiService (HTTP calls)
– ApiService → JSON server (REST API)
– CartComponent ↔ CartService (state management)
– ApiService → Components (data returns)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer (Client Browser)" 
        direction TB
        subgraph "Product Browsing"
            direction TB
            Home["HomeComponent"]:::frontend
            About["AboutComponent"]:::frontend
            Contact["ContactComponent"]:::frontend
            AllProducts["AllProductsComponent"]:::frontend
            Analgesics["AnalgesicsComponent"]:::frontend
            Antibiotics["AntibioticsComponent"]:::frontend
            Antipyretics["AntipyreticsComponent"]:::frontend
        end
        subgraph "Shopping Flow"
            direction TB
            Cart["CartComponent"]:::frontend
            Checkout["CheckoutComponent"]:::frontend
            Billing["BillingComponent"]:::frontend
        end
        subgraph "Authentication"
            direction TB
            UserLogin["UserLoginComponent"]:::frontend
            AdminLogin["AdminLoginComponent"]:::frontend
            Signup["SignupComponent"]:::frontend
            Logout["LogoutComponent"]:::frontend
        end
        subgraph "Miscellaneous"
            direction TB
            EmployeeUI["EmployeeUIComponent"]:::frontend
            Change["ChangeComponent"]:::frontend
            Checktq["ChecktqComponent"]:::frontend
        end
        subgraph "Utilities"
            direction TB
            FilterPipe["FilterPipe"]:::pipe
            PipeFilter["PipeFilter"]:::pipe
        end
        AppRouting["AppRoutingModule"]:::config
        AppModule["AppModule"]:::config
        Assets["Static Assets"]:::config
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        ApiService["ApiService"]:::service
        CartService["CartService"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        JSONServer["JSON Server"]:::data
        DB["db.json"]:::data
    end

    %% Config Layer
    subgraph "Configuration"
        direction TB
        EnvDev["environment.ts"]:::config
        EnvProd["environment.prod.ts"]:::config
    end

    %% Relationships
    Home -->|"calls GET /products"| ApiService
    About -->|"calls GET /about"| ApiService
    Contact -->|"calls GET /contact"| ApiService
    AllProducts -->|"calls GET /products"| ApiService
    Analgesics -->|"calls GET /products?category=analgesics"| ApiService
    Antibiotics -->|"calls GET /products?category=antibiotics"| ApiService
    Antipyretics -->|"calls GET /products?category=antipyretics"| ApiService

    Cart -->|"cart actions"| CartService
    CartService -->|updates state| Cart

    Cart -->|"calls POST /cart"| ApiService
    Checkout -->|"calls POST /orders"| ApiService
    Billing -->|"displays confirmation"| ApiService

    UserLogin -->|"calls POST /users/login"| ApiService
    AdminLogin -->|"calls POST /admin/login"| ApiService
    Signup -->|"calls POST /users"| ApiService
    Logout -->|"calls POST /users/logout"| ApiService

    EmployeeUI -->|"calls GET /employee"| ApiService
    Change -->|"calls PUT /items"| ApiService
    Checktq -->|"calls GET /tq"| ApiService

    ApiService -->|"HTTP GET/POST"| JSONServer
    JSONServer -->|serves data| DB

    ApiService -->|"returns Observable"| Home
    ApiService -->|"returns data"| Cart
    ApiService -->|"returns data"| Checkout

    EnvDev -->|configures| ApiService
    EnvProd -->|configures| ApiService

    AppRouting -->|wires routes| AppModule
    AppModule -->|declares components/services| Home
    AppModule -->|declares components/services| ApiService

    Assets -->|provides images| Home
    Assets -->|provides images| AllProducts

    %% Click Events
    click Home "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/home/home.component.ts"
    click About "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/about/about.component.ts"
    click Contact "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/contact/contact.component.ts"
    click AllProducts "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/allproducts/allproducts.component.ts"
    click Analgesics "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/analgesics/analgesics.component.ts"
    click Antibiotics "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/antibiotics/antibiotics.component.ts"
    click Antipyretics "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/antipyretics/antipyretics.component.ts"
    click Cart "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/cart/cart.component.ts"
    click Checkout "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/checkout/checkout.component.ts"
    click Billing "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/billing/billing.component.ts"
    click UserLogin "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/userlogin/userlogin.component.ts"
    click AdminLogin "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/adminlogin/adminlogin.component.ts"
    click Signup "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/signup/signup.component.ts"
    click Logout "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/logout/logout.component.ts"
    click EmployeeUI "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/employeeui/employeeui.component.ts"
    click Change "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/change/change.component.ts"
    click Checktq "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/checktq/checktq.component.ts"
    click FilterPipe "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/filter.pipe.ts"
    click PipeFilter "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/pipe.filter.ts"
    click ApiService "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/api.service.ts"
    click CartService "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/cart/cart.service.ts"
    click AppRouting "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/app-routing.module.ts"
    click AppModule "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/app/app.module.ts"
    click DB "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/db.json"
    click EnvDev "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/environments/environment.ts"
    click EnvProd "https://github.com/karthikeyanvk18/e-medicare/blob/main/medicineshopping/src/environments/environment.prod.ts"
    click Assets "https://github.com/karthikeyanvk18/e-medicare/tree/main/medicineshopping/src/assets/"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#339,stroke-width:1px
    classDef service fill:#DFF2D0,stroke:#393,stroke-width:1px
    classDef data fill:#FFE6CC,stroke:#E65,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#888,stroke-width:1px
    classDef pipe fill:#FFDDF4,stroke:#C39,stroke-width:1px
```
