Skip to content
Β 
Β 

Latest commit

Β 

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Review Assignment Due Date Open in Codespaces

Student Social App

A mobile social networking application built with React Native and Expo, allowing students to share posts with images and captions, connect with peers, and manage their profiles.

πŸ“± Features

  • User Authentication: Secure registration and login with JWT tokens
  • Username System: Unique usernames for user identification
  • Social Feed: View posts from all students in chronological order
  • Create Posts: Share images with captions using camera or photo library
  • Profile Management: View and edit student profiles
  • Event Feed: Browse upcoming events with capacity tracking
  • My Tickets: Track event tickets
  • Event Capacity: Organisers can set ticket limits; students see remaining spots and "fully booked" status
  • Real-time Updates: Posts automatically sync with the database
  • Follow System: Follow/unfollow students and organisations, view follower/following counts
  • In-App Notifications: Notification center for likes, comments, ticket confirmations, and new events from followed organisations
  • Notification Settings: Toggle notifications on/off with persistent settings

πŸ› οΈ Tech Stack

Frontend

  • React Native with Expo (~54.0)
  • Expo Router for file-based navigation
  • TypeScript for type safety
  • expo-image-picker for media selection
  • expo-secure-store for secure token storage
  • Context API for state management

Backend

  • Node.js with Express.js
  • TypeScript
  • Prisma ORM for database management
  • PostgreSQL database (Neon DB)
  • JWT for authentication
  • bcryptjs for password hashing

πŸ“ Project Structure

comp2003-2025-2026-team-21/
β”œβ”€β”€ docs/                          # Documentation and design files
β”‚   β”œβ”€β”€ design/                    # Design documents
β”‚   └── trello/                    # Trello board snapshots
β”œβ”€β”€ scripts/                       # Utility scripts
β”‚   └── init-env.sh               # Environment initialization
└── SourceCode/
    β”œβ”€β”€ backend/                   # Node.js/Express backend
    β”‚   β”œβ”€β”€ prisma/               # Database schema and migrations
    β”‚   β”‚   β”œβ”€β”€ schema.prisma     # Database models
    β”‚   β”‚   └── migrations/       # Migration history
    β”‚   └── src/
    β”‚       β”œβ”€β”€ controllers/      # Business logic
    β”‚       β”œβ”€β”€ middleware/       # Auth & role middleware
    β”‚       β”œβ”€β”€ routes/           # API routes
    β”‚       β”œβ”€β”€ types/            # TypeScript definitions
    β”‚       β”œβ”€β”€ utils/            # Utilities (Prisma client)
    β”‚       └── server.ts         # Express server entry point
    └── frontend/                  # React Native/Expo app
        β”œβ”€β”€ app/                   # Expo Router pages
        β”‚   β”œβ”€β”€ components/       # Reusable components
        β”‚   β”œβ”€β”€ contexts/         # Context providers
        β”‚   β”œβ”€β”€ createPost.tsx    # Post creation page
        β”‚   β”œβ”€β”€ socialStudent.tsx # Social feed
        β”‚   β”œβ”€β”€ profileStudent.tsx # Profile view
        β”‚   └── ...
        β”œβ”€β”€ assets/               # Images and static files
        └── lib/                  # API helpers
            β”œβ”€β”€ api.ts            # API configuration
            β”œβ”€β”€ apiBase.ts        # Base URL handler
            └── postsApi.ts       # Posts API functions

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Expo CLI
  • PostgreSQL database (or Neon DB account)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd comp2003-2025-2026-team-21
  2. Backend Setup

    cd SourceCode/backend
    npm install
  3. Configure Environment Variables

    Create a .env file in the backend directory:

    DATABASE_URL="your-postgres-connection-string"
    JWT_SECRET="your-secret-key"
    PORT=3001
  4. Run Database Migrations

    npx prisma migrate dev
    npx prisma generate
  5. Start Backend Server

    npm run dev

    Server will run on http://localhost:3001

  6. Frontend Setup

    cd ../frontend
    npm install
  7. Start Expo App

    npx expo start --tunnel

    Use the Expo Go app on your phone to scan the QR code, or:

    • Press a for Android emulator
    • Press i for iOS simulator
    • Press w for web
  8. Make 3001 Port Public if Need Be

     -Right Click on Port 
     -Port Visability
     -Select Public
    

πŸ—„οΈ Database Schema

User

  • id: UUID (primary key)
  • email: String (unique)
  • username: String (unique)
  • name: String
  • password: String (hashed)
  • role: Enum (STUDENT, SOCIETY_ORGANIZER)
  • Posts relationship (one-to-many)

Event

  • id: UUID (primary key)
  • title: String
  • description: String
  • date: DateTime
  • location: String
  • price: Decimal
  • category: String
  • capacity: Int? (optional, null = unlimited tickets)
  • eventImageUrl: String?
  • organiserId: String (foreign key to Organisation)
  • Tickets relationship (one-to-many)

Posts

  • id: UUID (primary key)
  • caption: String
  • image: Bytes (binary image data)
  • imageMimeType: String
  • authorId: String (foreign key to User)
  • createdAt: DateTime
  • User relationship (many-to-one)

Follow

  • id: UUID (primary key)
  • followerId: String (who is following)
  • followerType: String (STUDENT or ORGANISATION)
  • followingId: String (who is being followed)
  • followingType: String (STUDENT or ORGANISATION)
  • createdAt: DateTime

Notification

  • id: UUID (primary key)
  • type: String (POST_LIKE, POST_COMMENT, TICKET_CONFIRMED, NEW_EVENT)
  • title: String
  • body: String
  • data: JSON (optional payload with postId, eventId, etc.)
  • read: Boolean
  • userId: String
  • userRole: String
  • createdAt: DateTime

PushToken

  • id: UUID (primary key)
  • token: String (unique, Expo push token)
  • userId: String
  • userRole: String
  • createdAt: DateTime

πŸ” Authentication

The app uses JWT-based authentication:

  1. Registration: Users create an account with email, username, name, and password
  2. Login: Returns a JWT token stored securely using expo-secure-store
  3. Protected Routes: Backend routes use authMiddleware to verify tokens
  4. Token Storage: Tokens persisted securely on the device

πŸ“‘ API Endpoints

Authentication

  • POST /auth/register - Create new user account
  • POST /auth/login - Login and receive JWT token
  • GET /auth/me - Get current user information

Posts

  • POST /posts - Create a new post (requires auth)
  • GET /posts - Get all posts with author information
  • GET /posts/user/:userId - Get posts by specific user
  • DELETE /posts/:postId - Delete a post (requires auth)

Follow

  • POST /follow/:targetId - Follow a user or organisation
  • DELETE /follow/:targetId - Unfollow a user or organisation
  • GET /follow/check/:targetId - Check if current user is following target
  • GET /follow/counts/:userId - Get follower and following counts
  • GET /follow/followers/:userId - Get list of followers
  • GET /follow/following/:userId - Get list of following

Notifications

  • POST /notifications/register-token - Register push notification token
  • DELETE /notifications/register-token - Unregister push token
  • GET /notifications - Get user's notifications
  • PATCH /notifications/:id/read - Mark notification as read
  • PATCH /notifications/read-all - Mark all notifications as read
  • DELETE /notifications/:id - Delete a notification
  • GET /notifications/settings - Get notification preferences
  • PUT /notifications/settings - Update notification preferences

πŸ§ͺ Development Tools

Prisma Studio

View and edit database records:

cd SourceCode/backend
npx prisma studio

Database Inspection

Check migration status:

npx prisma migrate status

Reset database (development only):

npx prisma migrate reset

πŸ“¦ Key Dependencies

Frontend

  • expo - React Native framework
  • expo-router - File-based routing
  • expo-image-picker - Media selection
  • expo-secure-store - Secure storage
  • expo-file-system - File operations

Backend

  • express - Web framework
  • @prisma/client - Database ORM
  • jsonwebtoken - JWT authentication
  • bcryptjs - Password hashing
  • cors - Cross-origin requests

πŸ› Troubleshooting

Backend not connecting:

  • Verify DATABASE_URL in .env
  • Check if PostgreSQL is running
  • Ensure migrations are up to date: npx prisma migrate dev

Frontend can't reach backend:

  • Use --tunnel flag with expo start for remote testing
  • Check API_URL configuration in lib/apiBase.ts
  • Verify backend is running on port 3001

Image upload failing:

  • Check backend JSON limit (set to 10mb in server.ts)
  • Verify image is being converted to base64 properly
  • Check file permissions for camera/library access

πŸ“„ License

MIT

πŸ‘₯ Team

Team 21 - COMP2003 2025-2026


For more details, see documentation in the docs/ directory.

About

comp2003-2025-2026-comp2003_2025-2026-COMP2003-2024 created by GitHub Classroom

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages