How karthikeyanvk18/e-medicare works
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)