# aureldp/ordonline architecture

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

- Interactive diagram: https://gitdiagram.com/aureldp/ordonline
- Repository: https://github.com/aureldp/ordonline

## Overview

##### Project Type & Purpose
- Ord'Online is a full-stack web application designed to digitalize and secure the exchange of medical prescriptions. It handles user registration/login for four roles (doctor, pharmacist, patient, health service) and supports prescription creation, modification, and search functionalities.
- The README clearly states the application’s main features (registration, login, prescription management) and the design is cross-platform and responsive.

##### Analyzing the File Structure
- There is a clear separation between the client and the server:
- The “client” folder contains a Vue.js application (evidenced by the App.vue, main.js, router, components, and use of Tailwind CSS). This part includes views and components for different pages like login, register, prescription, and user space.
- The “server” folder hosts the backend logic. It uses controllers for handling different roles (doctor, patient, pharma, user) and prescriptions, routes to define the API endpoints, repositories indicating separation of data access logic, middleware for authentication, and utility/helper methods for global functionality.
- This structure points to an MVC-like separation on the server, where controllers process the logic, repositories handle data persistence, and routes define the API endpoints.

##### Main Components
a. Client (Frontend):
- Built with Vue.js; components include global components (Navbar, Footer, Modal, etc.), page-specific components (LoginForm, RegisterForm, Prescription components), and views (HomeView, LoginView, etc.).
- Routing: Managed by the client/src/router indicating navigation between different application screens.
b. Server (Backend):
- API Server: Entry point is server/index.js. It manages REST API endpoints for each user role and prescription actions.
- Controllers: Modules that handle business logic (doctorController, patientController, etc.).
- Middleware: The auth middleware enforces authentication and security.
- Repositories: Separate data access layers (for users, prescriptions, statuses, etc.) that abstract database interactions.
- Utility/Helper Methods: GlobalMethods and other utilities used across the backend.
c. External/Underlying Database:
- Although not explicitly shown, the presence of repositories (e.g., prescriptionRepository, userRepository) indicates that a database is in use. Even if it’s not in the file tree, represent it symbolically as part of the architecture.

##### Relationships and Interactions
- Inside the server, illustrate the flow:
- Requests hit the appropriate Routes.
- Routes forward the requests to Controllers.
- Controllers call Repositories to read/write from the Data Store (database).
- Middleware (such as the auth.js) is invoked to validate requests.
- Communication between components with labels like “API Call”, “Data Fetch”, “Authentication Check”, etc.

##### Architectural Patterns & Design Principles
- MVC and RESTful patterns in the backend separation (controllers, routes, repositories).
- Clear separation of concerns between the client-side presentation (Vue components & routing) and the server-side business logic.
- Emphasis on cross-platform responsiveness in the frontend design.

##### Relevant Technologies
- Frontend: Vue.js, Tailwind CSS, JavaScript.
- Backend: Node.js (with Express or a similar framework), JavaScript, middleware for authentication.
- Repository patterns hinting at use of a database (e.g., MongoDB, PostgreSQL, etc.), though the specific database isn’t mentioned.
- Build tools: npm for dependency management and nodemon for server deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Section
    subgraph "Frontend"
        F0["Vue Frontend"]
        F1["Main Application"]
        F2["Router"]
        F3["Views"]
        F4["Global Components"]
        F5["Login Form"]
        F6["Register Form"]
        F7["Prescription Component"]
        
        F0 -->|"initializes"| F1
        F1 -->|"loads"| F2
        F2 -->|"renders"| F3
        F2 -->|"navigates to"| F5
        F2 -->|"navigates to"| F6
        F2 -->|"navigates to"| F7
        F3 -->|"displays"| F4
    end

    %% Communication from Frontend to Backend
    F1 -->|"API_Call"| B0

    %% Backend Section
    subgraph "Backend"
        B0["API Server"]
        B1["Routes"]
        B2["Auth Middleware"]
        B3["Controllers"]
        B4["Repositories"]
        B5["Utility Methods"]
        B6["Database"]
        
        B0 -->|"routes request"| B1
        B1 -->|"authenticates"| B2
        B1 -->|"forwards to"| B3
        B3 -->|"calls"| B4
        B4 -->|"persist/fetch data"| B6
        B3 -->|"utilizes"| B5
    end

    %% Click Events for Frontend
    click F0 "https://github.com/aureldp/ordonline/tree/main/client/"
    click F1 "https://github.com/aureldp/ordonline/blob/main/client/src/main.js"
    click F2 "https://github.com/aureldp/ordonline/blob/main/client/src/router/index.js"
    click F3 "https://github.com/aureldp/ordonline/tree/main/client/src/views/"
    click F4 "https://github.com/aureldp/ordonline/tree/main/client/src/components/globalComponents/"
    click F5 "https://github.com/aureldp/ordonline/blob/main/client/src/components/loginPage/LoginForm.vue"
    click F6 "https://github.com/aureldp/ordonline/blob/main/client/src/components/registerPage/RegisterForm.vue"
    click F7 "https://github.com/aureldp/ordonline/blob/main/client/src/components/prescriptionPage/Prescription.vue"

    %% Click Events for Backend
    click B0 "https://github.com/aureldp/ordonline/blob/main/server/index.js"
    click B1 "https://github.com/aureldp/ordonline/tree/main/server/routes/"
    click B2 "https://github.com/aureldp/ordonline/blob/main/server/middleware/auth.js"
    click B3 "https://github.com/aureldp/ordonline/tree/main/server/controller/"
    click B4 "https://github.com/aureldp/ordonline/tree/main/server/repository/"
    click B5 "https://github.com/aureldp/ordonline/blob/main/server/methods/globalMethods.js"

    %% Class Definitions for Styling
    class F0,F1,F2,F3,F4,F5,F6,F7 frontend
    class B0,B1,B3,B5 backend
    class B2 middleware
    class B4 dataLayer
    class B6 external

    %% Style Declarations
    classDef frontend fill:#a2d2ff,stroke:#084298,stroke-width:2px;
    classDef backend fill:#d0f0c0,stroke:#38761d,stroke-width:2px;
    classDef middleware fill:#ffd966,stroke:#bf9000,stroke-width:2px;
    classDef dataLayer fill:#ffadad,stroke:#e63946,stroke-width:2px;
    classDef external fill:#f0e68c,stroke:#999,stroke-width:2px;
```
