# mohamedabi17/pharmacie-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedabi17/pharmacie-web-app
- Repository: https://github.com/mohamedabi17/pharmacie-web-app

## Overview

##### Main Components
- Frontend Application (pharmacie_front): Built with React/Next.js and Tailwind CSS. It includes multiple routes (e.g., landing, login, admin, search, product details) and shared components (like the navbar, footer, dashboard, etc.).
- Backend Application (pharmacie_backend): An Express/Node.js server managing API endpoints with routes, middleware, and models (User, Medicament, Order, Payment, etc.). It likely interacts with a MongoDB database (as indicated by the README’s MongoDB reference).
- Database (MongoDB): Although not directly visible in the file tree, the README tells us that MongoDB is used for data persistence (storing inventory, prescriptions, orders, etc.).

##### Relationships and Interactions
- User Interactions: Users access the web application through the frontend. They authenticate, browse inventory, place orders, and manage prescriptions.
- Request Flow: Data flows from the frontend to the backend through RESTful endpoints. Security is implied with JWTs for authentication.
- Data Persistence: The backend communicates with the MongoDB database using models defined in the project (Category, Medicament, Order, etc.). The backend routes (pharmacieRouter.js) handle the requests and pass data to/from the database.
- Middleware: The backend’s middleware (in /middleware) processes requests, possibly handling authentication checks or error handling.

##### Architectural Patterns and Key Technologies
- MVC / RESTful API Pattern: The backend organizes code with models (data), routes (controllers), and middleware (business logic, security), while the frontend uses Next.js’s file-based routing.
- Micro Frontend Components: The frontend is broken into clearly defined pages and components, hinting at a modular design.
- Security & Authentication: JWT is used for secure user authentication and authorizations.
- Separation of Concerns: The project cleanly separates presentation (pharmacie_front) from business logic and data handling (pharmacie_backend).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser("User/Browser"):::user

    subgraph "Frontend Layer"
        Frontend("Frontend (pharmacie_front)"):::frontend
        Landing("Landing Page"):::frontend
        Login("Login Page"):::frontend
        LoginServer("Login Server Logic"):::frontend
        Admin("Admin Page"):::frontend
        Dashboard("Dashboard Page"):::frontend
        Search("Search Page"):::frontend
        ProdDetails("Product Details"):::frontend
        Overview("Overview Page"):::frontend
    end

    subgraph "Backend Layer"
        Backend("Backend (pharmacie_backend)"):::backend
        API("API Endpoints (pharmacieRouter.js)"):::backend
        Middleware("Middleware (JWT/Auth)"):::backend
        Models("Data Models"):::backend
    end

    subgraph "Database Layer"
        DB("MongoDB"):::database
    end

    Browser -->|"access"| Frontend
    Frontend -->|"APIRequests"| API

    Landing -->|"callsAPI"| API
    Login -->|"authCall"| Middleware
    Login -->|"callsAPI"| API
    Admin -->|"adminActions"| API
    Dashboard -->|"dashboardAPI"| API
    Search -->|"searchAPI"| API
    ProdDetails -->|"productAPI"| API
    Overview -->|"overviewAPI"| API

    API -->|"passesTo"| Middleware
    API -->|"dataOps"| Models
    Middleware -->|"processesFor"| Models
    Models -->|"persistsTo"| DB

    click Frontend "https://github.com/mohamedabi17/pharmacie-web-app/tree/main/Pharmacie_front/"
    click Landing "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/Landing.tsx"
    click Login "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/login/page.tsx"
    click LoginServer "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/login/server.tsx"
    click Admin "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/admin/page.tsx"
    click Dashboard "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/dashboard/page.tsx"
    click Search "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/search/page.tsx"
    click ProdDetails "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/Details.tsx"
    click Overview "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/Pharmacie_front/app/overview/[id]/page.tsx"
    click Backend "https://github.com/mohamedabi17/pharmacie-web-app/tree/main/pharmacie_backend/"
    click API "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/pharmacie_backend/routes/pharmacieRouter.js"
    click Middleware "https://github.com/mohamedabi17/pharmacie-web-app/blob/main/pharmacie_backend/middleware/middleware.js"
    click Models "https://github.com/mohamedabi17/pharmacie-web-app/tree/main/pharmacie_backend/models/"

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef user fill:#FFD700,stroke:#000,stroke-width:2px;
```
