Skip to content

abrahao-dev/Marvel-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperHero Database App 🦸‍♂️

A beautiful iOS application built with SwiftUI that allows users to explore superheroes and villains from all comic universes using the SuperHero API.

Swift Platform License

📱 Screenshots

Heroes List Hero Detail Loading Screen
List of superheroes with images, alignment badges, and info Detailed view with power stats, biography, appearance, and connections Animated loading screen with progress indicator

✨ Features

  • Browse All Superheroes: Explore a comprehensive database of 731+ heroes and villains from all universes
  • Infinite Scrolling: Seamless pagination with automatic loading of more characters
  • Pull-to-Refresh: Easy content refresh with native SwiftUI gesture
  • Detailed Information: View comprehensive details about each character:
    • Power Statistics (Intelligence, Strength, Speed, Durability, Power, Combat)
    • Biography (Full name, aliases, place of birth, publisher, alignment)
    • Physical Appearance (Gender, race, height, weight, eye/hair color)
    • Work Information (Occupation, base of operations)
    • Connections (Group affiliations, relatives)
  • Visual Indicators: Color-coded alignment badges (Good = Green, Bad = Red)
  • Beautiful UI: Modern design with smooth animations and transitions
  • Offline Support: Cached responses for better offline experience
  • Dark Mode: Full support for iOS dark mode

🏗️ Architecture

The project follows a clean and simple architecture optimized for a small-scale application:

Marvel App/
├── Marvel_AppApp.swift      # App entry point
├── ContentView.swift        # Root view
├── APINetwork.swift         # Network layer with singleton pattern
├── HeroesListView.swift     # Main list view with pagination
├── HeroDetailView.swift     # Character detail view with power stats
├── HeroCell.swift           # Reusable character cell component
├── LoadingView.swift        # Custom animated loading screen
├── ErrorView.swift          # Error handling UI
└── Persistence.swift        # Core Data configuration (for future use)

Key Components

  • APINetwork: Singleton network manager handling all SuperHero API communications with proper error handling
  • Hero Models: Comprehensive codable structs including:
    • Hero: Main character model with all data
    • PowerStats: Character abilities and stats
    • Biography: Character background and publisher info
    • Appearance: Physical characteristics
    • Work: Occupation and base information
    • Connections: Affiliations and relationships
  • SwiftUI Views: Modern declarative UI with NavigationStack for iOS 16+

🔧 Technical Details

Requirements

  • iOS 17.0+
  • Xcode 15.0+
  • Swift 5.9+

Dependencies

This project uses only native Apple frameworks:

  • SwiftUI: Modern declarative UI framework
  • Foundation: Core networking and data handling
  • CoreData: Data persistence (configured for future features)

SuperHero API

The app uses the SuperHero API which provides:

  • Access to 731+ superheroes and villains
  • Comprehensive character information
  • High-quality character images
  • Simple token-based authentication

API Endpoints Used:

  • GET /api/{token}/{id} - Fetch character by ID
  • GET /api/{token}/search/{name} - Search characters by name

🚀 Getting Started

Prerequisites

  1. Get your free API token from SuperHero API
    • Simply login with your GitHub account
    • Your access token will be generated automatically
  2. Xcode 15 or later installed

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/superhero-app.git
cd superhero-app
  1. Open the project in Xcode:
open "Marvel App.xcodeproj"
  1. Update API Token:

    Open APINetwork.swift and replace the token:

    private let accessToken = "YOUR_ACCESS_TOKEN_HERE"

    For Production (Recommended):

    • Create a Config.xcconfig file
    • Add your token:
      SUPERHERO_API_TOKEN = your_token_here
      
    • Update APINetwork.swift to read from environment
  2. Build and run the project (⌘ + R)

📂 Project Structure

Models

struct Hero: Codable, Identifiable, Hashable {
    let id: String
    let name: String
    let powerstats: PowerStats?
    let biography: Biography?
    let appearance: Appearance?
    let work: Work?
    let connections: Connections?
    let image: HeroImage?
}

Network Layer

The APINetwork class provides:

  • Singleton pattern for consistent state management
  • Proper error handling with custom APIError enum
  • URL session configuration with caching
  • Multiple fetch methods:
    • getHeroes(offset:limit:) - Batch fetch heroes by ID range
    • getHero(by:) - Fetch single hero by ID
    • searchHeroes(by:) - Search heroes by name

Views

View Description
HeroesListView Main view with character list and infinite scroll pagination
HeroDetailView Comprehensive character information with power stats visualizations
HeroCell Reusable list cell with hero thumbnail, alignment badge, and preview info
LoadingView Animated loading screen with progress indicator
ErrorView Error display with retry functionality

🎨 UI/UX Features

  • Power Stats Visualization: Progress bars showing character abilities
  • Alignment Badges: Color-coded indicators (Green for heroes, Red for villains)
  • Smooth Transitions: Animated state changes throughout the app
  • Responsive Design: Adapts to different iPhone sizes
  • Native Feel: Follows iOS Human Interface Guidelines
  • Pull-to-Refresh: Native gesture support for content refresh

🔒 Security Considerations

⚠️ Important: The current implementation includes the API token directly in the source code for demonstration purposes. For production:

  1. Use .xcconfig files excluded from version control
  2. Consider using a backend proxy to hide API tokens
  3. Store sensitive data in Keychain for additional security
  4. Never commit tokens to public repositories

🎯 Future Enhancements

  • Search functionality by character name
  • Favorite characters with Core Data persistence
  • Filter by publisher (Marvel, DC, etc.)
  • Filter by alignment (Good, Bad, Neutral)
  • Share character cards
  • Compare two characters side-by-side
  • Support for iPad with adaptive layouts

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • SuperHero API for the comprehensive superhero database
  • SuperHeroDB for character data and images
  • Apple for SwiftUI framework
  • The amazing comic book universes (Marvel, DC, and more) for endless inspiration

📧 Contact

Matheus Abrahão - @yourusername

Project Link: https://github.com/yourusername/superhero-app


Data provided by SuperHero API. Character data from various comic book publishers.

Marvel-App

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages