Bodi organs

 

/* Instructions: This single-file contains a React component (default export) for an interactive body-map GIS UI and, in comments below, a minimal Express.js API implementation that serves organ geometry + metadata. This is a starter you can run locally. How to run (quick): 1) Create a folder, initialize two packages or use a single Node project. Example: - npx create-react-app bodymap-frontend - cd bodymap-frontend - Replace src/App.js with the React component below (and add Tailwind if you want the exact styling). 2) Create a backend folder (or inside same repo) and add server.js with the Express server code in the comments below. - npm init -y; npm i express cors - node server.js 3) Start frontend (npm start) and ensure frontend requests /api/organs -> either proxy in package.json or run backend on a different port and set fetch URL accordingly. API contract (example): GET /api/organs -> returns JSON array of organs with: { id, name, description, anatomyGroup, svgPath, bbox, properties: {...} } CORS: enable cors() in Express or proxy via package.json. --- Below: React component (interactive SVG body map) + helper UI. */ import React, { useEffect, useState } from "react"; export default function BodyMapApp() { const [organs, setOrgans] = useState([]); const [selected, setSelected] = useState(null); const [query, setQuery] = useState(""); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { // Fetch organ metadata + SVG paths from backend API // Change /api/organs to full URL if backend runs on another port setLoading(true); fetch("/api/organs") .then((r) => { if (!r.ok) throw new Error(`HTTP ${r.status}`); return r.json(); }) .then((data) => { setOrgans(data); setLoading(false); }) .catch((err) => { setError(err.message); setLoading(false); }); }, []); const filtered = organs.filter((o) => o.name.toLowerCase().includes(query.toLowerCase()) || (o.anatomyGroup || "").toLowerCase().includes(query.toLowerCase()) ); function handleSelect(id) { const o = organs.find((x) => x.id === id); setSelected(o || null); } return (

BodyMap GIS — Organs Explorer

{/* Left: controls */}
setQuery(e.target.value)} />
{loading &&
Loading organs...
} {error &&
Error: {error}
} {!loading && !error && filtered.length === 0 && (
No organs found.
)} {filtered.map((o) => ( ))}
API: /api/organs — returns organ list + SVG geometry.
{/* Middle: SVG Body Map */}
Interactive Body Map
{/* Simple anatomical SVG (frontal). Each organ path comes from API in organs[].svgPath */} {/* Basic body outline for context */} {/* Render organs from API */} {organs.map((o) => ( handleSelect(o.id)} style={{ fill: selected && selected.id === o.id ? "#fde68a" : "#fca5a5", stroke: "#92400e", strokeWidth: 1, cursor: "pointer", opacity: 0.95, }} /> ))} {/* If no organs loaded, draw placeholders */} {organs.length === 0 && ( {/* heart */} { /* no-op */ }} /> )}
{/* Right: details panel */}
Details
{!selected && (
Click an organ on the map or select from the list.
)} {selected && (

{selected.name}

Group: {selected.anatomyGroup}
{selected.description}
Properties
    {selected.properties && Object.entries(selected.properties).map(([k, v]) => (
  • {k}: {String(v)}
  • ))}
)} {/* Raw JSON dump for selected */} {selected && (
Raw JSON

                    {JSON.stringify(selected, null, 2)}

                  
)}
Tip: Use an API that returns svgPath for each organ. You can enrich each organ with coordinates, CT/MRI links, ICD codes etc.
); } /* --- Express API example (server.js) --- Save the snippet below to server.js and run `node server.js`. Requires: npm i express cors // server.js const express = require('express'); const cors = require('cors'); const app = express(); app.use(cors()); app.use(express.json()); // Example organs dataset. svgPath values are simplified; replace with accurate paths. const organs = [ { id: 'heart', name: 'Heart', anatomyGroup: 'Circulatory', description: 'Muscular organ that pumps blood throughout the body.', svgPath: 'M150 240 c-20 -20 -40 -40 -60 0 c-20 40 40 90 60 110 c20 -20 80 -70 60 -110 c-20 -40 -40 -20 -60 0z', properties: { weight_g: 300, function: 'pump blood', icd_code: 'I51' } }, { id: 'left_lung', name: 'Left Lung', anatomyGroup: 'Respiratory', description: 'Left lung for gas exchange.', svgPath: 'M110 140 c-20 40 -10 120 10 160 c30 10 50 -40 40 -90 c-10 -40 -30 -90 -50 -70z', properties: { lobes: 2, function: 'gas exchange' } }, { id: 'right_lung', name: 'Right Lung', anatomyGroup: 'Respiratory', description: 'Right lung for gas exchange.', svgPath: 'M190 140 c20 40 10 120 -10 160 c-30 10 -50 -40 -40 -90 c10 -40 30 -90 50 -70z', properties: { lobes: 3, function: 'gas exchange' } }, { id: 'liver', name: 'Liver', anatomyGroup: 'Digestive', description: 'Large organ that metabolizes nutrients and detoxifies.', svgPath: 'M120 360 c-40 20 -60 60 -40 90 c30 40 160 40 200 10 c20 -20 10 -70 -50 -80 c-60 -10 -110 -30 -110 -20z', properties: { weight_g: 1500 } }, { id: 'stomach', name: 'Stomach', anatomyGroup: 'Digestive', description: 'Digests food and mixes gastric juices.', svgPath: 'M140 420 c-30 20 -40 50 -20 70 c20 20 80 30 110 10 c20 -15 20 -60 -20 -70 c-40 -10 -60 -15 -70 -10z', properties: { capacity_ml: 1500 } } ]; app.get('/api/organs', (req, res) => { res.json(organs); }); app.listen(4000, () => console.log('API running on http://localhost:4000')); --- Notes & next steps: • Replace svgPath with accurate vector outlines (e.g., export from Illustrator or trace from anatomical sources). Use GeoJSON-like shapes if you prefer GIS libraries. • If you want geospatial features (lat/long) for organ mapping in medical imaging, adapt to store coordinates in organ.metadata and use leaflet or kepler.gl for advanced GIS overlays. • For heavy GIS usage, convert organs to GeoJSON-like polygons and visualize with Mapbox GL or Leaflet (project body to 2D coordinate system). If tu chahe to main ye sab setup karke detailed steps aur ek full runnable repo structure de du — bol de, main pura folder structure bata dunga aur ready-to-run commands bhi. */

Post a Comment

Previous Post Next Post