How vibhorsharma0053/virus works
Project type and purpose
• This is a full‑stack web application (“Virus”) built during a hackathon.
• Purpose: Allow administrators/teachers to post assignments, students to fetch and submit assignments, and view results. It supports offline data with PouchDB on the client.
File structure
• client/ – React + Vite frontend
• src/components, src/pages for UI
• src/pouchdb for offline storage logic
• axios for HTTP, react-router-dom for routing, tailwindcss for styling
• server/ – Node.js + Express backend
• routes/, controllers/, models/ (MVC pattern)
• middleware/ for auth or request preprocessing
• db.js connects to MongoDB (via Mongoose)
• Deployment/config files: .env (DB URI, secrets), package.json in each folder
README for additional insights
• Lists API endpoints (auth, assignment, result)
• Specifies external dependencies (MongoDB, PouchDB, Axios)
Main components
a. Frontend (React App)
• UI pages: Login/SignUp, StudentDashboard, TeacherDashboard, Assignment pages
• Offline store: PouchDB
• HTTP client: Axios
b. Backend (Express Server)
• Routing layer (authRoutes, assignmentRoutes, resultRoutes)
• Controllers (authController, assignmentController, resultController)
• Models (userModel, assignmentModel, resultModel)
• Middleware (auth guard, error handler)
c. Database
• MongoDB (hosted externally or locally)
d. External / Cross‑cutting
• Environment config (.env)
• Static file serving for client (if served by server in production)
Relationships and data flows
1. User (Teacher/Student) interacts with React UI in browser
2. React App reads/writes local PouchDB for offline mode
3. On network availability, Axios issues HTTP requests to Express API at /api/*
4. Express middleware authenticates the request
5. Express routes delegate to Controllers
6. Controllers use Models to query/update MongoDB
7. Responses flow back via JSON to React, which updates UI & PouchDB
Architectural patterns and design principles
• MVC pattern on the backend (routes → controllers → models)
• Separation of concerns: UI vs. data store vs. API
• Offline‑first capabilities with PouchDB sync
• RESTful API design
• Environment‐based configuration