How rrohit0/brain-tumor-detection-cnn works
Main Components
• Frontend Client:
– Built in React with TypeScript.
– Uses TailwindCSS and shadcn UI components.
– Contains various pages (Home, About, Dataset, Contact, Privacy, Terms, etc.) and many reusable UI components (e.g., FileUploader, ImagePreviewSection, ResultsSection).
– Implements context (BrainTumorContext) and custom hooks.
• Backend Server:
– Built with Express.js using Node.js.
– Handles routes for file uploads, tumor detection, model training, and dataset management.
– Responsible for image processing (likely using Sharp) and interfacing with the CNN for predictions.
• Neural Network Model:
– Stored in the “model” directory as a JSON configuration and binary weight file.
– Utilizes TensorFlow.js/TensorFlow Node.js for processing uploaded MRI scans.
• Dataset Management:
– Directories (“dataset/no” and “dataset/yes”) and functionality for uploading and training on new MRI images.
• Additional Utilities:
– A PDF generation script (generate_pdf.js) and a poster file (poster.html) that are used to produce presentations or detailed reports.
– Shared schemas and configurations (e.g., shared/schema.ts, drizzle.config.ts) suggest standardized data handling.
• File Storage:
– The “uploads” directory (with subdirectories for original and processed images) manages the lifecycle of input data and derived outputs.
Relationships and Interactions
• The Frontend communicates with the Backend via API routes:
– File uploads, dataset management, and triggering model prediction or training are sent as HTTP requests.
• The Backend processes incoming images:
– It routes the request to either the “upload”, “model”, or “train” modules.
– It accesses the CNN (stored in the model directory) to perform inference and returns the results to the frontend.
• The Backend uses image processing libraries for pre/post-processing of MRI scans.
• The system supports exporting detailed reports:
– The generate_pdf.js and Puppeteer are invoked to convert HTML (e.g., poster.html) to PDFs, potentially as part of a reporting service.
• Data storage (uploads and dataset directories) ensures persistence and reusability:
– Uploaded images are stored and optionally processed for future model training or analysis.
Architectural Patterns and Design Principles
• Separation of Concerns:
– Frontend vs. Backend responsibilities are clearly defined.
– UI components are modular, and backend routes/modules handle specific tasks (upload, train, inference).
• RESTful API Design:
– The server exposes routes (likely detailed in server/routes.ts) which are designed to handle different aspects of the application (upload, train, model inference).
• Modular Design:
– The project structure separates UI components, server logic, and business logic (model operations and dataset management) into different folders.
• Scalability:
– With distinct modules for dataset management and model training, future enhancements (like multi-class classification or batch processing) can be easily incorporated.