Skip to main content

Angular Example

This project is a note-taking app template built with Angular, TypeScript, and Tailwind CSS, designed to demonstrate integration with Juno for app development. It showcases authentication, data storage, and file storage using Juno's Satellite container.

You can scaffold it using the following command, or browse the source code:

npm create juno@latest -- --template react-example

Source: github.com/junobuild/create-juno/templates/angular-example


Folder Structure

angular-example/
├── public/ # Static assets
├── src/
│ ├── app/ # Angular modules, components, services, and types
│ ├── environments/ # Environment configuration files
│ ├── styles.css # Tailwind CSS styles
│ └── main.ts # Angular entry point
├── juno.config.mjs # Juno Satellite configuration
├── package.json # Project dependencies and scripts
├── angular.json # Angular CLI configuration
├── README.md # User-facing documentation
└── ... # Other config and build files

Key Features

  • Juno Integration: Uses Juno's Satellite for authentication, Datastore, and Storage.
  • Authentication: Login/logout flow.
  • Notes Collection: Users can create, view, and delete notes (text, with optional file URL).
  • Images Collection: Supports file storage for images.
  • Responsive UI: Built with Tailwind CSS for modern styling.
  • Banner: Warns if the Satellite is not configured for local development.

Main Components

  • app.component.ts: Main Angular component, bootstraps the app and layout.
  • components/: Contains UI and logic for authentication, notes table, modal, banner, etc.
  • services/: Angular services for interacting with Juno and managing app state.
  • types/note.ts: TypeScript interface for notes.

Data Structure

  • Note (src/app/types/note.ts):
    export interface Note {
    text: string;
    url?: string;
    }

How to Run

  1. Install dependencies:
npm install
  1. Start Juno local emulator:
important

Requires the Juno CLI to be available npm i -g @junobuild/cli

juno dev start
  1. Create a Satellite for local dev:

    • Visit http://localhost:5866 and follow the instructions.
    • Update src/environments/environment.ts with your Satellite ID.
  1. Create required collections:
  1. Start the frontend dev server (in a separate terminal):
npm run start

Juno-Specific Configuration

  • juno.config.mjs: Defines Satellite IDs for development/production, build source, and predeploy steps.
  • src/environments/environment.ts: Contains the Satellite ID for local development.
  • src/environments/environment.prod.ts: Contains the Satellite ID for production.

Production Deployment

  • Create a Satellite on the Juno Console for mainnet.
  • Update src/environments/environment.prod.ts and juno.config.mjs with the production Satellite ID.
  • Build and deploy:
    npm run build
    juno deploy

Notes

  • The app is intended as a starting point for Juno-based projects.
  • All logic is in TypeScript and Angular components/services.
  • The app is fully client-side (Server Side Rendering is not supported yet) and interacts with Juno via the Satellite container.

Juno SDK Used

The following functions from @junobuild/core are used in this example:

FunctionPurpose/DescriptionWhere Used (File/Component)Juno Docs/Source Reference
initSatelliteInitialize Juno Satellite containersrc/app/app.component.tsInitialization
authSubscribeSubscribe to auth state changessrc/app/services/auth.service.tsSubscription
signInSign in usersrc/app/components/login/login.component.tsSign-in
signOutSign out usersrc/app/components/logout/logout.component.tsSign-out
listDocsList documents in a collectionsrc/app/services/docs.service.tsList documents
setDocCreate or update a documentsrc/app/components/modal/modal.component.tsAdd a document
deleteDocDelete a documentsrc/app/components/delete/delete.component.tsDelete a document
uploadFileUpload a file to storagesrc/app/components/modal/modal.component.tsUpload asset
deleteAssetDelete a file from storagesrc/app/components/delete/delete.component.tsDelete asset