# ASCO

A cylinder management platform for tracking gas cylinders, clients, drivers, vehicles, warehouses and maintenance. The project is split into a **NestJS** backend (REST API + Prisma/MySQL) and a **Next.js** frontend.

## Project Structure

```
asco/
├── backend/                  # NestJS + Prisma REST API (MySQL)
│   ├── prisma/
│   │   ├── schema.prisma     # Database schema
│   │   ├── seed.ts           # Seed data
│   │   └── seed-masters.ts   # Master data seed
│   ├── src/
│   │   ├── auth/             # Authentication (JWT, Google, Facebook)
│   │   ├── blacklist/        # Token blacklist
│   │   ├── common/           # Shared filters, guards, interceptors, utils
│   │   ├── config/           # Env config & validation
│   │   ├── modules/          # Feature modules
│   │   │   ├── clients/
│   │   │   ├── cylinder-client/
│   │   │   ├── cylinderlogs/
│   │   │   ├── cylinders/
│   │   │   ├── dashboard/
│   │   │   ├── driver/
│   │   │   ├── external-api/
│   │   │   ├── maintenance-history/
│   │   │   ├── masters/
│   │   │   ├── reader/
│   │   │   ├── vehicle/
│   │   │   └── warehouse/
│   │   ├── selects/          # Reusable Prisma select objects
│   │   ├── users/            # User management
│   │   ├── app.module.ts
│   │   └── main.ts           # App entrypoint
│   ├── uploads/              # Uploaded files
│   └── package.json
│
├── frontend/                 # Next.js (App Router) web client
│   ├── public/
│   ├── src/
│   │   ├── app/             # Routes (dashboard, clients, cylinder,
│   │   │                    #   drivers, vehicles, warehouse, report, …)
│   │   ├── common/          # Shared helpers
│   │   ├── components/      # Reusable UI components
│   │   ├── lib/             # API client & utilities
│   │   └── types/           # TypeScript types
│   └── package.json
│
└── README.md
```

## Tech Stack

- **Backend:** NestJS 11, Prisma 6, MySQL, JWT (Passport), Winston logging
- **Frontend:** Next.js 15, React 19, Tailwind CSS 4, Chart.js, Axios

## Prerequisites

- Node.js 20+
- MySQL database
- npm

## Getting Started

### Backend

```bash
cd backend
npm install

# Configure environment
cp .env.example .env        # then edit values (DATABASE_URL, JWT secrets, etc.)

# Set up the database
npm run prisma:generate
npx prisma migrate deploy   # or: npx prisma db push
npm run seed                # optional: seed initial data

# Run
npm run start:dev           # development (watch mode)
npm run start:prod          # production (after `npm run build`)
```

The API runs on `http://localhost:3001` by default (see `PORT` in `.env`).

### Frontend

```bash
cd frontend
npm install

# Run
npm run dev                 # development → http://localhost:3000
npm run build && npm start  # production
```

Point the frontend at the API via its environment configuration (e.g. the API base URL) before running.

## Useful Scripts

### Backend
| Command | Description |
| --- | --- |
| `npm run start:dev` | Start in watch mode |
| `npm run build` | Compile to `dist/` |
| `npm run start:prod` | Run compiled build |
| `npm run prisma:studio` | Open Prisma Studio |
| `npm run seed` | Seed the database |
| `npm run lint` | Lint and auto-fix |
| `npm test` | Run tests |

### Frontend
| Command | Description |
| --- | --- |
| `npm run dev` | Start dev server |
| `npm run build` | Production build |
| `npm start` | Serve production build |
| `npm run lint` | Lint |
