📚 Technical Documentation: Architecture - Structure

This document provides an overview of the architecture and structure of the frontend application built with Angular 10, SCSS, and integrated external APIs. The application is modular, ensuring maintainability, scalability, and separation of concerns.


🏗️ Application Architecture

The application follows a modular structure, adhering to Angular's best practices. This structure ensures that components, services, and other entities are well-organized and easy to manage.

Key Characteristics:

  • Angular CLI is used for project configuration, building, and serving the application.
  • SCSS is employed for styling, with modular SCSS files for better maintainability.
  • External APIs are integrated via Angular services for seamless data handling.
  • Guards are implemented to protect routes based on user roles or authentication status.

📂 Folder Structure

The project is organized into the following main folders:

Folder Purpose
src/app Contains the core application logic, including components, services, etc.
src/assets Stores static files like SCSS, images, and fonts.
src/environments Holds environment-specific configurations (e.g., development, production).
src/styles.scss Global SCSS styles for the application.

🔑 Core Directories in src/app

Folder Description
components Houses reusable UI components like payments, orders, and brand profiles.
services Includes Angular services for API interaction (e.g., accounts.service.ts).
guards Contains route guards for access control (e.g., auth.guard.ts).
layout Manages layout components like the sidebar and navigation.
helpers Contains utility files like interceptors for HTTP requests.

📦 Angular CLI Configuration

The Angular CLI configuration file (angular.json) defines the build and serve processes. Below are some key configurations:

{
  "projects": {
    "volley-app": {
      "architect": {
        "build": {
          "options": {
            "outputPath": "dist/volley-app",
            "styles": [
              "src/styles.scss",
              "src/assets/scss/style.scss"
            ],
            "scripts": []
          }
        },
        "serve": {
          "options": {
            "browserTarget": "volley-app:build"
          }
        }
      }
    }
  }
}

📂 Styles and Assets

The SCSS files are modularized for better maintainability:

  • Helpers: Includes mixins and variables (_mixins.scss).
  • Base: Contains foundational styles like colors and fonts (_colors.scss, _fonts.scss).
  • Components: Styles specific to UI components (_buttons.scss, _modal.scss).
  • Layout: Styles for structural elements like tables and forms (_tables.scss, _forms.scss).

🚦 Route Guards

Guards are implemented to ensure secure and controlled navigation. Examples include:

  • auth.guard.ts: Restricts access to authenticated users.
  • isBrandGuard.ts: Ensures only brand users access certain routes.

🛠️ Components and Services

Example of a component (payments.component.ts):

@Component({
  selector: 'app-payments',
  templateUrl: './payments.component.html',
  styleUrls: ['./payments.component.scss']
})
export class PaymentsComponent implements OnInit {
  constructor(private accountsService: AccountsService) {}
  ngOnInit(): void {
    this.accountsService.currentUser.subscribe(user => {
      console.log(user);
    });
  }
}

Example of a service (insights.service.ts):

@Injectable({ providedIn: 'root' })
export class InsightsService {
  constructor(private http: HttpClient) {}

  getInsights(data: any): Observable<InsightResponse> {
    return this.http.get<InsightResponse>(`${environment.apiUrl}/public/kpi/orders`, { params: data });
  }
}

🌟 Highlights

  • Modular SCSS: Organized styles for components, layouts, and helpers.
  • Angular CLI: Streamlines builds, serves, and environment management.
  • Guards: Secures routes based on roles and authentication.
  • Services: Decouples API logic from components for cleaner code.

This modular architecture ensures the application is robust, scalable, and maintainable. 🚀