Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -88,6 +88,21 @@ jobs:
runs-on: ubuntu-latest
needs: [backend, frontend]
if: github.event_name == 'pull_request'
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: learnix
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- name: Checkout code
uses: actions/checkout@v6
Expand All @@ -113,21 +128,36 @@ jobs:
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps chromium

- name: Build frontend
run: pnpm --filter @repo/web build
- name: Build project
run: pnpm build
env:
VITE_API_URL: http://localhost:3000

- name: Start frontend preview server
run: |
cd apps/web
pnpm preview --port 5173 &
# Wait for server to be ready
npx wait-on http://localhost:5173 --timeout 30000
- name: Seed Database
run: pnpm --filter @repo/api db:seed
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_NAME: learnix
TYPEORM_SYNCHRONIZE: 'true'

- name: Run E2E tests
run: pnpm test:e2e --project=chromium
env:
CI: true
PLAYWRIGHT_BASE_URL: http://localhost:5173
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_NAME: learnix
TYPEORM_SYNCHRONIZE: 'false'
JWT_SECRET: test-secret-key-for-e2e
VITE_API_URL: http://localhost:3000
FRONTEND_URL: http://localhost:5173
NODE_ENV: production

- name: Upload Playwright report
if: always()
Expand Down
57 changes: 57 additions & 0 deletions Context/Final project Guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Submission Guidelines

Your submission is required to encompass the following components:

- Source Folder:
- Organize each project into distinct folders (e.g., front end, back end, API).
- Include comprehensive instructions detailing the deployment process for your project.
- Database Folder:
- House the database data along with the migration script for the data structure.
- Provide clear instructions on how to import the migration script.
- Reports
- Teamwork Report.pdf:
- Include a comprehensive report detailing how your team collaborated.
- Append screenshots of Git commits
- Jira Roadmap and Jira task reports as evidence (optional).
- Final Project Report.pdf:
- System Description: Provide an overview of your project.
- Team Information: Introduce your team members.
- Project Plan Tracker: Outline your project plan and progress.
- Functionalities Analysis: Describe the functionalities of your project.
- Database Design: Detail the structure and design of your database.
- UI/UX Design: Include Layout Design and Implementation details.
- Guideline: Offer instructions for web usage and deployment (both local and internet).
- Project Self-assessment Report.pdf:
- Grade each criterion based on the established scale.
- Provide evidence and proof for each self-assigned score.
- Accumulate and present the final project grade.
- Utilize a Pie chart to illustrate the contribution percentage for all team members.
- Offer a detailed breakdown of each member's contributions.
- Video Demo
- Team Introduction:
- Briefly introduce your team.
- Highlight member contributions with evidence:
- GitHub Contribution Report
- Commits
- Jira entries
- Documents
- Reports
- Project Introduction:
- Provide a concise overview of your project.
- If the project is published on a public website, demonstrate with the public website.
- Each member must showcase their contributions

Ensure all documentation is clear, organized, and follows the specified guidelines. This comprehensive submission will facilitate a thorough understanding of your project, team dynamics, and individual contributions.

# Oral defense guidelines

1. **Project Self-assessment Report**
- Complete the report, print it, and present it to the teacher during the defense.
2. **GitHub Repository & Contributors Report**
- Share your GitHub repository with the teacher.
- Highlight the Contributors section to show who worked on which tasks.
- Explain your team's collaboration process and each member's responsibilities.
3. **Project Showcase**
- Present your project to the teacher, demonstrating its features and functionality.
4. **Grade Sheet Signature**
- Sign the class grade sheet as part of the final evaluation process.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=installer --chown=nextjs:nodejs /app .
COPY --chown=nextjs:nodejs database ./database

# Install serve globally for static site serving (web)
RUN npm install -g serve
# Install serve globally for static site serving (web) and pnpm for dev scripts
RUN npm install -g serve pnpm

USER nextjs

Expand Down
166 changes: 90 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,117 +18,131 @@ Online learning platform built with React 19, NestJS 11, and Turborepo.
- **Github Repo**: <https://github.com/PhuocHoan/Learnix>
- **Vercel**: <https://learnix-teal.vercel.app>

## Structure
## Demo Accounts (Evaluator)

Use these accounts to evaluate the platform in different roles. **Password for all: `Password@123`**

| Role | Email | Features to Test |
| ---------- | ------------------------ | ----------------------------------------------------------- |
| Admin | `admin@learnix.edu` | Course moderation, user management, system stats |
| Instructor | `instructor@learnix.edu` | Create courses, manage lessons, generate AI quizzes |
| Student | `student@learnix.edu` | Enroll in courses, watch lessons, use Embedded IDE, quizzes |

## Project Structure

```text
apps/web/ # React + Vite frontend
apps/api/ # NestJS backend
e2e/ # Playwright tests
api/ # Vercel serverless adapter
├── apps/
│ ├── web/ # Frontend (React 19 + Vite)
│ └── api/ # Backend (NestJS 11)
├── database/ # Database migrations & seed data
│ ├── schema.sql # Complete PostgreSQL schema
│ ├── seed.sql # Sample data for development
│ └── README.md # Database import instructions
├── api/ # Vercel serverless adapter
├── e2e/ # End-to-end tests (Playwright)
├── docker-compose.yml # Local development containers
└── Makefile # Common development commands
```

## Quick Start
### Folder Details

### Prerequisites
| Folder | Description |
| ---------- | ----------------------------------------------------------------- |
| `apps/web` | React frontend with Vite, TailwindCSS, TanStack Query, CodeMirror |
| `apps/api` | NestJS backend with TypeORM, Passport.js, WebSockets, Gemini AI |
| `database` | PostgreSQL schema and seed data with import instructions |
| `api` | Vercel serverless function adapter for backend deployment |
| `e2e` | Playwright E2E tests for critical user flows |

- Node.js >= 24
- pnpm >= 10
- Docker (for database)
## Quick Start for Evaluators (Docker - Recommended)

### Setup
If you are a lecturer or evaluator, the easiest way to launch the **entire platform** (Frontend, Backend, and Database) is using Docker.

1. **Install Dependencies**
### Prerequisites (Docker Setup)

```bash
pnpm install
```
- Docker & Docker Compose installed

2. **Environment Variables**
Copy `.env.example` to `.env` in `apps/web` and `apps/api`.
### Launch Stack

```bash
cp apps/web/.env.example apps/web/.env
cp apps/api/.env.example apps/api/.env
```
```bash
# Start all services (PostgreSQL, NestJS API, React Frontend)
docker compose up -d --build
```

3. **Start Database**
### Initialize & Seed Database

```bash
make db
```
Wait about 10 seconds for the containers to be ready, then run:

4. **Start Development Servers**
```bash
# This reset script will apply the schema and comprehensive seed data
docker exec -it learnix-backend pnpm --filter @repo/api db:reset
docker exec -it learnix-backend pnpm --filter @repo/api db:seed
```

```bash
make dev
# Web: http://localhost:5173
# API: http://localhost:3000
```
### Access URLs

## Quality Gates & Testing
- **Frontend (Student/Instructor/Admin Portal)**: [http://localhost:5173](http://localhost:5173)
- **Backend API Documentation**: [http://localhost:3000/api](http://localhost:3000/api)

This project enforces strict quality gates. All checks must pass with zero errors and zero warnings.
---

```bash
# Run all pre-commit checks (Format, Lint, Typecheck, Unit Tests)
make pre
## Setup for Developers (Local Development)

# Run End-to-End Tests (Playwright)
make e2e
If you want to contribute to the code, use the following steps to run services locally.

# Build all packages
make build
```
### Prerequisites (Local Setup)

- Node.js >= 24, pnpm >= 10
- PostgreSQL (Local or Docker)

### Individual Commands
### Initial Setup

```bash
pnpm dev # Development mode
pnpm build # Build for production
pnpm test # Unit/Integration tests (Vitest/Jest)
pnpm test:e2e # E2E tests (Playwright)
pnpm lint # Lint (ESLint)
pnpm typecheck # TypeScript check
pnpm format # Formatter (Prettier)
pnpm install
cp apps/web/.env.example apps/web/.env
cp apps/api/.env.example apps/api/.env
```

## Deployment
### Start Database

- **Frontend**: Automatically deployed to Vercel on push to `main`.
- **Backend**: Deployed as Serverless Functions on Vercel.
- **Database**: Uses Aiven Cloud PostgreSQL.
If using the provided Docker PostgreSQL:

### Docker

To run the application with Docker Compose:
```bash
docker compose up -d postgres
# Then reset and seed (using local node)
cd apps/api
pnpm db:reset
pnpm db:seed
```

1. Ensure `.env` files are set up in `apps/web` and `apps/api`.
2. Run the compose file
### Run Development Servers

```bash
docker compose up -d --build
# From project root
pnpm dev
```

- **Frontend**: <http://localhost:5173>
- **Backend API**: <http://localhost:3000>
- **Database**: `postgres` service (internal)
- Frontend: [http://localhost:5173](http://localhost:5173)
- API: [http://localhost:3000](http://localhost:3000)

To stop:
---

```bash
docker compose down
```
## Evaluation Accounts

## Tech Stack
**Password for all: `Password@123`**

| Role | Email | Key Features |
| ---------- | ------------------------ | ----------------------------------------------------- |
| Admin | `admin@learnix.edu` | Course moderation, user management, system stats |
| Instructor | `instructor@learnix.edu` | Dashboard, course/lesson creation, AI quiz generation |
| Student | `student@learnix.edu` | Enrollment, learning viewer, embedded IDE, quizzes |

| Frontend | Backend | DevOps |
| -------------- | ----------------------- | -------------- |
| React 19 | NestJS 11 | Turborepo 2.7 |
| Vite 7 | TypeORM + PostgreSQL | GitHub Actions |
| TailwindCSS 4 | Passport.js (JWT/OAuth) | Playwright |
| TanStack Query | Gemini AI (Quizzes) | Vercel |
| CodeMirror 6 | Piston API (IDE) | Docker |
---

## Tech Stack

## License
- **Frontend**: React 19, Vite 7, TailwindCSS 4, TanStack Query, CodeMirror 6
- **Backend**: NestJS 11, TypeORM, PostgreSQL, Passport.js (JWT/OAuth), Gemini AI
- **DevOps**: Turborepo 2.7, Docker, GitHub Actions, Vercel

UNLICENSED
For detailed database details, see [database/README.md](database/README.md).
7 changes: 5 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"seed:admin": "ts-node -r tsconfig-paths/register src/scripts/create-admin.ts"
"seed:admin": "ts-node -r tsconfig-paths/register src/scripts/create-admin.ts",
"db:reset": "ts-node -r tsconfig-paths/register src/scripts/reset-db.ts",
"db:seed": "ts-node -r tsconfig-paths/register src/scripts/seed-from-sql.ts"
},
"dependencies": {
"@google/genai": "^1.34.0",
Expand Down Expand Up @@ -79,11 +81,12 @@
"eslint-plugin-import-x": "^4.16.1",
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-security": "^3.0.1",
"globals": "^16.5.0",
"globals": "^17.0.0",
"jest": "^30.2.0",
"supertest": "^7.1.4",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.51.0"
},
Expand Down
Loading
Loading