Technical Documentation

Developer Documentation

Complete technical specifications, API documentation, and integration guide for Neyatech platform

1. Technology Stack

Frontend (Already Built)

  • Framework: Pure HTML/CSS with Tailwind CSS v3
  • Icons: Font Awesome 6
  • Fonts: Cairo & Tajawal (Arabic support)
  • Authentication UI: Clerk.js integration ready
  • Responsive: Mobile, Tablet, Desktop optimized

Recommended Backend Stack

  • Runtime: Node.js (v18+) with Express.js OR Python with FastAPI
  • Database: PostgreSQL 15+ (recommended) or MongoDB
  • Authentication: Clerk (already integrated in frontend)
  • File Storage: AWS S3, Cloudinary, or DigitalOcean Spaces
  • Email Service: SendGrid, Mailgun, or AWS SES
  • Real-time: Socket.io for notifications (optional)

Note: Frontend is 100% complete and functional. You only need to build the backend API and connect it.

2. Database Schema (PostgreSQL)

users

id               UUID PRIMARY KEY DEFAULT uuid_generate_v4()
clerk_user_id    VARCHAR(255) UNIQUE NOT NULL
email            VARCHAR(255) UNIQUE NOT NULL
full_name        VARCHAR(255) NOT NULL
phone            VARCHAR(50)
user_type        ENUM('owner', 'volunteer', 'admin') NOT NULL
profile_image    VARCHAR(500)
location         VARCHAR(255)
bio              TEXT
is_verified      BOOLEAN DEFAULT FALSE
rating           DECIMAL(3,2) DEFAULT 0.00
total_reviews    INTEGER DEFAULT 0
created_at       TIMESTAMP DEFAULT NOW()
updated_at       TIMESTAMP DEFAULT NOW()
              

intentions

id               UUID PRIMARY KEY DEFAULT uuid_generate_v4()
owner_id         UUID REFERENCES users(id) ON DELETE CASCADE
title            VARCHAR(255) NOT NULL
description      TEXT NOT NULL
category         ENUM('prayer', 'umrah', 'charity', 'holy_sites', 'zamzam', 'quran') NOT NULL
location         VARCHAR(255) NOT NULL
status           ENUM('pending', 'accepted', 'in_progress', 'completed', 'cancelled') DEFAULT 'pending'
deadline         TIMESTAMP
cost             DECIMAL(10,2) DEFAULT 0.00
image_url        VARCHAR(500)
views_count      INTEGER DEFAULT 0
volunteer_id     UUID REFERENCES users(id) ON DELETE SET NULL
accepted_at      TIMESTAMP
completed_at     TIMESTAMP
created_at       TIMESTAMP DEFAULT NOW()
updated_at       TIMESTAMP DEFAULT NOW()
              

proof_submissions

id               UUID PRIMARY KEY DEFAULT uuid_generate_v4()
intention_id     UUID REFERENCES intentions(id) ON DELETE CASCADE
volunteer_id     UUID REFERENCES users(id) ON DELETE CASCADE
proof_type       ENUM('photo', 'video', 'document') NOT NULL
file_url         VARCHAR(500) NOT NULL
description      TEXT
is_approved      BOOLEAN DEFAULT FALSE
submitted_at     TIMESTAMP DEFAULT NOW()
              

reviews

id               UUID PRIMARY KEY DEFAULT uuid_generate_v4()
intention_id     UUID REFERENCES intentions(id) ON DELETE CASCADE
owner_id         UUID REFERENCES users(id) ON DELETE CASCADE
volunteer_id     UUID REFERENCES users(id) ON DELETE CASCADE
rating           INTEGER CHECK (rating >= 1 AND rating <= 5) NOT NULL
comment          TEXT
is_public        BOOLEAN DEFAULT TRUE
created_at       TIMESTAMP DEFAULT NOW()
              

notifications

id               UUID PRIMARY KEY DEFAULT uuid_generate_v4()
user_id          UUID REFERENCES users(id) ON DELETE CASCADE
type             VARCHAR(50) NOT NULL
title            VARCHAR(255) NOT NULL
message          TEXT NOT NULL
link             VARCHAR(500)
is_read          BOOLEAN DEFAULT FALSE
created_at       TIMESTAMP DEFAULT NOW()
              

Database Creation Script: Run the SQL migration script to create all tables with proper indexes and foreign keys.

3. API Endpoints Specification

👤 User Management

GET /api/users/:userId

Get user profile information

Response:
{
  "id": "uuid",
  "email": "[email protected]",
  "full_name": "Ahmed Mohamed",
  "user_type": "volunteer",
  "rating": 4.9,
  "total_reviews": 38
}
PUT /api/users/:userId

Update user profile

Body:
{
  "full_name": "Ahmed Mohamed",
  "phone": "+966501234567",
  "location": "Makkah, Saudi Arabia",
  "bio": "Certified volunteer..."
}

🙏 Intentions Management

GET /api/intentions

Get all intentions with filters

Query Params:
?category=umrah&status=pending&location=makkah&page=1&limit=10
POST /api/intentions

Create a new intention

Body:
{
  "title": "Umrah for My Father",
  "description": "Perform complete Umrah...",
  "category": "umrah",
  "location": "Makkah",
  "deadline": "2025-12-31T23:59:59Z",
  "cost": 0.00
}
PUT /api/intentions/:id/accept

Volunteer accepts an intention

Body:
{
  "volunteer_id": "uuid",
  "estimated_completion": "2025-12-15T10:00:00Z"
}
PUT /api/intentions/:id/complete

Mark intention as completed

Body:
{
  "status": "completed",
  "completion_notes": "Umrah completed successfully..."
}

📸 Proof Submissions

POST /api/proofs

Upload proof of intention fulfillment

Body (multipart/form-data):
{
  "intention_id": "uuid",
  "proof_type": "photo",
  "file": [File],
  "description": "Photo taken at Kaaba..."
}
GET /api/intentions/:id/proofs

Get all proof submissions for an intention

⭐ Reviews & Ratings

POST /api/reviews

Submit a review for volunteer

Body:
{
  "intention_id": "uuid",
  "volunteer_id": "uuid",
  "rating": 5,
  "comment": "Excellent work!",
  "is_public": true
}
GET /api/volunteers/:id/reviews

Get all public reviews for a volunteer

🔔 Notifications

GET /api/notifications

Get all notifications for logged-in user

Query Params:
?unread_only=true&page=1&limit=20
PUT /api/notifications/:id/read

Mark notification as read

Authentication Required

All API endpoints (except public browsing) require authentication via JWT token in the Authorization header:

Authorization: Bearer <jwt_token>

4. Authentication with Clerk

Frontend Integration (Already Done)

Clerk.js is already integrated in the frontend. Users can sign up and log in through the registration page.

Publishable Key: pk_test_ZmFtb3VzLXJhdHRsZXItODguY2xlcmsuYWNjb3VudHMuZGV2JA

Backend Integration Steps

Step 1: Install Clerk SDK

npm install @clerk/clerk-sdk-node

Step 2: Initialize Clerk in Backend

const { ClerkExpressWithAuth } = require('@clerk/clerk-sdk-node');

// Middleware for protected routes
app.use('/api/*', ClerkExpressWithAuth({
  secretKey: process.env.CLERK_SECRET_KEY
}));

// Access user info in routes
app.get('/api/profile', (req, res) => {
  const userId = req.auth.userId; // Clerk user ID
  // Query your database...
});

Step 3: Sync User Data

Use Clerk webhooks to sync user data to your database when users sign up:

// Webhook endpoint: /api/webhooks/clerk
app.post('/api/webhooks/clerk', async (req, res) => {
  const { type, data } = req.body;
  
  if (type === 'user.created') {
    await db.users.create({
      clerk_user_id: data.id,
      email: data.email_addresses[0].email_address,
      full_name: `${data.first_name} ${data.last_name}`,
      user_type: data.public_metadata.user_type || 'owner'
    });
  }
});

Important: Store your Clerk Secret Key in environment variables and never expose it in frontend code.

5. File Upload Implementation

Recommended: AWS S3

Step 1: Install AWS SDK

npm install aws-sdk multer multer-s3

Step 2: Configure Upload Middleware

const AWS = require('aws-sdk');
const multer = require('multer');
const multerS3 = require('multer-s3');

const s3 = new AWS.S3({
  accessKeyId: process.env.AWS_ACCESS_KEY,
  secretAccessKey: process.env.AWS_SECRET_KEY,
  region: 'us-east-1'
});

const upload = multer({
  storage: multerS3({
    s3: s3,
    bucket: 'neyatech-proofs',
    acl: 'public-read',
    key: function (req, file, cb) {
      cb(null, `proofs/${Date.now()}-${file.originalname}`);
    }
  }),
  fileFilter: (req, file, cb) => {
    // Accept images and videos only
    if (file.mimetype.startsWith('image/') || 
        file.mimetype.startsWith('video/')) {
      cb(null, true);
    } else {
      cb(new Error('Invalid file type'), false);
    }
  },
  limits: { fileSize: 50 * 1024 * 1024 } // 50MB max
});

// Upload endpoint
app.post('/api/proofs', upload.single('file'), (req, res) => {
  res.json({
    file_url: req.file.location,
    file_key: req.file.key
  });
});

Alternative: You can also use Cloudinary or DigitalOcean Spaces for simpler setup.

6. Deployment Guide

Frontend (Already Deployed)

✅ Your frontend is already live on Landingsite.ai at: ar.neyatech.net

All you need to do is connect your backend API endpoints to make it fully functional.

Backend Deployment Options

AWS (Recommended)

  • EC2 for backend server
  • RDS for PostgreSQL
  • S3 for file storage
  • CloudFront for CDN
  • Route 53 for DNS

DigitalOcean

  • Droplet for backend
  • Managed PostgreSQL
  • Spaces for files
  • Easier setup
  • Cost-effective

Heroku

  • Quick deployment
  • Built-in PostgreSQL
  • Simple scaling
  • CI/CD integration
  • Good for MVP

Vercel / Railway

  • Modern platform
  • Auto-deploy from Git
  • Serverless options
  • Fast setup
  • Free tier available

Required Environment Variables

DATABASE_URL=postgresql://user:pass@host:5432/neyatech
CLERK_SECRET_KEY=sk_test_xxxxxxxxxxxxx
CLERK_PUBLISHABLE_KEY=pk_test_xxxxxxxxxxxxx
AWS_ACCESS_KEY=xxxxxxxxxxxx
AWS_SECRET_KEY=xxxxxxxxxxxx
AWS_BUCKET_NAME=neyatech-proofs
SENDGRID_API_KEY=xxxxxxxxxxxx
JWT_SECRET=your-secret-key
PORT=3000
NODE_ENV=production

Ready to Build?

The frontend is 100% complete and live. Follow this documentation to build and connect your backend API. Need help? Contact the development team!