Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Coach Platform

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.

What the Project Demonstrates

  • 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

Features

Backend

  • 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

Mobile Client

  • Ionic/Angular application
  • Authentication flow
  • Backend API integration
  • Client-server communication

Architecture

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
Loading

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.

Domain Model

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:

docs/diagrams/erd.md

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
Loading

Authentication Flow

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
Loading

The complete authentication diagram is available at docs/diagrams/auth-flow.md.

Backend Structure

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.

Technology Stack

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

Repository Structure

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

Documentation

The repository includes a collection of Mermaid diagrams documenting different aspects of the system:

Getting Started

The backend can be run locally using Node.js and Docker.

Prerequisites

  • Node.js 18+
  • Docker
  • npm or Yarn

Clone the repository

git clone https://github.com/yazan-orcacoder/coach-platform.git
cd coach-platform/backend

Install dependencies

npm install

Configure the environment

The backend includes a local environment template under backend/env.

cp env/local.env .env

Adjust the values if required for your local environment.

Start PostgreSQL

The Docker Compose configuration starts the PostgreSQL database used by the backend.

docker compose up -d

Run the backend

npm run start:dev

The 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

Run tests

npm run test

Project Status

This 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.

License

This project is licensed under the MIT License.

About

Software-engineered coaching platform demonstrating scalable backend architecture, domain-driven design, Docker, PostgreSQL, and REST APIs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages