Overview
The TikTok Clone project follows a feature-based modular structure that promotes separation of concerns and scalability. Each major component has its dedicated directory with clear responsibilities.Directory Structure
MainApplication/
Core application setup and base classes for the entire app.Files in MainApplication/
Files in MainApplication/
- AppDelegate.swift
- SceneDelegate.swift
- TabBarController.swift
- BaseViewController.swift
Entry point for the application lifecycle.Location:
MainApplication/AppDelegate.swiftResponsibilities:- Application launch configuration
- Firebase initialization
- App lifecycle events (background, foreground)
Modules/
Feature-based modules implementing specific app functionality. Each module is self-contained with its own views, view models, and supporting files.Home Module
Home Module
The video feed feature displaying scrollable short-form videos.Location:
Modules/Home/Files:HomeViewController.swift- Main feed controller with table viewHomeViewModel.swift- Business logic and data managementHomeTableViewCell.swift- Individual video cellVideoPlayerView.swift- Custom video player UIVideoPlayerManager.swift- Video playback coordinationCommentPopUpView.swift- Comment section overlayCommentTableViewCell.swift- Individual comment cell
- Paginated video loading (10 per page)
- Automatic video playback on scroll
- Prefetching for smooth scrolling
- Audio session management
Modules/Home/HomeViewModel.swift:14-75Media Module
Media Module
Video recording, editing, and posting functionality.Location: Reference:
Modules/Media/Files:MediaViewController.swift- Camera interfaceMediaViewModel.swift- Recording and upload logicMediaPostingViewController.swift- Post creation screenCameraManager.swift- Camera and recording managementViews/MediaPlayerView.swift- Preview playerRecordButton.swift- Custom recording buttonAccessPermissionView.swift- Permission request UI
- Camera capture with AVFoundation
- Video recording with timer
- Post metadata (caption, music, author info)
- Firebase Storage upload
Modules/Media/MediaViewModel.swift:23-34Profile Module
Profile Module
User profile display with video grid.Location:
Modules/Profile/Files:ProfileViewController.swift- Profile page with collection viewProfileViewModel.swift- Profile state and cache managementProfileCollectionViewCell.swift- Video thumbnail cellsProfileCollectionViewFlowLayout.swift- Custom grid layoutProfileHeaderView.swift- User info headerProfileSlideBarView.swift- Tab selector (Posts/Liked)
- Custom collection view with stretching header
- 3-column video grid
- Parallax effect on background image
Modules/Profile/ProfileViewController.swift:12-166Discover & Inbox Modules
Discover & Inbox Modules
Discover Module (
Modules/Discover/)- Search and explore functionality
DiscoverViewController.swift- Search interface
Modules/Inbox/)- Messaging and notifications
InboxViewController.swift- Messages list
Entity/
Data models, cache managers, and domain entities.- Models/
- VideoCache/
Core data structures representing app entities.Location: User.swift (Comment.swift
Entity/Models/Post.swift (Entity/Models/Post.swift:13-85)Entity/Models/User.swift:12-26)- Comment text and metadata
- User information
- Timestamp and likes
Network/
Firebase integration and API request handlers.Network Implementation Details
Network Implementation Details
NetworkModel.swift (PostsRequest.swift (Key Features:
Network/NetworkModel.swift:11-17)Network/GetRequests/PostsRequest.swift:13-56)- Static methods for easy access
- Closure-based completion handlers
- Firebase Firestore queries with pagination
- Firebase Storage URL generation
Extensions/
Swift extensions adding functionality to existing types. Location:Extensions/
- Colors.swift
- UIKit Extensions.swift
- String.swift
- Number.swift
- URL.swift
UIColor extensions for app color scheme
- Brand colors
- Background colors
- Text colors
Utils/
Utility classes and global constants. Location:Utils/
Constants.swift (Utils/Constants.swift:12-22)
Resources/
Assets, animations, and media files.- App icons and tab bar icons
- Profile background images
- Loading animations (Lottie JSON)
- Media button custom icon
File Naming Conventions
The project follows standard Swift naming conventions:Naming Patterns
Naming Patterns
- ViewControllers:
[Feature]ViewController.swift- Example:
HomeViewController.swift,ProfileViewController.swift
- Example:
- ViewModels:
[Feature]ViewModel.swift- Example:
HomeViewModel.swift,MediaViewModel.swift
- Example:
- Views:
[Feature][Component]View.swift- Example:
VideoPlayerView.swift,ProfileHeaderView.swift
- Example:
- Cells:
[Feature]TableViewCell.swiftor[Feature]CollectionViewCell.swift- Example:
HomeTableViewCell.swift,ProfileCollectionViewCell.swift
- Example:
- Models:
[Entity].swift- Example:
Post.swift,User.swift,Comment.swift
- Example:
- Network:
[Entity]Request.swift- Example:
PostsRequest.swift,UserRequest.swift
- Example:
Build Configuration
Xcode Project:KD Tiktok-Clone.xcodeproj
Workspace: KD Tiktok-Clone.xcworkspace (for CocoaPods)
Always open the
.xcworkspace file when working with the project, not the .xcodeproj, to ensure CocoaPods dependencies are properly linked.Dependency Management
The project uses CocoaPods for dependency management. Podfile Location: Root of project directory Installed Pods:- SnapKit (UI layout)
- RxSwift (reactive programming)
- MarqueeLabel (scrolling text)
- lottie-ios (animations)
- Firebase (backend services)
Next Steps
Learn about the implementation patterns:- Architecture Overview - High-level architecture and tech stack
- MVVM Pattern - Detailed MVVM implementation with RxSwift