Skip to content

EvaWilson67/CSCE548

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌱 Plant Tracker

  Plant Tracker is a full-stack web application for managing household plants and their care requirements.
  
  The system allows users to:
  
    Track plants and their attributes
    
    Record watering and soil change information
    
    Store location and lighting conditions
    
    View and manage plant data through a web interface
  
  The application demonstrates a layered architecture:
  
    Frontend (React + Vite)  →  Backend API (Spring Boot)  →  Database (PostgreSQL)

🌐 Live Application
  Frontend (Netlify)
  
  Primary URL
  https://funny-liger-c00f87.netlify.app/
  
  Alternate Netlify deployment
  https://69a26a241c8f10f797f0d67a--funny-liger-c00f87.netlify.app/
  
  ⚠️ The “Get All Plants” request may take several seconds to load.
  This is due to the backend running on Render's free tier, which sleeps when inactive.
  
  Backend API (Render)
  
  Platform: Render (Cloud PaaS)
  Service: Spring Boot REST API
  
  Example endpoint:
  
  https://csce548.onrender.com/api/plants
  
  
  The backend exposes REST endpoints used by the frontend client.
  
  Database (Clever Cloud)
  
  Platform: Clever Cloud PostgreSQL
  
  The backend connects to the database using JDBC and environment variables.

🏗️ System Architecture
  Browser
     │
     ▼
  Netlify (Frontend)
  React + Vite
     │
     ▼
  Render (Backend)
  Spring Boot REST API
  Business Layer
  DAO / Data Layer
     │
     ▼
  Clever Cloud
  PostgreSQL Database

📁 Project Structure
  plant-tracker
  ├── client/                     # React + Vite frontend
  │   ├── public
  │   └── src
  │       ├── assets
  │       └── components
  │
  ├── sql/                        # SQL scripts for database schema and seed data
  │
  ├── src/main/java/com/planttracker
  │   ├── business                # Business layer
  │   ├── dao                     # DAO layer
  │   ├── data                    # Data provider
  │   ├── model                   # Data models
  │   ├── service/api             # REST controllers
  │   └── config                  # Configuration classes
  │
  └── target/                     # Maven build output

🧰 Prerequisites
  
  To run the project locally you will need:
  
  Java 17+
  
  Maven
  
  Node.js 18+
  
  npm
  
  PostgreSQL client (psql)
  
  Git
  
  Optional tools:
  
  Postman / Insomnia
  
  DBeaver / pgAdmin
  
  Docker

🗄️ Database Setup (Clever Cloud)

  Create a PostgreSQL Add-On in Clever Cloud.
  
  Copy the connection details:
  
  Host
  
  Port
  
  Database name
  
  Username
  
  Password
  
  Example host format:
  
    bhnjibolguuj9qrqwpr6-postgresql.services.clever-cloud.com

💻 Creating Tables with SQL Shell

  Open SQL Shell (psql) and connect using the credentials from Clever Cloud:
  
  psql -h <HOST> -p <PORT> -U <USERNAME> -d <DATABASE>
  
  
  Enter the password when prompted.
  
  Create the tables by running the SQL statements located in the /sql folder.
  
  Example verification:
  
  \dt
  
  
  Expected tables:
  
    plant
    care
    information
    location
  
  ⚙️ Backend Configuration
    
    The backend reads database credentials from environment variables using DbConfig.
    
    PLANTDB_URL
    PLANTDB_USER
    PLANTDB_PASS
  
  
  Example values:
  
    PLANTDB_URL=jdbc:postgresql://<HOST>:<PORT>/<DATABASE>?sslmode=require
    PLANTDB_USER=<USERNAME>
    PLANTDB_PASS=<PASSWORD>

▶️ Running the Backend Locally

  From the project root:
  
    mvn clean package
    mvn spring-boot:run
  
  
  The service will start at:
  
    http://localhost:8080
  
  
  Example endpoint:
  
    http://localhost:8080/api/plants
  
  
  Test with PowerShell:
  
    Invoke-RestMethod http://localhost:8080/api/plants
  
  🖥️ Running the Frontend Locally
  
  Navigate to the client folder:
    
    cd client
    npm install
  
  
  Set the API URL:
  
    VITE_API_BASE=http://localhost:8080/api
  
  
  Start the development server:
  
    npm run dev
  
  
  Open in browser:
  
    http://localhost:5173
  
  ☁️ Backend Deployment (Render)
  
  Push the repository to GitHub.
  
  Create a Render Web Service
  
  Settings:
  
  Build Command: mvn clean package
  Start Command: java -jar target/planttracker-0.0.1-SNAPSHOT.jar
  
  
  Configure environment variables:
  
  PLANTDB_URL
  PLANTDB_USER
  PLANTDB_PASS
  
  
  Deploy the service.
  
  Render will generate a public URL similar to:
  
  https://csce548.onrender.com

🌐 Frontend Deployment (Netlify)

  Import the GitHub repository into Netlify.
  
  Configure build settings:
  
  Base directory: client
  Build command: npm run build
  Publish directory: dist
  
  
  Add environment variable:
  
  VITE_API_BASE=https://csce548.onrender.com
  
  
  Deploy the site.
  
  Netlify will provide a public site URL.

🧪 Console Test Client

  The project includes a console application used to test CRUD operations for:
  
  Business layer
  
  DAO layer
  
  Service layer
  
  Run with Maven:
  
    mvn compile exec:java
  
  
  To change the service URL:
  
  Windows
  
    setx PLANT_SERVICE_URL "http://localhost:8080"
  
  
  Mac/Linux
  
    export PLANT_SERVICE_URL=http://localhost:8080

⚠️ Common Issues
  Backend slow to start
  
  Render free tier sleeps after inactivity.
  
  The first request may take 30–60 seconds.
  
  Database connection error
  
  Verify environment variables:
  
    PLANTDB_URL
    PLANTDB_USER
    PLANTDB_PASS
  
  CORS errors
  
  Ensure backend WebConfig allows:
  
  http://localhost:5173
  https://funny-liger-c00f87.netlify.app

🔒 Security Notes

  Never commit database passwords to GitHub
  
  Use environment variables for credentials
  
  Use HTTPS in production

📚 Technologies Used

  Backend
  
    Java
    
    Spring Boot
    
    Maven
  
  Frontend
  
    React
    
    Vite
  
  Infrastructure
  
    Render
    
    Netlify
    
    Clever Cloud PostgreSQL

📜 License

  This project was developed as part of a university assignment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors