https://github.com/jessfreak/servicestation
Repository for coursework on the topic Web application for service station support
https://github.com/jessfreak/servicestation
client-server coursework full-stack google-auth imagebb nest react service
Last synced: 2 months ago
JSON representation
Repository for coursework on the topic Web application for service station support
- Host: GitHub
- URL: https://github.com/jessfreak/servicestation
- Owner: JessFreak
- Created: 2024-12-10T20:41:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-13T16:21:41.000Z (about 1 year ago)
- Last Synced: 2025-05-13T17:27:35.083Z (about 1 year ago)
- Topics: client-server, coursework, full-stack, google-auth, imagebb, nest, react, service
- Language: JavaScript
- Homepage:
- Size: 13 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π ServiceStation
**ServiceStation** is a web application designed to support the operations of car service stations. The system provides an intuitive interface for users, mechanics, and administrators to manage profiles, vehicles, services, and orders.
## π οΈ Key Features
- π User authentication and authorization (including Google OAuth)
- π€ Profile management
- π Vehicle management (add, view, edit)
- π§Ύ View service history
- π
Online service booking
- π§° Service management (create, update, delete)
- π¦ Order management (status updates, filtering, assignment)
- π₯ Role-based user management
## π§βπ» Technologies Used
- **Frontend:** React
- **Backend:** NestJS
- **Database:** PostgreSQL
- **OAuth Integration:** Google
- **Image Hosting:** ImgBB
- **Architecture:** Client-Server, REST API
## π Diagrams
For a detailed overview of the system's structure and components, please refer to the `docs/diagrams/` folder.
## π Additional document
Also you can check explanatory note to course work (Ukrainian): ΠΡΡΡΠΎΠ²Π° ΡΠΎΠ±ΠΎΡΠ°.pdf.
## π Running the Project Locally
1. Clone the repository:
```bash
git clone https://github.com/JessFreak/ServiceStation.git
cd ServiceStation
```
2. Fill all env variables.
3. Install all dependencies:
```bash
npn istall
```
3. Run the project:
```bash
npn start
```
## Infrastructure & Production-Grade Features (Lab 0)
This section documents the implementation of the "Level 2" requirements for the project infrastructure.
### Environment Variables
The application requires the following environment variables to be configured.
#### Backend (`back/.env`)
| Variable | Description | Example |
| :--- | :--- | :--- |
| `DB_USER` | Database username | `postgres` |
| `DB_PASSWORD` | Database password | `1234` |
| `DB_HOST` | Database host (Docker service name or localhost) | `db` |
| `DB_PORT` | Database port | `5432` |
| `DB_NAME` | Database name | `service_station` |
| `DATABASE_URL` | Full Prisma connection string | `postgresql://user:pass@host:port/db?schema=public` |
| `PORT` | Backend server port | `8080` |
| `JWT_SECRET` | Secret for JWT signing | `your_secret_key` |
| `JWT_EXPIRE` | JWT expiration time | `1d` |
| `GOOGLE_CLIENT_ID` | OAuth2 Client ID | `your_id.apps.googleusercontent.com` |
| `GOOGLE_CLIENT_SECRET` | OAuth2 Client Secret | `your_secret` |
| `GOOGLE_CALLBACK_URL` | OAuth2 Redirect URI | `http://localhost:8080/auth/google/callback` |
| `CLIENT_URL` | Frontend URL for CORS | `http://localhost:3000` |
#### Frontend (`front/.env`)
| Variable | Description | Example |
| :--- | :--- | :--- |
| `REACT_APP_API_URL` | Backend API base URL | `http://localhost:8080` |
| `REACT_APP_IMGBB_API_KEY` | API Key for image hosting | `your_imgbb_key` |
---
### π©Ί Health Checks
The application provides a deep health check endpoint at `/health` to verify system integrity.
* **Status 200 (OK):** Returned when both the HTTP server and the PostgreSQL database connection are healthy.

* **Status 503 (Service Unavailable):** Returned when the database connection is lost or the service is degraded.

---
### π Structured Logging (JSON)
Logs are output to `STDOUT` in structured JSON format, enabling machine-readability for log aggregators (ELK, Prometheus). Each log contains mandatory `timestamp`, `level`, and `message` fields.
**Example Logs:**
```json
[0] {"level":"INFO","timestamp":"2026-03-11T08:35:16.202Z","context":"NestApplication","message":"Nest application successfully started"}
[0] {"level":"INFO","timestamp":"2026-03-11T08:35:16.203Z","message":"Started server on port 8080"}
[0] {"level":"INFO","timestamp":"2026-03-11T08:35:29.736Z","req":{"method":"GET","url":"/health"},"res":{"statusCode":200},"responseTime":8,"message":"request completed"}
[0] {"level":"ERROR","timestamp":"2026-03-11T08:35:48.008Z","req":{"method":"GET","url":"/health"},"message":"Health Check has failed! {\"database\":{\"message\":\"timeout of 1000ms exceeded\",\"status\":\"down\"}}"}
[0] {"level":"INFO","timestamp":"2026-03-11T08:35:48.009Z","req":{"method":"GET","url":"/health"},"res":{"statusCode":503},"err":{"type":"Error","message":"failed with status code 503","stack":"Error: failed with status code 503\n at onResFinished (C:\\Users\\Jess\\WebstormProjects\\ServiceStation\\node_modules\\pino-http\\logger.js:115:39)\n at ServerResponse.onResponseComplete (C:\\Users\\Jess\\WebstormProjects\\ServiceStation\\node_modules\\pino-http\\logger.js:178:14)\n at ServerResponse.emit (node:events:520:35)\n at onFinish (node:_http_outgoing:1026:10)\n at callback (node:internal/streams/writable:764:21)\n at afterWrite (node:internal/streams/writable:708:5)\n at afterWriteTick (node:internal/streams/writable:694:10)\n at process.processTicksAndRejections (node:internal/process/task_queues:89:21)"},"responseTime":1013,"message":"request errored"}
```
### π Graceful Shutdown
The backend application is configured to handle `SIGTERM` (sent by Docker/Kubernetes) and `SIGINT` (sent via CTRL+C) signals to ensure no data loss or interrupted requests during deployment or scaling.
* **Shutdown Process:**
1. **Signal Interception:** The app catches the termination signal.
2. **Logging:** A JSON-structured log is emitted: `"message": "SIGINT/SIGTERM received. Starting graceful shutdown..."`.
3. **Request Draining:** NestJS stops accepting new connections and finishes processing in-flight HTTP requests.
4. **Database Cleanup:** All active PostgreSQL connections are closed via Prisma's `onModuleDestroy` hook.
5. **Clean Exit:** The process exits with code 0.
**Verification Screenshot:**
