diff --git a/README.md b/README.md index 15317b2..dc95abf 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,97 @@ -# Ad Astra +# AdAstra App -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.2.2. +Frontend of the AdAstra platform — a multi-domain Angular application covering e-commerce, CMS, skydive club management, and Hero Wars guild analytics. -## Development server +## Tech stack -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. +| Layer | Choice | +| --------- | ------------------------------------------------------------------ | +| Framework | Angular 21 (standalone components, no NgModules) | +| Language | TypeScript 5.9 — strict mode + strictTemplates | +| UI | Angular Material 21, Bootstrap 5 | +| Charts | Chart.js 4 (ng2-charts), Chartist | +| HTTP | Angular HttpClient with three interceptors (base URL, JWT, errors) | +| Tests | Karma + Jasmine | +| Linting | angular-eslint + Prettier (enforced via lint-staged) | +| Node | `^20.19.0 \|\| ^22.12.0` | -## Code scaffolding +## Related repository -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. +The backend API lives in [`adastra_api`](../adastra_api) — an Express + Sequelize stack, routes grouped under `/api/ecommerce`, `/api/cms`, `/api/skydive`, `/api/herowars`. -## Build +## Getting started -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. +```bash +npm install +npm run local # dev server on :4400, uses environment.local.ts +``` -## Running unit tests +Copy and configure your local environment: -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). +```bash +cp src/environments/environment.example.ts src/environments/environment.local.ts +# fill in: apiBaseUrl, apiKey, googleMapApiKey, … +``` -## Running end-to-end tests +## Commands -Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. +| Command | Description | +| --------------- | ----------------------------------------------------- | +| `npm start` | Dev server on :4200 with production config | +| `npm run dev` | Dev server on :4300 with `environment.development.ts` | +| `npm run local` | Dev server on :4400 with `environment.local.ts` | +| `npm run build` | Production build → `dist/adastra_angular/` | +| `npm run watch` | Incremental build in development configuration | +| `npm run lint` | angular-eslint on `**/*.ts` and `**/*.html` | +| `npm test` | Karma + Jasmine unit tests | -## Further help +Run a single spec: -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. +```bash +ng test --include src/path/to/file.spec.ts +``` + +## Architecture + +### Bootstrap + +`AppComponent` renders a single `FullComponent` shell (Material sidenav + toolbar). Routes are split into two arrays in `app.routes.ts`: + +- `auth.routes.ts` — protected by `authGuard`; admin sections additionally require `adminGuard` +- `noauth.routes.ts` — public pages and auth entry points, blocked by `noauthGuard` when already authenticated + +Data is pre-fetched by resolvers under `src/app/core/resolvers/` — new route components should follow this pattern rather than fetching in `ngOnInit`. + +### HTTP pipeline + +Three interceptors applied in order: + +1. **`apiInterceptor`** — prepends `environment.apiBaseUrl` to every request. Services use relative paths (`/cms/user`, `/skydive/jumps`, …), never absolute URLs. +2. **`tokenInterceptor`** — attaches `Authorization: Token ` when a token exists in `localStorage['jwtToken']`. +3. **`errorInterceptor`** — unwraps `err.error` and rethrows. + +### Feature domains + +| Domain | Routes | Backend prefix | +| ---------- | ------------------------------------------------------ | ---------------- | +| E-commerce | `products`, `product/:slug`, `products/:category` | `/api/ecommerce` | +| CMS | `pages`, `page/:slug`, `home`, profiles, articles | `/api/cms` | +| Skydive | `skydive/*` — aeronefs, canopies, dropzones, jumps | `/api/skydive` | +| Hero Wars | Guild analytics, weekly snapshots in `src/files-data/` | `/api/herowars` | + +### Path aliases + +Defined in `tsconfig.json`; always prefer them over relative imports: + +``` +@components @services @models @guards +@interceptors @resolvers @viewmodels @interfaces +@constants @core/* @environments/* +@data/* @assets/* @styles/* +``` + +When adding a new file, export it from the appropriate `index.ts` barrel so the alias resolves correctly. + +### Styling + +SCSS with `includePaths: ["src/styles"]` — imports like `@use 'variables'` resolve globally. Material date locale is set to `fr-FR` with `DD/MM/YYYY` format.