Skip to content

steyncd/TheNarrowTrail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

61 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒฒ The Narrow Trail - Hiking Portal

A comprehensive full-stack web application for managing hiking groups, events, and community features. Built with modern technologies for scalability, security, and user experience.


๐Ÿš€ Live Application

Status: โœ… Production Ready - Last Deployed: October 15, 2025


๐Ÿ“‹ Quick Links

For Developers

Documentation


โœจ Key Features

๐Ÿ‘ฅ User Management

  • Authentication - Secure JWT-based login with role-based access control
  • User Profiles - Comprehensive profiles with emergency contacts
  • Permission System - Granular role and permission management
  • Auto-Approval - Intelligent user registration approval
  • Privacy - Full POPIA compliance (South African data protection)

๐Ÿฅพ Hike Management

  • Event Planning - Create and manage hiking events
  • Registration - Interest tracking and attendance management
  • Payment Tracking - Integrated payment processing
  • Photo Galleries - Image upload and sharing
  • Packing Lists - Customizable gear lists
  • Weather Integration - Real-time weather data

๐Ÿ“ฑ Communication

  • Email Notifications - SendGrid-powered email system
  • SMS Alerts - Twilio SMS and WhatsApp integration
  • Real-time Updates - WebSocket-based live notifications
  • Comment System - Discussions on hikes and events
  • Carpool Coordination - Organize shared transportation

๐Ÿ“Š Analytics & Admin

  • Usage Analytics - Comprehensive usage tracking
  • Activity Logs - Detailed audit trail
  • Payment Reporting - Financial tracking and reporting
  • Admin Dashboard - Complete system administration

๐Ÿ”’ Compliance & Security

  • POPIA Compliance - Full South African data protection compliance
  • Data Retention - Automated data cleanup policies
  • Editable Legal Docs - Privacy Policy and Terms in admin panel
  • Data Export - User data export capabilities
  • Account Deletion - Complete data removal

๐Ÿ“ฑ Progressive Web App (PWA)

  • Offline Support - Work without internet connection
  • Mobile Optimized - Responsive design for all devices
  • Install Prompt - Add to home screen on mobile
  • Push Notifications - Real-time alerts on mobile

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend    โ”‚      โ”‚   Node.js Backend     โ”‚      โ”‚   PostgreSQL DB    โ”‚
โ”‚  Firebase Hosting   โ”‚โ—„โ”€โ”€โ”€โ”€โ–บโ”‚     Cloud Run         โ”‚โ—„โ”€โ”€โ”€โ”€โ–บโ”‚     Cloud SQL      โ”‚
โ”‚  (Port 3000 dev)    โ”‚      โ”‚   (Port 8080 prod)    โ”‚      โ”‚   (Unix Socket)    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                              โ”‚                             โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚                                        โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚  Secret Manager   โ”‚                  โ”‚   File Storage     โ”‚
          โ”‚  (API Keys, etc)  โ”‚                  โ”‚   (Future: GCS)    โ”‚
          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Technology Stack

Frontend:

  • React 18 with Hooks
  • React Router v6
  • Bootstrap 5
  • Socket.IO Client
  • Service Workers (PWA)

Backend:

  • Node.js 18 (LTS)
  • Express.js
  • Socket.IO Server
  • JWT Authentication
  • Node-cron (Scheduled tasks)

Database:

  • PostgreSQL 14
  • pg (Node PostgreSQL client)
  • Connection pooling
  • Automated backups

Cloud Infrastructure:

  • Google Cloud Platform (Project: helloliam)
    • Cloud Run (Backend hosting)
    • Cloud SQL (Database)
    • Secret Manager (Credentials)
    • Cloud Build (CI/CD)
  • Firebase
    • Hosting (Frontend)
    • Analytics

Integrations:

  • SendGrid (Email)
  • Twilio (SMS & WhatsApp)
  • OpenWeather API (Weather data)
  • Stripe (Payment processing - Future)

๐Ÿ“ Project Structure

hiking-portal/
โ”œโ”€โ”€ ๐Ÿ“„ DEPLOYMENT.md              # Complete deployment guide
โ”œโ”€โ”€ ๐Ÿ“„ CONFIGURATION.md           # Environment variables reference
โ”œโ”€โ”€ ๐Ÿ“„ PRE_DEPLOYMENT_CHECKLIST.md # Pre-deployment verification
โ”œโ”€โ”€ ๐Ÿ“„ README.md                  # This file
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ frontend/                  # React application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/           # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ admin/            # Admin-specific components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ hikes/            # Hike-related components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ payments/         # Payment components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ common/           # Shared components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/                # Page-level components
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/             # React Context (state management)
โ”‚   โ”‚   โ”œโ”€โ”€ services/             # API integration layer
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ utils/                # Utility functions
โ”‚   โ”œโ”€โ”€ public/
โ”‚   โ”‚   โ”œโ”€โ”€ service-worker.js     # PWA service worker
โ”‚   โ”‚   โ””โ”€โ”€ manifest.json         # PWA manifest
โ”‚   โ”œโ”€โ”€ .env.production           # Production environment config โš ๏ธ
โ”‚   โ”œโ”€โ”€ .env.local.example        # Local dev config template
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ backend/                   # Node.js API server
โ”‚   โ”œโ”€โ”€ controllers/              # Request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ adminController.js
โ”‚   โ”‚   โ”œโ”€โ”€ hikeController.js
โ”‚   โ”‚   โ”œโ”€โ”€ paymentController.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ routes/                   # API route definitions
โ”‚   โ”‚   โ”œโ”€โ”€ admin.js
โ”‚   โ”‚   โ”œโ”€โ”€ hikes.js
โ”‚   โ”‚   โ”œโ”€โ”€ auth.js
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ middleware/               # Express middleware
โ”‚   โ”‚   โ”œโ”€โ”€ auth.js               # JWT authentication
โ”‚   โ”‚   โ”œโ”€โ”€ permissions.js        # Permission checks
โ”‚   โ”‚   โ””โ”€โ”€ rateLimit.js          # Rate limiting
โ”‚   โ”œโ”€โ”€ services/                 # Business logic
โ”‚   โ”‚   โ”œโ”€โ”€ emailService.js       # SendGrid integration
โ”‚   โ”‚   โ”œโ”€โ”€ smsService.js         # Twilio integration
โ”‚   โ”‚   โ””โ”€โ”€ socketService.js      # WebSocket handling
โ”‚   โ”œโ”€โ”€ config/                   # Configuration
โ”‚   โ”‚   โ”œโ”€โ”€ database.js           # DB connection
โ”‚   โ”‚   โ””โ”€โ”€ env.js                # Environment variables
โ”‚   โ”œโ”€โ”€ migrations/               # Database migrations (future)
โ”‚   โ”œโ”€โ”€ tools/                    # Utility scripts
โ”‚   โ”œโ”€โ”€ .env.example              # Backend config template
โ”‚   โ””โ”€โ”€ server.js                 # Application entry point
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ docs/                      # Documentation
โ”‚   โ”œโ”€โ”€ setup-guides/             # Getting started guides
โ”‚   โ”œโ”€โ”€ deployment/               # Deployment documentation
โ”‚   โ”œโ”€โ”€ architecture/             # System design
โ”‚   โ”œโ”€โ”€ features/                 # Feature documentation
โ”‚   โ”œโ”€โ”€ development/              # Developer guides
โ”‚   โ”œโ”€โ”€ configuration/            # Config guides
โ”‚   โ”œโ”€โ”€ compliance/               # POPIA & security
โ”‚   โ”œโ”€โ”€ mobile/                   # PWA & mobile docs
โ”‚   โ””โ”€โ”€ archive/                  # Archived documentation
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ scripts/                   # Deployment & utility scripts
โ”‚   โ””โ”€โ”€ pre-deploy-check.sh       # Pre-deployment validation (future)
โ”‚
โ”œโ”€โ”€ ๐Ÿ“‚ docker/                    # Docker configuration (local dev)
โ”‚   โ””โ”€โ”€ docker-compose.yml        # Local dev environment
โ”‚
โ””โ”€โ”€ ๐Ÿ“‚ .git/                      # Git repository

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ (Download)
  • Google Cloud SDK (Install)
  • Firebase CLI - npm install -g firebase-tools
  • Git - For version control

Local Development Setup

# 1. Clone the repository
git clone https://github.com/yourusername/hiking-portal.git
cd hiking-portal

# 2. Install backend dependencies
cd backend
npm install

# 3. Configure backend (create .env file)
cp .env.example .env
# Edit .env with your local database credentials

# 4. Start backend
npm start
# Backend runs on http://localhost:5000

# 5. In a new terminal, install frontend dependencies
cd frontend
npm install

# 6. Configure frontend (for local development)
cp .env.local.example .env.local
# Edit .env.local to point to http://localhost:5000

# 7. Start frontend
npm start
# Frontend runs on http://localhost:3000

Using Docker (Alternative)

# Start all services with Docker Compose
cd docker
docker-compose up -d

# Services will be available at:
# - Frontend: http://localhost:3000
# - Backend: http://localhost:5000
# - Database: localhost:5433

๐Ÿš€ Deployment

โš ๏ธ IMPORTANT: Always Use the Checklist

Before deploying to production:

  1. Read PRE_DEPLOYMENT_CHECKLIST.md
  2. Complete ALL checklist items
  3. Follow DEPLOYMENT.md step-by-step

Quick Deploy (If Checklist Complete)

# 1. Deploy Backend
cd backend
gcloud run deploy backend \
  --source . \
  --region europe-west1 \
  --project helloliam \
  --allow-unauthenticated \
  --set-env-vars="NODE_ENV=production,DB_USER=postgres,DB_NAME=hiking_portal,DB_HOST=/cloudsql/helloliam:us-central1:hiking-db,DB_PORT=5432,FRONTEND_URL=https://www.thenarrowtrail.co.za" \
  --add-cloudsql-instances=helloliam:us-central1:hiking-db \
  --set-secrets="DB_PASSWORD=db-password:latest,JWT_SECRET=jwt-secret:latest,SENDGRID_API_KEY=sendgrid-key:latest,SENDGRID_FROM_EMAIL=sendgrid-from-email:latest,OPENWEATHER_API_KEY=openweather-api-key:latest,TWILIO_ACCOUNT_SID=twilio-sid:latest,TWILIO_AUTH_TOKEN=twilio-token:latest,TWILIO_WHATSAPP_NUMBER=twilio-whatsapp-number:latest"

# 2. Deploy Frontend
cd frontend
npm run build
firebase deploy --only hosting

For complete deployment instructions, see DEPLOYMENT.md.


๐Ÿ  Home Assistant Integration

HACS Custom Version

Monitor and manage your hiking portal directly from Home Assistant!

The Home Assistant integration has been moved to a dedicated repository for easier installation and maintenance.

๐Ÿ‘‰ hiking-portal-homeassistant

Quick Install via HACS

1. HACS โ†’ Integrations โ†’ โ‹ฎ โ†’ Custom repositories
2. Add: https://github.com/steyncd/hiking-portal-homeassistant
3. Category: Integration
4. Install "The Narrow Trail Hiking Portal"
5. Restart Home Assistant
6. Configuration โ†’ Integrations โ†’ Add โ†’ "The Narrow Trail"

Features

  • ๐Ÿ“Š 24 Sensors - Hikes, notifications, weather, payments, WebSocket
  • ๐Ÿšจ 3 Binary Sensors - Urgent notifications, weather warnings, connection status
  • ๐Ÿ“… Calendar - All hikes as calendar events
  • โšก 7 Services - Express interest, mark attendance, notifications, payments, weather
  • ๐Ÿ”„ Real-time Updates - WebSocket support for instant notifications

๐Ÿ“Š Recent Updates

October 15, 2025 - Production Fixes

  • โœ… Fixed: Backend database connection using Unix socket
  • โœ… Fixed: All 12 users now display (pagination issue resolved)
  • โœ… Fixed: Correct backend URL in frontend configuration
  • โœ… Added: Smart pagination with per-page selector
  • โœ… Added: Comprehensive deployment documentation

October 14, 2025 - Production Deployment

  • โœ… Backend deployed to Cloud Run
  • โœ… Frontend deployed to Firebase Hosting
  • โœ… Database migrated to Cloud SQL
  • โœ… Secret Manager configured
  • โœ… SSL certificates configured

October 13, 2025 - Major Updates

  • โœ… Permission system audit complete
  • โœ… User role management enhanced
  • โœ… Mobile responsiveness improved
  • โœ… Performance optimizations
  • โœ… Code cleanup and organization

๐Ÿ”ง Configuration

Critical Configuration Files

  1. frontend/.env.production - Frontend production config

    • Contains backend API URL
    • MUST be verified before every deployment
    • See CONFIGURATION.md
  2. Backend Environment - Set via Cloud Run deployment

    • Environment variables set via gcloud run deploy
    • Secrets stored in Secret Manager
    • Database connection via Unix socket
  3. Database - Cloud SQL PostgreSQL

    • Instance: helloliam:us-central1:hiking-db
    • Connection: Unix socket for Cloud Run
    • Backups: Automated daily

For complete configuration reference, see CONFIGURATION.md.


๐Ÿ†˜ Troubleshooting

Common Issues

Issue: Frontend shows "Failed to fetch"

Issue: Backend database connection errors

  • Cause: Using TCP IP instead of Unix socket
  • Solution: Redeploy with correct DB_HOST
  • See: CONFIGURATION.md

Issue: Users not all displaying

  • Status: โœ… Fixed in latest deployment
  • Solution: Frontend now requests all users with ?limit=1000

For more troubleshooting, see:


๐Ÿ› ๏ธ Development

API Documentation

API endpoints are documented in backend/api-docs/.

Base URL (Production): https://backend-4kzqyywlqq-ew.a.run.app

Authentication: JWT Bearer token in Authorization header

Example API calls:

# Public endpoints (no auth)
GET /api/hikes/public
GET /api/public-content/mission_vision

# Authenticated endpoints
GET /api/hikes (requires login)
POST /api/hikes (requires admin)
GET /api/admin/users (requires admin)

Database Schema

See docs/architecture/DATABASE_SCHEMA.md for complete schema documentation.

Tables:

  • users - User accounts and profiles
  • hikes - Hiking events
  • hike_interest - User registrations
  • payments - Payment tracking
  • roles & permissions - Access control
  • And 20+ more tables

๐Ÿ“š Documentation

Essential Reading

  1. Quick Start Guide - Get up and running
  2. Deployment Guide - Production deployment
  3. Configuration Reference - All settings explained
  4. Pre-Deployment Checklist - Before every deploy

Additional Documentation


๐Ÿค Contributing

  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

Code Standards

  • Backend: ESLint with Airbnb config
  • Frontend: ESLint with React config
  • Commits: Conventional commit messages
  • Testing: Write tests for new features

๐Ÿ“ง Support

Developer: Christiaan Steyn Email: steyncd@gmail.com Project: The Narrow Trail Hiking Portal Status: โœ… Production Ready


๐Ÿ“„ License

This project is private and proprietary.


Last Updated: October 15, 2025 Version: 2.0.0 Status: โœ… Production - Fully Operational

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors