Skip to main content

Frontend Architecture

Overview

The Smart Academic Hub frontend follows a component-based architecture with clear separation of concerns.

Architecture Layers

View Layer

  • Vue 3 components with Composition API
  • Reusable UI components
  • Layout components

State Management

  • Pinia stores for global state
  • Composables for shared logic
  • Local component state when appropriate

Service Layer

  • API service classes
  • HTTP interceptors
  • Error handling

Type Layer

  • TypeScript interfaces and types
  • API response types
  • Component prop types

Directory Structure

src/
├── assets/ # Static assets (images, fonts)
├── components/ # Reusable Vue components
├── composables/ # Composition API reusable logic
├── layouts/ # Layout components
├── router/ # Vue Router configuration
├── services/ # API and service classes
├── stores/ # Pinia state stores
├── types/ # TypeScript types and interfaces
├── utils/ # Utility functions
└── views/ # Page components

Component Organization

Atomic Design Pattern

  • Atoms: Basic UI elements (buttons, inputs)
  • Molecules: Simple component combinations
  • Organisms: Complex UI sections
  • Templates: Page layouts
  • Pages: Complete views

State Management

Global State (Pinia)

  • User authentication state
  • Academy context
  • Shared data

Local State

  • Component-specific data
  • Form state
  • UI state (modals, dropdowns)

Design Patterns

  • Composition API: For component logic reuse
  • Composables: Shared reactive logic
  • Service Pattern: API abstraction
  • Provider/Inject: Deep component communication

Best Practices

  1. Use TypeScript for type safety
  2. Keep components small and focused
  3. Extract reusable logic to composables
  4. Use Pinia for global state
  5. Implement proper error handling
  6. Follow Vue 3 style guide