How dminghao/neurosoft works
Project Type and Purpose
• NeuroSoft is a full‐stack medical surveying platform built with the MERN stack (MongoDB, Express, React, Node.js). It enables surgeons to create, manage, and distribute treatment admission surveys, while also incorporating a conventional SQL database for generating medical reports.
Analyzing the File Structure
• The “Main” directory holds the full application.
– The “backend” subdirectory contains server-side code: environment configuration (.env), middleware (auth.js), data models (for survey and user objects), and API routes.
– The “src” subdirectory contains React components and context management for the frontend (navigation, survey display/creation, dashboards for doctors and patients, authentication).
• The structure reflects an MVC or layered architecture where the front end, back end, and databases are kept separate.
Key Components
• Frontend:
• React Application (located in Main/src)
• Core components such as Navbar, Home, Surveys, Dashboards for various roles (Doctor, Patient)
• Client side routing and context providers (UserContext, MsgContext)
• Backend:
• Express Server (Main/backend/server.js) responsible for API handling, connecting to both MongoDB (for storing surveys, users, etc.) and the SQL Database (for medical report generation)
• Middleware (e.g., auth.js) for security/authentication
• API endpoints for surveys, templates, and user management
• Databases:
• MongoDB for the core data of surveys, users, etc.
• A conventional SQL database (as indicated in the README for report generation)
• Deployment & Infrastructure:
• AWS EC2: Deployment of the application via PM2 for the backend (e.g., using nodemon/node server)
• Environment configuration (.env file) and build/deployment steps described in the README.
Relationships and Interactions
• Data Flow: The React frontend sends HTTP requests (via API calls) to the Express backend.
• The backend processes these requests, applying middleware (authentication) before reaching the appropriate API routes.
• Backend interacts with both MongoDB (for surveys, users) and a SQL Database (for generating and storing reports).
• Deployment pipelines and configuration management (such as changes in .env and using PM2) should be depicted to show the lifecycle from development to production.
Architectural Patterns & Design Principles
• Separation of Concerns: Clearly separate client-side rendering (React) and server-side logic (Express).
• MVC-like Structure: Use models (in /models), views (served via React), and controllers (API routes) on the backend.
• Security: Emphasize the role of authentication middleware within the API call flow.
2. The server-side (Express/Node.js) that includes middleware and routing.
3. The databases (MongoDB and SQL) that the server interacts with.
4. Deployment context: an AWS EC2 block with PM2 managing the production server.
graph TD
FE[React Application]
end
BE[Express/Node.js Server]
Middleware[Authentication Middleware]
BE --> Middleware
end
MDB[MongoDB]
SQL[SQL Database]
end
FE -->|HTTP API Calls| BE
BE -->|CRUD Operations| MDB
BE -->|Report Generation Queries| SQL
AWS[AWS EC2 (PM2 Managed)]
end
BE --> AWS
• Use this as a base template, and expand with more detailed components if needed (for example, listing specific API endpoints or frontend subcomponents).