Skip to content

Nhp125/family-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

235 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Family Tree Management System

A comprehensive digital family tree application that allows users to create, manage, and explore their family connections with advanced features like real-time notifications, AI-powered chatbot assistance, and collaborative family management.

๐ŸŒŸ Features

๐Ÿ‘ฅ Family Management

  • Create & Join Families: Start your own family tree or request to join existing ones
  • Smart Member Linking: Auto-match by email or manual linking for existing family members
  • Role-Based Access: Family admin controls with member permissions
  • Member Profiles: Detailed profiles with photos, relationships, and personal information

๐ŸŒณ Interactive Family Tree

  • Visual Tree Representation: Interactive family tree visualization using D3.js
  • Relationship Mapping: Define complex family relationships (parent, spouse, sibling, etc.)
  • Tree Navigation: Smooth navigation through large family structures
  • Export Options: Export family tree as PDF or image

๐Ÿ”” Real-Time Notifications

  • Live Updates: Real-time notifications using Socket.IO
  • Family-Specific: Notifications filtered by user's joined families
  • Request Management: Join requests, member additions, and family updates
  • Smart Filtering: Organized notification system with read/unread states

๐Ÿ“… Events & Milestones

  • Family Events: Create and manage family gatherings, celebrations, and milestones
  • Event Reminders: Automated notification system for upcoming events
  • Photo Sharing: Share memories and photos from family events

๐Ÿ† Achievements System

  • Family Achievements: Track and celebrate family milestones
  • Member Recognition: Individual and collective family achievements
  • Progress Tracking: Visual progress indicators for various goals

๐Ÿ’ญ Anonymous Confessions

  • Safe Space: Anonymous confession system for family members
  • Community Support: Share thoughts and experiences within the family
  • Moderated Content: Admin oversight with editing and deletion capabilities

๐Ÿค– AI-Powered Assistant

  • Smart Chatbot: Google Gemini AI integration for family-related assistance
  • Family Insights: Get answers about family history, relationships, and genealogy
  • Intelligent Suggestions: AI-powered recommendations for family connections

๐Ÿ“ฑ Modern User Experience

  • Responsive Design: Mobile-first design with Tailwind CSS
  • Real-Time Updates: Live synchronization across all connected devices
  • Intuitive Interface: Clean, modern UI with smooth animations
  • Dark/Light Mode: User preference-based theme switching

๐Ÿ›  Tech Stack

Backend

  • Node.js with Express.js - RESTful API server
  • TypeScript - Type-safe development
  • Prisma ORM - Database modeling and queries
  • PostgreSQL - Primary database (Supabase)
  • Socket.IO - Real-time communication
  • JWT - Authentication and authorization
  • Swagger - API documentation
  • Google Gemini AI - Chatbot integration
  • Cloudinary - Image storage and optimization

Frontend

  • React 18 - Modern UI library
  • Vite - Fast build tool and dev server
  • Tailwind CSS - Utility-first styling
  • D3.js - Family tree visualization
  • Socket.IO Client - Real-time updates
  • Axios - HTTP client
  • React Router - Client-side routing
  • Framer Motion - Smooth animations

DevOps & Deployment

  • Docker - Containerization
  • Render - Cloud deployment platform
  • Supabase - Database hosting
  • GitHub Actions - CI/CD pipeline

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v18 or higher)
  • npm or yarn
  • PostgreSQL database
  • Git

๐Ÿš€ Quick Start

1. Clone the Repository

git clone https://github.com/thu2005/family-tree.git
cd family-tree

2. Backend Setup

cd backend
npm install

# Copy environment variables
cp .env.example .env

# Configure your .env file with:
# - Database URL (PostgreSQL)
# - JWT Secret
# - Google Gemini API Key
# - Cloudinary credentials
# - Supabase credentials

# Set up database
npm run db:generate
npm run db:push
npm run db:seed

# Start backend server
npm run dev

3. Frontend Setup

cd ../frontend
npm install

# Copy environment variables
cp .env.example .env

# Configure your .env file with:
# - VITE_API_URL=http://localhost:3001/api
# - Firebase configuration (optional)

# Start frontend development server
npm start

4. Access the Application

๐Ÿ”ง Environment Variables

Backend (.env)

NODE_ENV=development
PORT=3001

# Database (Supabase PostgreSQL)
DATABASE_URL="postgresql://username:password@host:port/database"
DIRECT_URL="postgresql://username:password@host:port/database"

# Supabase
SUPABASE_URL="your-supabase-url"
SUPABASE_ANON_KEY="your-supabase-anon-key"
SUPABASE_SERVICE_ROLE_KEY="your-service-role-key"

# Authentication
JWT_SECRET="your-super-secret-jwt-key"
JWT_EXPIRES_IN="7d"

# Google AI
GEMINI_API_KEY="your-google-gemini-api-key"

# Cloudinary
CLOUDINARY_CLOUD_NAME="your-cloudinary-name"
CLOUDINARY_API_KEY="your-cloudinary-api-key"
CLOUDINARY_API_SECRET="your-cloudinary-api-secret"

# Frontend URL (for CORS)
FRONTEND_URL="http://localhost:4028"

Frontend (.env)

VITE_API_URL="http://localhost:3001/api"
VITE_SOCKET_URL="http://localhost:3001"

# Firebase (optional)
VITE_FIREBASE_API_KEY="your-firebase-api-key"
VITE_FIREBASE_AUTH_DOMAIN="your-project.firebaseapp.com"
VITE_FIREBASE_PROJECT_ID="your-project-id"

๐Ÿณ Docker Deployment

Development with Docker Compose

# Build and run all services
docker-compose -f docker-compose.dev.yml up --build

# Run in background
docker-compose -f docker-compose.dev.yml up -d

Production Deployment

# Build and run production containers
docker-compose up --build -d

# View logs
docker-compose logs -f

๐Ÿ“š API Documentation

The API is fully documented with Swagger/OpenAPI. Access the interactive documentation at:

Key API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • POST /api/auth/refresh - Refresh access token

Families

  • GET /api/families - Get user's families
  • POST /api/families - Create new family
  • PUT /api/families/:id - Update family details
  • POST /api/families/:id/join - Request to join family

Members

  • GET /api/families/:id/members - Get family members
  • POST /api/families/:id/members - Add new member
  • PUT /api/members/:id - Update member details
  • DELETE /api/members/:id - Remove member

Notifications

  • GET /api/notifications - Get user notifications
  • PUT /api/notifications/:id/mark-read - Mark as read
  • PUT /api/notifications/mark-all-read - Mark all as read

๐Ÿ”„ Real-Time Features

The application uses Socket.IO for real-time communication:

Socket Events

  • notification:new - New notification received
  • family:member-added - New member joined family
  • family:request-approved - Join request approved
  • family:update - Family information updated

Client Implementation

import { io } from 'socket.io-client';

const socket = io('http://localhost:3001', {
  auth: { token: 'your-jwt-token' }
});

// Listen for notifications
socket.on('notification:new', (notification) => {
  console.log('New notification:', notification);
});

๐Ÿค– AI Chatbot Integration

The application includes an AI-powered chatbot using Google Gemini:

Features

  • Family history inquiries
  • Relationship explanations
  • Genealogy guidance
  • General family-related assistance

Usage

// Send message to chatbot
POST /api/chatbot/chat
{
  "message": "How do I add a new family member?",
  "familyId": "family-id-here"
}

๐Ÿงช Testing

Backend Tests

cd backend
npm test

# Run with coverage
npm run test:coverage

Frontend Tests

cd frontend
npm test

# Run E2E tests
npm run test:e2e

๐Ÿ“– Database Schema

The application uses a PostgreSQL database with the following main entities:

  • Users - User accounts and authentication
  • Families - Family groups and metadata
  • FamilyMembers - Individual family members and relationships
  • FamilyJoinRequests - Requests to join families
  • Events - Family events and celebrations
  • Achievements - Family and member achievements
  • Confessions - Anonymous family confessions
  • Notifications - Real-time notification system

๐Ÿš€ Deployment

Render.com (Recommended)

  1. Fork this repository to your GitHub account

  2. Create a new Web Service on Render:

    • Connect your GitHub repository
    • Use the provided render.yaml configuration
  3. Configure Environment Variables in Render dashboard

  4. Deploy - Render will automatically build and deploy your application

Manual Deployment

# Build production assets
cd frontend && npm run build
cd ../backend && npm run build

# Start production server
cd backend && npm start

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use conventional commit messages
  • Add tests for new features
  • Update documentation as needed

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

If you encounter any issues or need help:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue with detailed information
  4. Contact the development team

๐Ÿ™ Acknowledgments

  • D3.js - For powerful family tree visualization
  • Prisma - For excellent database tooling
  • Socket.IO - For seamless real-time communication
  • Google Gemini - For AI-powered assistance
  • Tailwind CSS - For beautiful, responsive design
  • React Community - For continuous inspiration and support

๐Ÿ”ฎ Roadmap

Upcoming Features

  • Mobile App - React Native implementation
  • Advanced Analytics - Family statistics and insights
  • DNA Integration - Connect with genetic testing services
  • Multi-language Support - Internationalization
  • Family Stories - Collaborative storytelling feature
  • Calendar Integration - Sync with external calendars
  • Photo Recognition - AI-powered photo tagging
  • Family Newsletter - Automated family updates

Built with โค๏ธ for families around the world

Keep your family connections strong and your memories alive.

git clone <repository-url>
cd family-tree
  1. Development mode (with hot reload):

    sudo docker compose -f docker-compose.dev.yml up -d
  2. Production mode (no hot reload):

    sudo docker compose up -d
  3. Access the application:

  4. Stop services:

    sudo docker compose down
    # or for dev mode
    sudo docker compose -f docker-compose.dev.yml down

๐Ÿณ Docker Commands

Development workflow (with hot reload):

# Start development mode with auto-reload
sudo docker compose -f docker-compose.dev.yml up -d

# View logs (will show nodemon restarts)
sudo docker compose -f docker-compose.dev.yml logs backend -f

# Stop development mode
sudo docker compose -f docker-compose.dev.yml down

Production workflow:

# Start production mode
sudo docker compose up -d

# View logs
sudo docker compose logs backend        # Backend logs only
sudo docker compose logs -f             # All logs with follow

# Restart services
sudo docker compose restart backend     # Restart backend only
sudo docker compose restart             # Restart all services

# Rebuild and restart (after dependency changes)
sudo docker compose up -d --build

# Stop services
sudo docker compose down

# Check status
sudo docker compose ps

๐Ÿ› ๏ธ Local Development (Without Docker)

๐Ÿ› ๏ธ Local Development (Without Docker)

Backend Setup:

cd backend
npm install
npm run dev

Frontend Setup:

git clone <repository-url>
cd frontend
  1. Install dependencies:

    npm install
    # or
    yarn install
  2. Start the development server:

    npm start
    # or
    yarn start

๐Ÿ“š Backend Development Workflow

For detailed instructions on implementing new backend features, see: Backend Implementation Guide

This guide covers:

  • Step-by-step workflow for new features
  • Service โ†’ Controller โ†’ Route pattern
  • Testing with Swagger UI
  • Database operations with Prisma
  • Best practices and examples

๐Ÿ“ Project Structure

family-tree/
โ”œโ”€โ”€ backend/            # Node.js + TypeScript + Prisma API
โ”‚   โ”œโ”€โ”€ src/           # Source code
โ”‚   โ”œโ”€โ”€ prisma/        # Database schema
โ”‚   โ”œโ”€โ”€ Dockerfile     # Docker configuration
โ”‚   โ””โ”€โ”€ package.json   # Dependencies
โ”œโ”€โ”€ frontend/          # React + Vite application
โ”‚   โ”œโ”€โ”€ public/        # Static assets
โ”‚   โ”œโ”€โ”€ src/          
โ”‚   โ”‚   โ”œโ”€โ”€ components/    # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/         # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ styles/        # Global styles and Tailwind configuration
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx        # Main application component
โ”‚   โ”‚   โ”œโ”€โ”€ Routes.jsx     # Application routes
โ”‚   โ”‚   โ””โ”€โ”€ index.jsx      # Application entry point
โ”‚   โ”œโ”€โ”€ index.html         # HTML template
โ”‚   โ”œโ”€โ”€ package.json       # Project dependencies and scripts
โ”‚   โ”œโ”€โ”€ tailwind.config.js # Tailwind CSS configuration
โ”‚   โ””โ”€โ”€ vite.config.js     # Vite configuration
โ””โ”€โ”€ docker-compose.yml     # Multi-service Docker setup

๐Ÿงฉ Adding Routes

To add new routes to the application, update the Routes.jsx file:

import { useRoutes } from "react-router-dom";
import HomePage from "pages/HomePage";
import AboutPage from "pages/AboutPage";

const ProjectRoutes = () => {
  let element = useRoutes([
    { path: "/", element: <HomePage /> },
    { path: "/about", element: <AboutPage /> },
    // Add more routes as needed
  ]);

  return element;
};

๐Ÿ“ฆ Key Dependencies

Family Tree Visualization

๐Ÿ“ฆ Deployment

Docker Production Build:

# Build and start production containers
sudo docker compose -f docker-compose.yml up -d --build

# Or build specific service
sudo docker compose build backend

Manual Build:

# Backend
cd backend
npm run build

# Frontend  
cd frontend
npm run build

๐Ÿ”ง Environment Configuration

Backend Environment Variables:

Create /backend/.env.docker for Docker or /backend/.env for local development:

PORT=3001
NODE_ENV=production
DATABASE_URL=your_supabase_connection_string
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
JWT_SECRET=your_jwt_secret
GOOGLE_CLIENT_ID=your_google_client_id
FRONTEND_URL=http://localhost:4028

๐Ÿšจ Troubleshooting

Docker Issues:

# Check container status
sudo docker compose ps

# View container logs
sudo docker compose logs backend

# Restart services
sudo docker compose restart

# Clean rebuild
sudo docker compose down
sudo docker compose up -d --build

Permission Issues:

If you get permission denied errors, add your user to docker group:

sudo usermod -aG docker $USER
# Then logout and login again

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors