Skip to content

11neeja/medihub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MediHub ✨

MediHub is a full-stack medical learning and collaboration platform built with Next.js 14, Express, Prisma, PostgreSQL, and Socket.IO.

Overview πŸ”Ž

MediHub brings together the tools medical students, doctors, researchers, and educators need in one place. The app combines a polished landing experience with authenticated workspace features for learning, collaboration, communication, and career growth.

What the app covers
  • πŸ“° Medical news browsing and trending topics
  • πŸ“… Event discovery, registration, and Eventbrite sync support
  • πŸ“ Notebook workspace for subjects, notes, blocks, and tasks
  • 🫢 Social feed for posts, likes, bookmarks, reposts, and comments
  • πŸ‘₯ Community groups with threads, replies, votes, and resources
  • πŸ’¬ Real-time chat with files, join requests, and pinned conversations
  • πŸ€– AI assistant for questions, document summaries, and extracted text
  • πŸ”” Notifications for chat, groups, events, and system actions
  • πŸ’Ό Opportunities and applications for medical roles and internships

What Changed πŸš€

This version moves the backend from MongoDB/Mongoose to PostgreSQL with Prisma and Docker-based local database setup.

  • 🐘 PostgreSQL replaces MongoDB as the main database
  • 🧩 Prisma is used for schema management, queries, and migrations
  • 🐳 Docker Compose is provided for local PostgreSQL startup
  • 🎨 The frontend UI has been refreshed with a cleaner landing page, updated navigation, responsive cards, and a more polished visual system
  • ⚑ Real-time chat, notifications, AI assistant, notebook, events, groups, opportunities, and feed features are wired into the current app structure

Architecture πŸ—οΈ

flowchart LR
	U[User] --> F[Next.js Frontend]
	F --> A[Express API]
	F <--> S[Socket.IO]
	A --> P[Prisma Client]
	P --> D[(PostgreSQL)]
	A --> U1[Uploads / Documents]
	A --> N[Notifications]
	A --> AI[AI Assistant]
Loading

The frontend handles the UI, routing, and client-side state. The backend provides the API, authentication, real-time messaging, and file/document workflows. Prisma connects the backend to PostgreSQL, and Docker provides a local database container for development.

Feature Tour 🧭

Core product modules
Area What it does
πŸ“° News Lists medical news, supports cache refresh, and exposes trending topics
πŸ“… Events Lists events, registers users, creates events, and supports Eventbrite syncing
πŸ“ Notebook Manages subjects, notes, note blocks, reorder actions, and tasks
🫢 Feed Supports posts, likes, bookmarks, reposts, comments, and image uploads
πŸ‘₯ Groups Handles communities, members, threads, replies, votes, pins, and resources
πŸ’¬ Chat Supports conversations, direct and group chat, file messages, and join requests
πŸ€– Assistant Lets users chat with AI, summarize docs, extract text, and save message history
πŸ”” Notifications Tracks unread counts, read states, and bulk clearing
πŸ’Ό Opportunities Lists roles, filters, applications, and user submissions
πŸ‘€ Users Handles register, login, profile fetch, and protected user listing

UI Tour 🎨

The current frontend is not just functional; it is visually structured to feel like a complete product.

UI highlights
  • ✨ A redesigned landing page with a stronger brand presence and feature-led storytelling
  • 🧭 A sticky navigation bar with app shortcuts and notification controls
  • πŸ“± Dedicated app pages for home, feed, events, groups, chat, notebook, assistant, opportunities, login, and signup
  • πŸŽ›οΈ A clearer visual language with refined spacing, cards, borders, shadows, and color system
  • πŸ“ Responsive layouts that adapt to desktop and mobile screens
  • πŸ€– An assistant workspace with document upload, summary generation, and message history

Frontend pages

Route Purpose
/ Public landing page
/login Sign in page
/signup Sign up page
/home Main authenticated dashboard
/feed Community feed
/events Events page
/groups Communities and threads
/chat Messaging
/notebook Notes and tasks
/assistant AI assistant
/opportunities Roles and applications

Project Structure πŸ—‚οΈ

Path Role
frontend/ Next.js app and UI
backend/ Express API, Prisma schema, routes, controllers, and utilities
docker-compose.yml Local PostgreSQL container
backend/prisma/ Prisma schema and migrations
backend/uploads/ Stored uploaded files

Local Setup πŸ› οΈ

Prerequisites βœ…

  • Node.js 18+ recommended
  • npm
  • Docker Desktop or another Docker runtime
  • (Optional) Ollama running locally if you want to use the AI assistant. Pull the default model with ollama pull smollm:1.7b.

1. Install dependencies πŸ“¦

From the repository root:

npm run install:all

This installs root, frontend, and backend dependencies.

2. Configure environment variables πŸ”

cp backend/.env.example backend/.env

Then open backend/.env and set at minimum:

  • JWT_SECRET β€” any long random string
  • EVENTBRITE_TOKEN / NEWS_API_KEY β€” optional, leave blank to disable events / news fetching

The default DATABASE_URL matches the Docker Compose setup below.

3. Start PostgreSQL with Docker 🐳

docker compose up -d

This starts the PostgreSQL container defined in docker-compose.yml on port 5432.

4. Apply database migrations 🧩

From the backend/ folder:

npx prisma migrate deploy
npx prisma generate

(Use npx prisma migrate dev instead if you intend to author new migrations.)

5. Run the app ▢️

From the repository root:

npm run dev

That starts the frontend on http://localhost:3000 and the backend on http://localhost:5000.

Scripts βš™οΈ

Root scripts 🧰

Command Purpose
npm run install:all Install frontend and backend dependencies
npm run dev:frontend Start the frontend only
npm run dev:backend Start the backend only
npm run dev Run both apps together

Frontend scripts 🎯

Command Purpose
npm run dev Start Next.js in development mode
npm run build Build the frontend
npm run start Start the production build
npm run lint Lint the frontend

Backend scripts πŸ–₯️

Command Purpose
npm run dev Start the Express server with nodemon
npm start Start the Express server

API Surface πŸ”Œ

Authentication and users πŸ‘€

  • POST /api/users/register
  • POST /api/users/login
  • GET /api/users/me
  • GET /api/users

Feed πŸ“°

  • GET /api/posts
  • POST /api/posts
  • PUT /api/posts/:id/like
  • PUT /api/posts/:id/bookmark
  • POST /api/posts/:id/comments
  • DELETE /api/posts/:postId/comments/:commentId
  • POST /api/posts/:id/repost
  • DELETE /api/posts/:id

Notes and tasks πŸ“

  • GET /api/notes
  • POST /api/notes
  • PUT /api/notes/reorder
  • PUT /api/notes/:id
  • DELETE /api/notes/:id
  • GET /api/notes/subjects
  • POST /api/notes/subjects
  • PUT /api/notes/subjects/:name
  • DELETE /api/notes/subjects/:name
  • GET /api/tasks
  • POST /api/tasks
  • PUT /api/tasks/:id/toggle
  • DELETE /api/tasks/:id

Events πŸ“…

  • GET /api/events
  • POST /api/events
  • PUT /api/events/:id/register
  • DELETE /api/events/:id
  • GET /api/events/eventbrite
  • POST /api/events/eventbrite/refresh

Documents and AI πŸ€–

  • GET /api/documents
  • POST /api/documents
  • GET /api/documents/:id/download
  • DELETE /api/documents/:id
  • POST /api/ai/chat
  • POST /api/ai/summarize
  • POST /api/ai/suggestions
  • POST /api/ai/extract-text
  • GET /api/ai/messages
  • POST /api/ai/messages
  • DELETE /api/ai/messages

Chat πŸ’¬

  • GET /api/chat/conversations
  • POST /api/chat/conversations/private
  • POST /api/chat/conversations/group
  • PUT /api/chat/conversations/:id/pin
  • DELETE /api/chat/conversations/:id
  • POST /api/chat/conversations/:id/members
  • DELETE /api/chat/conversations/:id/members/:userId
  • GET /api/chat/conversations/:id/messages
  • POST /api/chat/conversations/:id/messages
  • POST /api/chat/conversations/:id/files
  • GET /api/chat/conversations/:id/files
  • GET /api/chat/users/search
  • GET /api/chat/join-requests
  • POST /api/chat/conversations/:id/join-request
  • PUT /api/chat/join-requests/:id

Groups πŸ‘₯

  • GET /api/groups
  • POST /api/groups
  • PUT /api/groups/:id
  • POST /api/groups/:id/join
  • DELETE /api/groups/:id/leave
  • GET /api/groups/:id/members
  • POST /api/groups/:id/members
  • DELETE /api/groups/:id/members/:userId
  • GET /api/groups/:id/threads
  • POST /api/groups/:id/threads
  • PUT /api/groups/threads/:threadId/vote
  • PUT /api/groups/threads/:threadId/pin
  • GET /api/groups/threads/:threadId/replies
  • POST /api/groups/threads/:threadId/replies
  • GET /api/groups/:id/resources
  • POST /api/groups/:id/resources
  • PUT /api/groups/resources/:resourceId/download

Notifications, news, and opportunities πŸ””

  • GET /api/notifications
  • GET /api/notifications/unread-count
  • PUT /api/notifications/read-all
  • PUT /api/notifications/:id/read
  • DELETE /api/notifications
  • GET /api/news
  • POST /api/news/refresh
  • GET /api/news/trending
  • GET /api/opportunities
  • POST /api/opportunities
  • GET /api/opportunities/filters
  • GET /api/opportunities/applications
  • POST /api/opportunities/:id/apply
  • DELETE /api/opportunities/:id

Database and Prisma 🐘

Prisma is the source of truth for the schema in backend/prisma/schema.prisma.

  • PostgreSQL is the active database provider
  • Relations are modeled through Prisma instead of Mongoose collections
  • Migrations live under backend/prisma/migrations/
  • The backend connects to PostgreSQL through Prisma on startup

Data model highlights 🧠

Main entities
  • Users and auth
  • Posts, comments, likes, bookmarks, and reposts
  • Notes, note blocks, and subjects
  • Tasks and event registrations
  • Conversations, members, messages, and join requests
  • Notifications and AI chat messages
  • Documents, opportunities, applications, and groups

Troubleshooting 🧯

Common issues
  • If the backend cannot connect, verify DATABASE_URL and that Docker is running.
  • If Prisma schema changes are not visible, rerun npx prisma generate and npx prisma migrate dev.
  • If the frontend cannot reach the backend, check the backend port and any local proxy or firewall rules.
  • If uploads fail, confirm the backend/uploads/ directory exists and the file size is within the configured limit.
  • If Socket.IO chat is not connecting, verify the JWT token and backend server startup.

Next Improvements 🌱

Potential production follow-ups:

  • πŸ”‘ Add deployment-specific environment files and secrets handling
  • πŸ›‘οΈ Harden authentication and session management
  • ☁️ Add file storage backed by cloud object storage
  • πŸ§ͺ Expand validation and error handling
  • βœ… Add CI checks for Prisma migrations and frontend linting
  • πŸš€ Deploy the frontend and backend with managed PostgreSQL

About

hub for medical

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors