Skip to content

23co23-coder/diebito

 
 

Repository files navigation

# Diabetes Management Application A comprehensive Next.js application for diabetes management with Firebase Firestore backend, featuring user authentication, diet planning, exercise tracking, consultations, and more. ## Features - **User Management**: Role-based access (Admin, Doctor, Patient) - **Diet Plans**: Create and manage personalized diet plans - **Exercise Tracking**: Monitor exercise progress and routines - **Consultations**: Book and manage doctor appointments - **Food Ordering**: Order healthy meals and snacks - **Progress Tracking**: Monitor health and fitness progress - **Community**: Share experiences and connect with others ## Tech Stack - **Frontend**: Next.js 14, TypeScript, Tailwind CSS - **Backend**: Firebase (Authentication, Firestore, Storage) - **UI Components**: Shadcn/ui component library - **State Management**: React hooks and Firebase real-time listeners ## Project Structure ``` ├── app/ # Next.js app directory │ ├── admin/ # Admin panel pages │ ├── auth/ # Authentication pages │ ├── consultations/ # Consultation management │ ├── dashboard/ # Main dashboard │ ├── diets/ # Diet plan management │ ├── exercises/ # Exercise tracking │ ├── food-ordering/ # Food ordering system │ └── meal-suggestions/ # Meal recommendations ├── components/ # Reusable UI components │ ├── ui/ # Shadcn/ui components │ ├── AuthGuard.tsx # Route protection │ ├── Navbar.tsx # Navigation component │ └── UserProfileSetup.tsx # Profile setup form ├── hooks/ # Custom React hooks │ ├── useAuth.tsx # Authentication hook │ └── useUser.tsx # User data management ├── lib/ # Utility libraries │ ├── firebase.ts # Firebase configuration │ ├── firestore.ts # Firestore operations │ └── types.ts # TypeScript interfaces └── package.json # Dependencies and scripts ``` ## Firebase Data Structure ### Collections #### Users Collection (`users/{userId}`) ```typescript { name: string; email: string; role: "admin" | "doctor" | "patient"; age: number; weight: number; diabetesType: string; createdAt: Timestamp; } ``` #### Diets Collection (`diets/{dietId}`) ```typescript { userId: string; // Reference to user meals: string[]; nutritionStats: { calories: number; carbs: number; protein: number; sugar: number; }; createdAt: Timestamp; } ``` #### Consultations Collection (`consultations/{consultationId}`) ```typescript { doctorId: string; // Reference to doctor user patientId: string; // Reference to patient user timeSlot: Timestamp; status: "pending" | "confirmed" | "completed"; prescriptionLink: string; // Cloudinary URL createdAt: Timestamp; } ``` #### Progress Collection (`progress/{progressId}`) ```typescript { userId: string; // Reference to user exerciseId: string; // Reference to exercise date: Timestamp; status: "completed" | "skipped"; } ``` #### Orders Collection (`orders/{orderId}`) ```typescript { userId: string; // Reference to user items: [{ foodId: string; qty: number }]; totalPrice: number; status: "pending" | "delivered"; deliveryInfo: string; createdAt: Timestamp; } ``` #### Posts Collection (`posts/{postId}`) ```typescript { userId: string; // Reference to user title: string; content: string; createdAt: Timestamp; } ``` #### Comments Collection (`comments/{commentId}`) ```typescript { postId: string; // Reference to post userId: string; // Reference to user comment: string; createdAt: Timestamp; } ``` ## Setup Instructions ### 1. Environment Configuration Create a `.env.local` file in your project root: ```env # Firebase Configuration NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key_here NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id ``` ### 2. Firebase Project Setup 1. Go to [Firebase Console](https://console.firebase.google.com/) 2. Create a new project or select existing one 3. Enable Authentication (Email/Password, Google) 4. Create Firestore database 5. Set up security rules 6. Get your configuration values ### 3. Firestore Security Rules ```javascript rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { // Users can read/write their own data match /users/{userId} { allow read, write: if request.auth != null && request.auth.uid == userId; } // Diets: users can only access their own match /diets/{dietId} { allow read, write: if request.auth != null && resource.data.userId == request.auth.uid; } // Consultations: doctors and patients can access relevant ones match /consultations/{consultationId} { allow read, write: if request.auth != null && (resource.data.doctorId == request.auth.uid || resource.data.patientId == request.auth.uid); } // Progress: users can only access their own match /progress/{progressId} { allow read, write: if request.auth != null && resource.data.userId == request.auth.uid; } // Orders: users can only access their own match /orders/{orderId} { allow read, write: if request.auth != null && resource.data.userId == request.auth.uid; } // Posts: public read, authenticated write match /posts/{postId} { allow read: if true; allow write: if request.auth != null; } // Comments: public read, authenticated write match /comments/{commentId} { allow read: if true; allow write: if request.auth != null; } } } ``` ### 4. Install Dependencies ```bash npm install # or yarn install ``` ### 5. Run Development Server ```bash npm run dev # or yarn dev ``` ## Usage ### Authentication Flow 1. **Registration**: Users sign up with email/password 2. **Profile Setup**: Complete profile information (name, age, weight, diabetes type, role) 3. **Role Assignment**: Users are assigned roles (patient, doctor, admin) 4. **Access Control**: Different features based on user role ### User Roles - **Patient**: Access to diet plans, exercises, consultations, progress tracking - **Doctor**: Manage patient consultations, create diet/exercise plans - **Admin**: User management, system overview, content management ### Key Features #### Diet Management - Create personalized diet plans - Set nutrition targets (calories, carbs, protein, sugar) - Track meal plans and progress #### Exercise Tracking - Log exercise activities - Monitor completion status - Track progress over time #### Consultations - Book appointments with doctors - Manage consultation status - Upload prescriptions #### Progress Monitoring - Track health metrics - Monitor diet and exercise adherence - Generate progress reports ## API Functions The application provides comprehensive Firestore operations: - **CRUD Operations**: Create, read, update, delete for all collections - **Real-time Listeners**: Subscribe to data changes - **User Management**: Profile creation, updates, role management - **Data Relationships**: Handle references between collections ## Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Test thoroughly 5. Submit a pull request ## License This project is licensed under the MIT License. ## Support For support and questions, please open an issue in the GitHub repository.# diebito

About

health website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.2%
  • Other 0.8%