# nujhatmaliha99/medirepolab architecture

> Architecture diagram of the GitHub repository nujhatmaliha99/medirepolab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nujhatmaliha99/medirepolab
- Repository: https://github.com/nujhatmaliha99/medirepolab

## Overview

1. **High-level shape**
   MedReproLab is a two-tier MERN application: a React/Vite frontend talks to an Express.js REST backend, which persists research workspace data in MongoDB via Mongoose. The repository also includes a separate lightweight admin-panel UI under the backend tree.

2. **Frontend shell and navigation**
   The main UI lives in `src/` and is organized around a dashboard-style shell. `App.jsx`, `DashboardLayout.jsx`, and the page components under `src/pages/` define the user-facing workflows for projects, datasets, experiments, reviews, reports, and published research. Styling is split across `App.css` and `index.css`.

3. **Client-side state and access control**
   Authentication is handled on the client by `AuthContext.jsx`, with protected navigation enforced by `PrivateRoute.jsx`. The login/register pages are the public entry points; once authenticated, users move into the dashboard and workspace pages. `src/api/axios.js` centralizes API calls, which helps keep request/auth wiring consistent across pages.

4. **Core product boundaries in the UI**
   The frontend is organized around research-workspace concepts rather than generic CRUD pages:
   - project management: `Projects`, `ProjectDetails`
   - datasets: `Datasets`
   - experiments and comparisons: `Experiments`, `ExperimentDetails`, `Compare`, `Leaderboard`
   - research outputs: `Manuscript`, `ModelCards`, `Reports`, `ReproPackage`, `Reproducibility`
   - review and quality workflows: `QualityReview`, `ReviewRequests`, `XAIEvidence`, `ClinicalTriage`, `ClinicalCases`
   - public discovery: `PublishedResearch`
   - user/account views: `Profile`, `Dashboard`

5. **Frontend data flows**
   The typical flow is: page component -> axios API request -> authenticated backend route -> controller -> Mongoose model -> MongoDB -> response back to the page. The utility modules in `src/utils/` suggest client-side shaping of domain-specific outputs such as activity summaries, artifact lists, dataset risk scoring, and reproducibility checks before rendering.

6. **Backend API organization**
   The Express backend under `server/server/` is split by domain:
   - `routes/` defines REST endpoints
   - `controllers/` contains request handlers
   - `models/` defines Mongoose schemas
   - `middleware/authMiddleware.js` protects authenticated routes
   - `config/db.js` handles MongoDB connection
   This is a clean controller-route-model separation, with auth middleware sitting between the client and protected resources.

7. **Backend domain model**
   The persistence layer centers on `User`, `Project`, `Dataset`, `Experiment`, `ClinicalCase`, `ReviewRequest`, and `Activity`. That tells you the system stores not just research objects, but also workflow state: review submissions, audit history, and clinical triage/case metadata.

8. **Review, approval, and publication workflow**
   A major architectural boundary is between private research workspaces and approved public research. `reviewRequestController.js` and the admin-panel UI indicate a submission/approval queue. Once approved, research appears in `PublishedResearch`, so there is an explicit transition from internal workspace data to public-facing visibility.

9. **AI-assisted review layer**
   `aiController.js` and `aiRoutes.js` indicate a dedicated API for automated reviewer suggestions. In the product description this is used for identifying missing validation, artifacts, and documentation gaps, so the AI subsystem functions as advisory tooling layered on top of the core research records rather than as a primary data store.

10. **Audit/activity tracking**
   `activityLogger.js`, `activityController.js`, and the `Activity` model point to an event stream or activity log used across the platform. This is important for a reproducibility product because it captures what changed, when, and by whom across project, experiment, and review actions.

11. **Admin surface**
   `server/server/admin-panel/` is a separate static interface with its own `app.js`, `index.html`, and `styles.css`. Based on the README, it serves the admin review queue on a different local port from the main app, so the repository contains two user interfaces: the researcher app and the admin approval console.

12. **Infrastructure and runtime**
   The stack is Node.js/Express on the server, React on the client, and MongoDB as the backing store. JWT authentication is the main security boundary. The README also exposes health/status endpoints for both app and database, which suggests operational visibility is part of the backend’s responsibility.

13. **Demo and data bootstrap**
   The seed scripts (`seedSample.js`, `seedBreastSample.js`, `seedPublishedResearch.js`) create representative datasets and approved public research for demos. These scripts are part of the architecture because they establish the initial state needed for the platform’s main workflows: workspace exploration, review, and public browsing.

14. **How to draw the diagram**
   The most accurate diagram should show:
   - a browser/client tier with the React app
   - a separate admin-panel UI
   - a REST API tier with auth, AI, activity, and domain controllers
   - a MongoDB persistence layer
   - workflow arrows for authentication, workspace CRUD, experiment/review activity, AI suggestions, and approval/publication
   The key architectural idea is that MedReproLab is a research-workflow system with strong separation between private workspace data, review/approval processes, and publicly published research.

Main entry points: [`server/server/models/Project.js`](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/models/Project.js) (Research data), [`src/api/axios.js`](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/api/axios.js) (API client), [`server/server/server.js`](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/server.js) (Server entry), [`src/pages/Projects.jsx`](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/pages/Projects.jsx) (Workspace UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app_shell["App shell<br/>react entry<br/>[App.jsx]"]
  node_dashboard_layout["Dashboard<br/>layout shell"]
  node_auth_state["Auth state<br/>client auth<br/>[AuthContext.jsx]"]
  node_route_guard["Guard<br/>[PrivateRoute.jsx]"]
  node_api_client["API client<br/>http layer<br/>[axios.js]"]
  node_workspace_ui["Workspace UI<br/>research pages<br/>[Projects.jsx]"]
  node_public_ui["Public UI<br/>entry pages<br/>[Login.jsx]"]
  node_client_utils["UI utils<br/>client transforms<br/>[reproducibility.js]"]
end

subgraph group_backend["Backend API"]
  node_server_entry["Server entry<br/>api bootstrap<br/>[server.js]"]
  node_db_config["DB config<br/>mongo connect<br/>[db.js]"]
  node_auth_middleware["Auth guard<br/>middleware<br/>[authMiddleware.js]"]
  node_auth_routes["Auth API<br/>routes<br/>[authRoutes.js]"]
  node_domain_routes["Domain API<br/>routes<br/>[projectRoutes.js]"]
  node_ai_routes["AI API<br/>routes<br/>[aiRoutes.js]"]
  node_activity_routes["Activity API<br/>routes<br/>[activityRoutes.js]"]
  node_auth_controller["Auth handlers<br/>controllers<br/>[authController.js]"]
  node_domain_controller["Domain handlers<br/>controllers"]
  node_ai_controller["AI review<br/>[aiController.js]"]
  node_activity_controller["Activity log<br/>controllers"]
end

subgraph group_admin["Admin UI"]
  node_admin_panel["Admin panel<br/>static ui<br/>[app.js]"]
end

subgraph group_data["Persistence"]
  node_models[("Research data<br/>mongoose models<br/>[Project.js]")]
  node_seed_data["Seed data<br/>bootstrap scripts<br/>[seedSample.js]"]
end

node_app_shell -->|"renders"| node_dashboard_layout
node_app_shell -->|"routes"| node_public_ui
node_dashboard_layout -->|"hosts"| node_workspace_ui
node_public_ui -->|"updates"| node_auth_state
node_auth_state -->|"protects"| node_route_guard
node_route_guard -->|"allows"| node_workspace_ui
node_workspace_ui -->|"requests"| node_api_client
node_public_ui -->|"requests"| node_api_client
node_workspace_ui -->|"shapes"| node_client_utils
node_api_client -->|"calls"| node_auth_routes
node_api_client -->|"calls"| node_domain_routes
node_api_client -->|"calls"| node_ai_routes
node_api_client -->|"calls"| node_activity_routes
node_server_entry -->|"connects"| node_db_config
node_server_entry -->|"mounts"| node_auth_routes
node_server_entry -->|"mounts"| node_domain_routes
node_server_entry -->|"mounts"| node_ai_routes
node_server_entry -->|"mounts"| node_activity_routes
node_domain_routes -->|"protects"| node_auth_middleware
node_auth_routes -->|"dispatches"| node_auth_controller
node_domain_routes -->|"dispatches"| node_domain_controller
node_ai_routes -->|"dispatches"| node_ai_controller
node_activity_routes -->|"dispatches"| node_activity_controller
node_auth_controller -->|"users"| node_models
node_domain_controller -->|"persists"| node_models
node_activity_controller -->|"logs"| node_models
node_ai_controller -->|"analyzes"| node_models
node_models -.->|"feeds"| node_admin_panel
node_admin_panel -.->|"updates"| node_models
node_seed_data -->|"loads"| node_models

click node_app_shell "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/App.jsx"
click node_dashboard_layout "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/layouts/DashboardLayout.jsx"
click node_auth_state "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/context/AuthContext.jsx"
click node_route_guard "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/routes/PrivateRoute.jsx"
click node_api_client "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/api/axios.js"
click node_workspace_ui "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/pages/Projects.jsx"
click node_public_ui "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/pages/Login.jsx"
click node_client_utils "https://github.com/nujhatmaliha99/medirepolab/blob/main/src/utils/reproducibility.js"
click node_server_entry "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/server.js"
click node_db_config "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/config/db.js"
click node_auth_middleware "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/middleware/authMiddleware.js"
click node_auth_routes "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/authRoutes.js"
click node_domain_routes "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/projectRoutes.js"
click node_ai_routes "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/aiRoutes.js"
click node_activity_routes "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/activityRoutes.js"
click node_auth_controller "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/authController.js"
click node_domain_controller "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/projectController.js"
click node_ai_controller "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/aiController.js"
click node_activity_controller "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/activityController.js"
click node_models "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/models/Project.js"
click node_seed_data "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/seedSample.js"
click node_admin_panel "https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/admin-panel/app.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_shell,node_dashboard_layout,node_auth_state,node_route_guard,node_api_client,node_workspace_ui,node_public_ui,node_client_utils toneBlue
class node_server_entry,node_db_config,node_auth_middleware,node_auth_routes,node_domain_routes,node_ai_routes,node_activity_routes,node_auth_controller,node_domain_controller,node_ai_controller,node_activity_controller toneAmber
class node_admin_panel toneMint
class node_models,node_seed_data toneRose
```

## Components

### Frontend

React/Vite researcher workspace UI

- [App shell](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/App.jsx): react entry · Top-level React app and route composition · `src/App.jsx`
- [Dashboard](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/layouts/DashboardLayout.jsx): layout shell · Authenticated workspace layout and navigation chrome · `src/layouts/DashboardLayout.jsx`
- [Auth state](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/context/AuthContext.jsx): client auth · Client session state and login/register flow · `src/context/AuthContext.jsx`
- [Guard](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/routes/PrivateRoute.jsx): route guard · Protected navigation for authenticated pages · `src/routes/PrivateRoute.jsx`
- [API client](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/api/axios.js): http layer · Shared axios client for authenticated backend requests · `src/api/axios.js`
- [Workspace UI](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/pages/Projects.jsx): research pages · Projects, datasets, experiments, review, and reporting screens · `src/pages/Projects.jsx`
- [Public UI](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/pages/Login.jsx): entry pages · Login, register, and published research views · `src/pages/Login.jsx`
- [UI utils](https://github.com/nujhatmaliha99/medirepolab/blob/main/src/utils/reproducibility.js): client transforms · Helpers for activity, artifacts, risk, and reproducibility summaries · `src/utils/reproducibility.js`

### Backend API

Express REST server, controllers, and middleware

- [Server entry](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/server.js): api bootstrap · Express startup and route mounting · `server/server/server.js`
- [DB config](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/config/db.js): mongo connect · MongoDB connection setup · `server/server/config/db.js`
- [Auth guard](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/middleware/authMiddleware.js): middleware · JWT protection for secured backend routes · `server/server/middleware/authMiddleware.js`
- [Auth API](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/authRoutes.js): routes · Login and registration endpoints · `server/server/routes/authRoutes.js`
- [Domain API](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/projectRoutes.js): routes · Project, dataset, experiment, clinical case, and review endpoints · `server/server/routes/projectRoutes.js`
- [AI API](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/aiRoutes.js): routes · Automated reviewer suggestion endpoints · `server/server/routes/aiRoutes.js`
- [Activity API](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/routes/activityRoutes.js): routes · Activity and audit endpoints · `server/server/routes/activityRoutes.js`
- [Auth handlers](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/authController.js): controllers · Authentication and session handlers · `server/server/controllers/authController.js`
- [Domain handlers](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/projectController.js): controllers · Project, dataset, experiment, clinical case, and review request handlers · `server/server/controllers/projectController.js`
- [AI review](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/aiController.js): service · Automated suggestion and reviewer-assist logic · `server/server/controllers/aiController.js`
- [Activity log](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/controllers/activityController.js): controllers · Activity capture and retrieval handlers · `server/server/controllers/activityController.js`

### Admin UI

Separate approval console under the server tree

- [Admin panel](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/admin-panel/app.js): static ui · Separate review console for approvals and moderation · `server/server/admin-panel/app.js`

### Persistence

MongoDB models and seed/bootstrap scripts

- [Research data](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/models/Project.js): mongoose models · User, project, dataset, experiment, clinical case, review request, and activity schemas · `server/server/models/Project.js`
- [Seed data](https://github.com/nujhatmaliha99/medirepolab/blob/main/server/server/seedSample.js): bootstrap scripts · Sample and published research bootstrap scripts · `server/server/seedSample.js`

## Connections

- App shell → Dashboard: renders · Top-level app composes the authenticated dashboard shell
- App shell → Public UI: routes · Public entry points for login, register, and discovery
- Dashboard → Workspace UI: hosts · Workspace pages render inside the dashboard shell
- Public UI → Auth state: updates · Login and register flows update client auth state
- Auth state → Guard: protects · Authenticated state gates protected navigation
- Guard → Workspace UI: allows · Protected routes open the research workspace
- Workspace UI → API client: requests · Pages call the shared API client
- Public UI → API client: requests · Public screens use the API client for auth and discovery
- Workspace UI → UI utils: shapes · Client helpers format domain outputs before rendering
- API client → Auth API: calls · Client authentication requests reach the auth API
- API client → Domain API: calls · Workspace CRUD and workflow requests reach domain routes
- API client → AI API: calls · Client can request AI-assisted review suggestions
- API client → Activity API: calls · Client reads or posts activity data
- Server entry → DB config: connects · Server initializes the MongoDB connection
- Server entry → Auth API: mounts · Authentication routes are registered on the server
- Server entry → Domain API: mounts · Research domain routes are registered on the server
- Server entry → AI API: mounts · AI suggestion routes are registered on the server
- Server entry → Activity API: mounts · Activity routes are registered on the server
- Domain API → Auth guard: protects · Protected workspace routes pass through JWT middleware
- Auth API → Auth handlers: dispatches · Auth endpoints delegate to request handlers
- Domain API → Domain handlers: dispatches · Domain endpoints delegate to workflow handlers
- AI API → AI review: dispatches · AI endpoints delegate to advisory logic
- Activity API → Activity log: dispatches · Activity endpoints delegate to audit handlers
- Auth handlers → Research data: users · Authentication resolves user accounts
- Domain handlers → Research data: persists · Controllers read and write research records
- Activity log → Research data: logs · Activity handlers store and query audit events
- AI review → Research data: analyzes · AI suggestions are derived from stored research data
- Research data → Admin panel: feeds · Reviewable content is surfaced in the admin console
- Admin panel → Research data: updates · Approval actions update persisted review records
- Seed data → Research data: loads · Bootstrap scripts populate core collections
