An open API service indexing awesome lists of open source software.

https://github.com/krguptaa/ionic-angular-boilerplate

Ionic 8 + Angular 17 Boilerplate ๐Ÿš€ โ€“ A production-ready starter kit for building cross-platform apps (Android, iOS, Web/PWA) with JWT authentication, secure storage, API layer, and modular theme customization.
https://github.com/krguptaa/ionic-angular-boilerplate

cross-platform hybrid-app ionic ionic-android ionic-angular ionic-angular-boilerplate ionic-apps ionic-boilerplate ionic-framework ionic-ios ionic-native ionic-pwa ionic-starter ionic8 mobile-app mobile-app-development mobile-application mobile-development progressive-web-app

Last synced: 5 months ago
JSON representation

Ionic 8 + Angular 17 Boilerplate ๐Ÿš€ โ€“ A production-ready starter kit for building cross-platform apps (Android, iOS, Web/PWA) with JWT authentication, secure storage, API layer, and modular theme customization.

Awesome Lists containing this project

README

          

# Ionic 8 + Angular Boilerplate

A comprehensive, production-ready Ionic 8 + Angular boilerplate with authentication, theming, platform-specific features, and modern development practices.

![Ionic](https://img.shields.io/badge/Ionic-8.0.0-blue.svg)
![Angular](https://img.shields.io/badge/Angular-20.0.0-red.svg)
![TypeScript](https://img.shields.io/badge/TypeScript-5.8.0-blue.svg)
![Capacitor](https://img.shields.io/badge/Capacitor-7.0.0-green.svg)

## โœจ Features

### ๐Ÿ” Authentication & Security
- JWT-based authentication with refresh tokens
- Secure storage for sensitive data
- Route guards with role-based access control
- Automatic token refresh and session management
- Password reset and account recovery

### ๐ŸŽจ Theming & UI
- Comprehensive theme system with light/dark/auto modes
- Responsive design with breakpoints
- Reusable UI components (buttons, inputs, modals, alerts, toasts)
- Customizable color schemes and typography
- Platform-specific styling

### ๐Ÿ“ฑ Platform Support
- **Web/PWA**: Full PWA support with service worker and offline capabilities
- **Android**: Native Android app with full device integration
- **iOS**: Native iOS app with platform-specific features
- Cross-platform camera, location, and push notification support

### ๐Ÿ”ง Core Services
- **API Service**: Generic HTTP client with interceptors and error handling
- **State Management**: Angular Signals-based reactive state management
- **Platform Service**: Device detection and platform-specific features
- **Network Monitoring**: Real-time connectivity status and offline support

### ๐Ÿ“ฆ Additional Features
- Form validation utilities
- Date/time formatting helpers
- File upload and management
- Push notifications with background handling
- Biometric authentication support
- Haptic feedback and device vibration
- Clipboard and sharing capabilities

## ๐Ÿš€ Quick Start

### Prerequisites
- Node.js 18+ and npm
- Ionic CLI: `npm install -g @ionic/cli`
- Angular CLI: `npm install -g @angular/cli`

### Installation

1. **Clone the repository**:
```bash
git clone https://github.com/krguptaa/ionic-angular-boilerplate.git
cd ionic-angular-boilerplate
```

2. **Install dependencies**:
```bash
npm install
```

3. **Set up environment variables**:
```bash
cp src/environments/environment.ts src/environments/environment.prod.ts
# Edit environment files with your API endpoints
```

4. **Run the development server**:
```bash
npm start
```

## ๐Ÿ“‹ Project Structure

```
src/
โ”œโ”€โ”€ app/
โ”‚ โ”œโ”€โ”€ auth/ # Authentication module
โ”‚ โ”‚ โ”œโ”€โ”€ login/ # Login page
โ”‚ โ”‚ โ”œโ”€โ”€ register/ # Registration page
โ”‚ โ”‚ โ””โ”€โ”€ auth-routing.module.ts
โ”‚ โ”œโ”€โ”€ guards/ # Route guards
โ”‚ โ”‚ โ””โ”€โ”€ auth.guard.ts # Authentication guard
โ”‚ โ”œโ”€โ”€ home/ # Home page
โ”‚ โ”œโ”€โ”€ interceptors/ # HTTP interceptors
โ”‚ โ”‚ โ””โ”€โ”€ auth.interceptor.ts # JWT token interceptor
โ”‚ โ”œโ”€โ”€ models/ # TypeScript interfaces
โ”‚ โ”œโ”€โ”€ services/ # Application services
โ”‚ โ”‚ โ”œโ”€โ”€ api.service.ts # Generic API service
โ”‚ โ”‚ โ”œโ”€โ”€ auth.service.ts # Authentication service
โ”‚ โ”‚ โ”œโ”€โ”€ camera.service.ts # Camera functionality
โ”‚ โ”‚ โ”œโ”€โ”€ location.service.ts # Geolocation service
โ”‚ โ”‚ โ”œโ”€โ”€ platform.service.ts # Platform utilities
โ”‚ โ”‚ โ”œโ”€โ”€ push-notifications.service.ts # Push notifications
โ”‚ โ”‚ โ””โ”€โ”€ state/ # State management
โ”‚ โ”‚ โ”œโ”€โ”€ base-state.service.ts
โ”‚ โ”‚ โ”œโ”€โ”€ user-state.service.ts
โ”‚ โ”‚ โ”œโ”€โ”€ app-state.service.ts
โ”‚ โ”‚ โ””โ”€โ”€ network-state.service.ts
โ”‚ โ”œโ”€โ”€ shared/ # Shared components and modules
โ”‚ โ”‚ โ”œโ”€โ”€ components/ # Reusable UI components
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ alert/ # Alert component
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ toast/ # Toast notifications
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ card/ # Card component
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ badge/ # Badge component
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ custom-button/ # Enhanced button
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ custom-input/ # Enhanced input
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ custom-modal/ # Enhanced modal
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ loading-spinner/ # Loading spinner
โ”‚ โ”‚ โ””โ”€โ”€ shared.module.ts # Shared module
โ”‚ โ”œโ”€โ”€ utilities/ # Utility classes
โ”‚ โ”‚ โ”œโ”€โ”€ date.utils.ts # Date formatting
โ”‚ โ”‚ โ”œโ”€โ”€ validation.utils.ts # Form validation
โ”‚ โ”‚ โ”œโ”€โ”€ platform.utils.ts # Platform detection
โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Utility exports
โ”‚ โ”œโ”€โ”€ constants/ # Application constants
โ”‚ โ”œโ”€โ”€ theme/ # Theme configuration
โ”‚ โ”‚ โ””โ”€โ”€ variables.scss # SCSS variables
โ”‚ โ””โ”€โ”€ environments/ # Environment configurations
โ”œโ”€โ”€ assets/ # Static assets
โ”œโ”€โ”€ android/ # Android platform files
โ”œโ”€โ”€ ios/ # iOS platform files
โ””โ”€โ”€ resources/ # Icon and splash screen sources
```

## ๐Ÿ—๏ธ Architecture

### State Management
The application uses Angular Signals for reactive state management:

```typescript
// User state example
export class UserStateService extends BaseStateService {
public readonly isLoggedIn = computed(() => this.state().isAuthenticated);
public readonly currentUser = computed(() => this.state().currentUser);

setUser(user: User, token: string) {
this.updateState({
currentUser: user,
isAuthenticated: true,
session: { token, refreshToken: null, expiresAt: null }
});
}
}
```

### Service Layer
Clean separation of concerns with dedicated services:

```typescript
// API Service with error handling
@Injectable({ providedIn: 'root' })
export class ApiService {
get(endpoint: string, options?: ApiOptions): Observable {
return this.request('GET', endpoint, null, options);
}

post(endpoint: string, data: any, options?: ApiOptions): Observable {
return this.request('POST', endpoint, data, options);
}
}
```

### Component Architecture
Reusable, platform-aware components:

```typescript
@Component({
selector: 'app-custom-button',
template: `




`
})
export class CustomButtonComponent {
@Input() loading = false;
@Output() buttonClick = new EventEmitter();
}
```

## ๐Ÿ“ฑ Platform-Specific Setup

### Android Setup

1. **Add Android platform**:
```bash
npx cap add android
```

2. **Configure permissions** in `android/app/src/main/AndroidManifest.xml`

3. **Build and run**:
```bash
npx cap run android
```

### iOS Setup

1. **Add iOS platform**:
```bash
npx cap add ios
```

2. **Configure permissions** in `ios/App/App/Info.plist`

3. **Build and run**:
```bash
npx cap run ios
```

### PWA Setup

1. **Build for production**:
```bash
npm run build
```

2. **Serve with HTTPS** for full PWA functionality

3. **Register service worker** (automatically configured)

## ๐ŸŽจ Theming

### Theme Configuration
The application supports multiple theme modes:

```scss
// Light theme (default)
:root {
--theme-bg-primary: #ffffff;
--theme-text-primary: #000000;
--theme-primary: #3880ff;
}

// Dark theme
[data-theme="dark"] {
--theme-bg-primary: #1e1e1e;
--theme-text-primary: #ffffff;
--theme-primary: #4c8dff;
}
```

### Theme Service
```typescript
@Injectable({ providedIn: 'root' })
export class ThemeService {
setTheme(theme: 'light' | 'dark' | 'auto') {
// Implementation
}

toggleTheme() {
// Implementation
}
}
```

## ๐Ÿ” Authentication Flow

### Login Process
```typescript
// Login component
async onLogin(credentials: LoginRequest) {
try {
const response = await this.authService.login(credentials).toPromise();
this.userState.setUser(response.user, response.accessToken);
this.router.navigate(['/home']);
} catch (error) {
this.toastService.showError('Login failed');
}
}
```

### Route Protection
```typescript
// Route guard
canActivate(route: ActivatedRouteSnapshot): boolean {
if (!this.authService.isLoggedIn()) {
this.router.navigate(['/auth/login']);
return false;
}
return true;
}
```

## ๐Ÿ“ก API Integration

### Base API Configuration
```typescript
// API Service
export const APP_CONSTANTS = {
API_BASE_URL: 'https://api.example.com',
TIMEOUTS: {
HTTP_REQUEST: 30000,
CACHE_EXPIRY: 3600000
}
};
```

### HTTP Interceptor
```typescript
// Auth Interceptor
intercept(request: HttpRequest, next: HttpHandler): Observable> {
// Add JWT token to requests
const token = await this.authService.getAccessToken();
if (token) {
request = request.clone({
setHeaders: { Authorization: `Bearer ${token}` }
});
}
return next.handle(request);
}
```

## ๐Ÿงช Testing

### Unit Tests
```bash
npm run test
```

### E2E Tests
```bash
npm run e2e
```

### Linting
```bash
npm run lint
```

## ๐Ÿ“ฆ Build & Deployment

### Development
```bash
npm start # Development server
npm run watch # Watch mode
```

### Production Build
```bash
npm run build # Web build
npx cap build # Native builds
```

### Deployment
```bash
# Web deployment
npm run build --prod
# Deploy to hosting service

# Android deployment
npx cap build android
# Sign and upload to Play Store

# iOS deployment
npx cap build ios
# Archive and upload to App Store
```

## ๐Ÿ”ง Configuration

### Environment Variables
```typescript
// src/environments/environment.ts
export const environment = {
production: false,
apiUrl: 'https://api-dev.example.com',
enableDebug: true,
firebaseConfig: { /* ... */ }
};
```

### Capacitor Configuration
```typescript
// capacitor.config.ts
const config: CapacitorConfig = {
appId: 'com.yourcompany.boilerplate',
appName: 'Ionic Boilerplate',
webDir: 'www',
plugins: {
Camera: { allowEditing: true },
Geolocation: { enableHighAccuracy: true },
PushNotifications: { presentationOptions: ["badge", "sound", "alert"] }
}
};
```

## ๐Ÿ“š Documentation

- [Ionic Documentation](https://ionicframework.com/docs)
- [Angular Documentation](https://angular.io/docs)
- [Capacitor Documentation](https://capacitorjs.com/docs)
- [Icons & Splash Screens Guide](./ICONS_SPLASH_README.md)

## ๐Ÿค Contributing

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit your changes: `git commit -m 'Add amazing feature'`
4. Push to the branch: `git push origin feature/amazing-feature`
5. Open a Pull Request

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- Ionic Framework team
- Angular team
- Capacitor team
- All contributors and the open-source community

## ๐Ÿ“ž Support

For support, email webworldgk@gmail.com (Kamlesh Gupta).

---

**Happy coding! ๐Ÿš€**

Built with โค๏ธ using Ionic 8 + Angular