A backend-focused coaching platform built to demonstrate Clean Architecture, domain-driven design, REST API development, and end-to-end client-server integration.
Coach Platform is a software engineering project centered around the design of a modular NestJS backend. The project explores separation of concerns, dependency inversion, domain modeling, authentication, persistence, and API design.
The repository also includes an Ionic/Angular client to demonstrate how the backend API can be consumed by a real application.
- Clean Architecture and separation of concerns
- Domain-driven design principles
- Dependency inversion and repository abstractions
- Modular REST API development
- JWT authentication and role-based authorization
- PostgreSQL persistence with TypeORM
- Request validation and exception handling
- Swagger/OpenAPI API documentation
- Dockerized local development
- Client-server integration with Ionic/Angular
- Architectural and system-level documentation
- JWT authentication and authorization
- Role-based access control
- Account, player, coach, gym, membership, training, program, diet, exercise, rating, and transaction workflows
- REST API built with NestJS
- Domain entities and repository interfaces
- Application use cases
- TypeORM repositories
- PostgreSQL persistence
- Request validation
- File/media handling
- Swagger/OpenAPI documentation
- Health check endpoint
- Dockerized PostgreSQL development environment
- Ionic/Angular application
- Authentication flow
- Backend API integration
- Client-server communication
The backend is organized around Clean Architecture principles, with domain concepts and repository abstractions separated from infrastructure concerns.
flowchart TB
Client["Ionic / Angular Client"]
subgraph Backend["NestJS Backend"]
subgraph Presentation["Presentation"]
Controllers["Controllers"]
Guards["JWT Guards"]
DTOs["DTOs & Validation"]
end
subgraph Application["Application"]
UseCases["Application Use Cases"]
Services["Application Services"]
end
subgraph Domain["Domain"]
Entities["Entities"]
Interfaces["Repository Interfaces"]
Rules["Business Rules"]
end
subgraph Infrastructure["Infrastructure"]
Repositories["Repository Implementations"]
TypeORM["TypeORM"]
PostgreSQL[("PostgreSQL")]
JWT["JWT"]
Storage["Media Storage"]
end
Controllers --> UseCases
Guards --> Controllers
DTOs --> Controllers
UseCases --> Services
Services --> Entities
Services --> Rules
Services --> Interfaces
Interfaces -. implemented by .-> Repositories
Repositories --> TypeORM
TypeORM --> PostgreSQL
Services --> JWT
Services --> Storage
end
Client -->|HTTP / REST| Controllers
The project uses interfaces at the domain boundary and concrete implementations in infrastructure. This keeps application logic from being directly coupled to persistence and other external concerns.
The repository contains additional diagrams covering the system architecture, authentication flow, training flow, entity relationships, module dependencies, and request lifecycle.
See docs/diagrams.
The platform models several core concepts around accounts, players, coaches, gyms, memberships, training, and related data.
The main relationships can be explored in the project's Entity Relationship Diagram:
erDiagram
ACCOUNT ||--o| PLAYER : owns
ACCOUNT ||--o| COACH : owns
ACCOUNT ||--o| GYM : owns
CATEGORY ||--o{ COACH : classifies
PLAYER ||--o{ MEMBERSHIP : has
GYM ||--o{ MEMBERSHIP : offers
COACH ||--o{ ENROLLMENT : works_at
GYM ||--o{ ENROLLMENT : employs
PLAYER ||--o{ TRAINING : receives
COACH ||--o{ TRAINING : provides
TRAINING ||--o{ PROGRAM : contains
TRAINING ||--o{ DIET : contains
TRAINING ||--o{ RATING : receives
ACCOUNT ||--o{ TRANSACTION : sends
ACCOUNT ||--o{ TRANSACTION : receives
Authentication is implemented using a JWT-based login flow.
sequenceDiagram
actor User
participant Client
participant AuthController
participant AuthService
participant AccountRepository
participant PostgreSQL
User->>Client: Enter email & password
Client->>AuthController: POST /auth/login
AuthController->>AuthService: validateUser()
AuthService->>AccountRepository: findByEmail()
AccountRepository->>PostgreSQL: Query account
PostgreSQL-->>AccountRepository: Account
AccountRepository-->>AuthService: User entity
AuthService->>AuthService: Verify password
AuthService->>AuthService: Generate JWT
AuthService-->>AuthController: JWT token
AuthController-->>Client: 200 OK + token
Client-->>User: Login successful
The complete authentication diagram is available at docs/diagrams/auth-flow.md.
The backend is organized into three main areas:
backend/
└── src/
├── domain/
│ ├── adapters/
│ ├── configuration/
│ ├── entities/
│ ├── models/
│ └── repositories/
│
├── use-cases/
│ ├── account.usecases.ts
│ ├── coach.usecases.ts
│ ├── gym.usecases.ts
│ ├── membership.usecases.ts
│ ├── player.usecases.ts
│ ├── training.usecases.ts
│ └── ...
│
├── infrastructure/
│ ├── common/
│ ├── configuration/
│ ├── controllers/
│ ├── repositories/
│ ├── services/
│ └── usecases-proxy/
│
├── app.module.ts
└── main.ts
The domain layer contains the core entities and abstractions.
The use-cases layer contains application operations for the different areas of the platform.
The infrastructure layer contains framework-specific implementations such as controllers, repositories, services, configuration, and use-case proxies.
| Area | Technology |
|---|---|
| Backend | NestJS, TypeScript |
| Database | PostgreSQL |
| ORM | TypeORM |
| Authentication | JWT |
| API | REST |
| API Documentation | Swagger / OpenAPI |
| Validation | class-validator |
| Mobile | Ionic, Angular |
| Database Development | Docker |
coach-platform/
├── backend/ # NestJS backend
│ ├── env/ # Environment configuration
│ ├── src/ # Backend source code
│ ├── test/ # Tests
│ └── docker-compose.yml # PostgreSQL development service
│
├── frontend-ionic/ # Ionic / Angular client
│
├── docs/
│ └── diagrams/ # Mermaid architecture and flow diagrams
│
├── README.md
└── LICENSE
The repository includes a collection of Mermaid diagrams documenting different aspects of the system:
- System Architecture
- Clean Architecture
- Authentication Flow
- Create Training Flow
- Entity Relationship Diagram
- Module Dependencies
- Request Lifecycle
The backend can be run locally using Node.js and Docker.
- Node.js 18+
- Docker
- npm or Yarn
git clone https://github.com/yazan-orcacoder/coach-platform.git
cd coach-platform/backendnpm installThe backend includes a local environment template under backend/env.
cp env/local.env .envAdjust the values if required for your local environment.
The Docker Compose configuration starts the PostgreSQL database used by the backend.
docker compose up -dnpm run start:devThe API runs on port 9000 by default.
Swagger documentation is available at:
http://localhost:9000/swagger
The health check endpoint is available at:
http://localhost:9000/api/health
npm run testThis project is archived.
It is preserved as a portfolio and learning artifact rather than as an actively maintained product. No further feature development is planned.
The repository represents the state of the project at the end of its development. Some areas may therefore be incomplete or reflect development decisions that were made during the original implementation.
The purpose of the repository is to demonstrate the engineering and architectural approaches explored in the project, rather than to provide a production-ready coaching platform.
This project is licensed under the MIT License.