v1 code db
This commit is contained in:
@@ -1,60 +1,124 @@
|
||||
# Aero Resolve - Backend
|
||||
# AeroResolve Backend
|
||||
|
||||
This is the backend REST API powered by NestJS.
|
||||
NestJS REST API for AeroResolve.
|
||||
|
||||
## 🚀 Getting Started
|
||||
## Current Modules
|
||||
|
||||
### Prerequisites
|
||||
- Node.js (v18+)
|
||||
| Module | Status | Description |
|
||||
|--------|--------|-------------|
|
||||
| `health` | Implemented | Health check |
|
||||
| `database` | Implemented | PostgreSQL / TypeORM setup |
|
||||
| `master-data` | Implemented | CRUD and seed data for lookup categories |
|
||||
| `cohort` | Implemented | Cohort CRUD, pagination, status update |
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Node.js 18+
|
||||
- npm
|
||||
- PostgreSQL
|
||||
|
||||
### Installation
|
||||
1. Navigate to the backend directory:
|
||||
```bash
|
||||
cd backend
|
||||
```
|
||||
2. Install the dependencies:
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
### Environment Files
|
||||
|
||||
The project uses environment-specific files. The npm scripts automatically set `NODE_ENV` so the correct file is loaded (e.g. `.env.dev`).
|
||||
|
||||
- `.env.local`
|
||||
- `.env.dev`
|
||||
- `.env.uat`
|
||||
- `.env.test`
|
||||
|
||||
### Running the Application
|
||||
|
||||
To start the server, use the command corresponding to your target environment:
|
||||
## Install
|
||||
|
||||
```bash
|
||||
# Local environment
|
||||
npm run local
|
||||
npm run start:local # (watch mode)
|
||||
|
||||
# Development environment
|
||||
npm run dev
|
||||
npm run start:dev # (watch mode)
|
||||
|
||||
# UAT environment
|
||||
npm run uat
|
||||
npm run start:uat # (watch mode)
|
||||
|
||||
# Test environment
|
||||
npm run test
|
||||
npm install
|
||||
```
|
||||
|
||||
### Database Seeding
|
||||
## Environment Files
|
||||
|
||||
To run the master data seed scripts for a specific environment:
|
||||
The app loads environment files based on `NODE_ENV`:
|
||||
|
||||
```text
|
||||
.env.local
|
||||
.env.dev
|
||||
.env.test
|
||||
.env.uat
|
||||
```
|
||||
|
||||
Required values:
|
||||
|
||||
```text
|
||||
PORT=3001
|
||||
CORS_ORIGIN=http://localhost:5174
|
||||
DB_HOST=localhost
|
||||
DB_PORT=5432
|
||||
DB_USER=<postgres-user>
|
||||
DB_PASSWORD=<postgres-password>
|
||||
DB_NAME=<database-name>
|
||||
DB_SYNCHRONIZE=true
|
||||
DB_SSL=false
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
# Local
|
||||
npm run local
|
||||
npm run start:local
|
||||
|
||||
# Dev
|
||||
npm run dev
|
||||
npm run start:dev
|
||||
|
||||
# UAT
|
||||
npm run uat
|
||||
npm run start:uat
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Base URL:
|
||||
|
||||
```text
|
||||
http://localhost:3001/api
|
||||
```
|
||||
|
||||
Swagger:
|
||||
|
||||
```text
|
||||
http://localhost:3001/docs
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Method | Path |
|
||||
|--------|------|
|
||||
| `GET` | `/api/health` |
|
||||
| `GET` | `/api/master-data/:category` |
|
||||
| `POST` | `/api/master-data/:category` |
|
||||
| `GET` | `/api/master-data/:category/:id` |
|
||||
| `PUT` | `/api/master-data/:category/:id` |
|
||||
| `DELETE` | `/api/master-data/:category/:id` |
|
||||
| `GET` | `/api/cohorts?page=1&limit=10` |
|
||||
| `POST` | `/api/cohorts` |
|
||||
| `GET` | `/api/cohorts/:id` |
|
||||
| `PUT` | `/api/cohorts/:id` |
|
||||
| `PATCH` | `/api/cohorts/:id/status` |
|
||||
| `DELETE` | `/api/cohorts/:id` |
|
||||
|
||||
## Seed Master Data
|
||||
|
||||
```bash
|
||||
npm run seed:local
|
||||
npm run seed:dev
|
||||
npm run seed:uat
|
||||
npm run seed:test
|
||||
npm run seed:uat
|
||||
```
|
||||
|
||||
Seeded categories:
|
||||
|
||||
- `MEMBERSHIP_TIER`
|
||||
- `CUSTOMER_VALUE`
|
||||
- `REGION`
|
||||
- `TRIP_PURPOSE`
|
||||
- `CABIN_CLASS`
|
||||
- `PASSENGER_TYPE`
|
||||
- `ANCILLARY_PURCHASE`
|
||||
- `REVENUE_SEGMENT`
|
||||
|
||||
## Planned Next
|
||||
|
||||
- Tenant foundation
|
||||
- Auth / RBAC
|
||||
- Audit logging
|
||||
- Policy / regulation engine backend
|
||||
- Compensation engine
|
||||
|
||||
Reference in New Issue
Block a user