Skip to content

Latest commit

Β 

History

History
358 lines (296 loc) Β· 9.69 KB

File metadata and controls

358 lines (296 loc) Β· 9.69 KB

UniMatch Kenya - Complete Setup & Deployment Guide

A free, campus-exclusive dating platform for Kenyan university and college students built with modern, production-ready technologies.

πŸ“‹ Table of Contents

🎯 Project Overview

UniMatch Kenya is a mobile-first dating application designed specifically for university and college students in Kenya. The platform emphasizes safety, authenticity, and a vibrant campus community experience.

Key Features:

  • Email verification using institutional email domains (.ac.ke, .edu)
  • Swipe-based discovery with intelligent matching
  • Real-time messaging with WebSocket support
  • User safety with reporting and blocking features
  • Profile completeness tracking
  • Responsive design with dark mode support

πŸ› οΈ Technology Stack

Backend

  • Framework: Django 5.0 + Django REST Framework
  • Database: PostgreSQL 16
  • Cache & Broker: Redis 7
  • Real-time: Django Channels + Daphne
  • Tasks: Celery with Beat scheduler
  • Server: Gunicorn with Uvicorn workers
  • Proxy: Nginx with rate limiting

Frontend

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • State Management: Zustand
  • HTTP Client: Axios
  • Animations: Framer Motion
  • Styling: Tailwind CSS (to be added)
  • Testing: Jest + React Testing Library

Infrastructure

  • Containerization: Docker & Docker Compose
  • Email: SMTP (Gmail recommended for dev)
  • File Storage: Cloudinary
  • Production: Manual scaling with monitoring

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 18+ (for frontend development)
  • Python 3.11+ (for backend development)
  • PostgreSQL 16 (if running without Docker)

Local Development with Docker Compose

  1. Clone and setup environment:
cd /home/samdev652/Desktop/UniMatch\ Kenya
cp .env.example .env
# Edit .env with your configuration
  1. Start all services:
docker-compose up --build
  1. Run migrations:
docker-compose exec backend python manage.py migrate
docker-compose exec backend python manage.py createsuperuser
  1. Access the application:

Manual Development Setup

Backend:

cd backend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
export DJANGO_SETTINGS_MODULE=unmatch_kenya.settings.development
python manage.py migrate
python manage.py runserver

Frontend:

cd frontend
npm install
npm run dev

Redis (macOS with Homebrew):

brew install redis
redis-server

πŸ—οΈ Architecture

Directory Structure

UniMatch Kenya/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ unmatch_kenya/           # Main Django project
β”‚   β”‚   β”œβ”€β”€ settings/            # Base, dev, production configs
β”‚   β”‚   β”œβ”€β”€ asgi.py              # Channels config
β”‚   β”‚   β”œβ”€β”€ wsgi.py              # WSGI config
β”‚   β”‚   β”œβ”€β”€ celery.py            # Celery config
β”‚   β”‚   └── urls.py              # URL routing
β”‚   β”œβ”€β”€ apps/
β”‚   β”‚   β”œβ”€β”€ users/               # Authentication & user management
β”‚   β”‚   β”œβ”€β”€ profiles/            # User profile & photos
β”‚   β”‚   β”œβ”€β”€ matching/            # Swipe algorithm & matches
β”‚   β”‚   β”œβ”€β”€ messaging/           # Chat & WebSocket
β”‚   β”‚   β”œβ”€β”€ notifications/       # In-app notifications
β”‚   β”‚   └── reports/             # Moderation system
β”‚   β”œβ”€β”€ core/                    # Shared utilities
β”‚   β”œβ”€β”€ manage.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/                     # Next.js App Router pages
β”‚   β”œβ”€β”€ components/              # React components
β”‚   β”œβ”€β”€ hooks/                   # Custom React hooks
β”‚   β”œβ”€β”€ store/                   # Zustand stores
β”‚   β”œβ”€β”€ lib/                     # Utilities (API client, etc)
β”‚   β”œβ”€β”€ types/                   # TypeScript definitions
β”‚   β”œβ”€β”€ __tests__/               # Jest tests
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”œβ”€β”€ next.config.js
β”‚   └── Dockerfile
β”œβ”€β”€ infrastructure/
β”‚   └── nginx/                   # Nginx configuration
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .editorconfig
└── README.md

Data Models Relationship

User (1) ───────► UserProfile (1)
  β”‚                    β”‚
  β”œβ”€β”€β–Ί VerificationOTP │──► ProfilePhoto
  β”‚                    β”‚
  β”œβ”€β”€β–Ί UserBlock       └──► ProfileInterest
  β”‚
  β”œβ”€β”€β–Ί Swipe ◄────►User (Many-to-Many via swipe)
  β”‚
  β”œβ”€β”€β–Ί Match
  β”‚      β”‚
  β”‚      └──► Message
  β”‚              β”‚
  β”‚              └──► User (sender)
  β”‚
  β”œβ”€β”€β–Ί Notification
  β”‚
  └──► Report

πŸ“Š Database Schema Highlights

Connection Pooling

  • Pool size: 20 connections
  • Max overflow: 10 additional connections
  • Timeout: 600 seconds (auto-reconnect)

Indexes

-- Swipes: Quick access by swiper & swiped
CREATE INDEX idx_swipes_swiper ON swipes(swiper_id, created_at DESC);
CREATE INDEX idx_swipes_swiped ON swipes(swiped_id, created_at DESC);

-- Messages: Efficient chat retrieval
CREATE INDEX idx_messages_match ON messages(match_id, created_at DESC);

-- Users: Location & activity queries
CREATE INDEX idx_users_campus ON users(campus, last_active DESC);

πŸ”Œ API Endpoints

Base URL: /api/v1/

Authentication

POST   /auth/register/          - Register new user
POST   /auth/verify/            - Verify email with OTP
POST   /auth/login/             - Login (JWT)
POST   /auth/refresh/           - Refresh token
GET    /auth/me/                - Current user profile
PATCH  /auth/me/update/         - Update profile

Profiles

GET    /profiles/my_profile/    - Get user's profile
POST   /profiles/upload_photo/  - Upload profile photo
POST   /profiles/add_interests/ - Add interests
PATCH  /profiles/update_bio/    - Update bio & looking_for

Discovery & Matching

GET    /matching/discover/feed/ - Get discover feed (20 candidates)
POST   /matching/discover/like/ - Like a profile
POST   /matching/discover/pass_profile/ - Pass on profile
GET    /matching/matches/       - List all active matches
POST   /matching/matches/{id}/unmatch/ - Unmatch with user

Messaging

GET    /messages/conversations/ - Get all conversations
POST   /messages/send_message/  - Send message in match
POST   /messages/mark_as_read/  - Mark messages as read

WebSocket: /ws/chat/{match_id}/

Notifications

GET    /notifications/          - List notifications
GET    /notifications/unread/   - Get unread count
POST   /notifications/{id}/mark_as_read/ - Mark as read
POST   /notifications/mark_all_as_read/

Reports

POST   /reports/report_user/    - Submit report
GET    /reports/                - List user's reports

πŸš€ Deployment

Environment Variables

Critical variables for production:

DEBUG=False
SECRET_KEY=<generate-strong-key>
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com
DATABASE_URL=postgresql://user:pass@host:5432/dbname
REDIS_URL=redis://host:6379/0
CLOUDINARY_CLOUD_NAME=<your-cloud-name>
CLOUDINARY_API_KEY=<api-key>
CLOUDINARY_API_SECRET=<api-secret>
EMAIL_HOST_USER=<gmail@example.com>
EMAIL_HOST_PASSWORD=<app-password>
CORS_ALLOWED_ORIGINS=https://yourdomain.com
JWT_EXPIRATION_HOURS=1
JWT_REFRESH_EXPIRATION_DAYS=7

Production Checklist

  • Set DEBUG=False
  • Generate secure SECRET_KEY
  • Configure PostgreSQL connection pooling
  • Set up Redis persistence
  • Configure Cloudinary for image moderation
  • Set up HTTPS/SSL certificates
  • Configure email backend (SendGrid/Mailgun recommended)
  • Set up log aggregation (Sentry)
  • Configure database backups
  • Set up monitoring & alerting

Using Gunicorn

gunicorn --workers=4 \
         --worker-class=uvicorn.workers.UvicornWorker \
         --bind=0.0.0.0:8000 \
         --timeout=30 \
         unmatch_kenya.wsgi:application

βœ… Testing & Monitoring

Backend Testing

# Run all tests
pytest

# With coverage
pytest --cov=apps --cov-report=html

# Specific app
pytest apps/users/tests/

# Watch mode
pytest-watch

Frontend Testing

# Run unit tests
npm test

# With coverage
npm run test:coverage

# Watch mode
npm test -- --watch

Load Testing

# Using Locust - simulate 600 concurrent users
locust -f tests/load_test.py --host=http://localhost:8000

Monitoring

  • Database: Monitor slow queries, connection pool utilization
  • Redis: Monitor memory usage, eviction policies
  • Celery: Monitor task queue length, worker availability
  • WebSocket: Monitor active connections, message throughput
  • Response times: API latency, WebSocket message delivery

πŸ“ Contributing

  1. Create a feature branch: git checkout -b feature/your-feature
  2. Make changes following the project conventions
  3. Write tests for new features
  4. Run linting: black . && flake8 apps/
  5. Commit with clear messages
  6. Push and create a Pull Request

πŸ“„ License

Proprietary - UniMatch Kenya 2026


Questions or Issues? Create an issue or contact the development team.