Skip to content

Latest commit

Β 

History

History
559 lines (405 loc) Β· 12.8 KB

File metadata and controls

559 lines (405 loc) Β· 12.8 KB

πŸ”§ ML Engineer RoadMap - Installation & Setup Guide

Complete step-by-step guide to set up the ML Engineer RoadMap web application locally.


πŸ“‹ Table of Contents


πŸ“¦ Prerequisites

Before starting, ensure you have the following installed on your system:

Required Software

  1. Node.js (v18.17.0 or higher)

  2. pnpm (v8.0.0 or higher)

    • Install globally: npm install -g pnpm
    • Check version: pnpm --version
  3. Git

Optional (for Production)

  1. PostgreSQL (v14.0 or higher) - for production database

⚑ Quick Start

For experienced developers who want to get started quickly:

# 1. Clone the repository
git clone https://github.com/Ahmet-Ruchan/ML-Engineer-RoadMap.git
cd ML-Engineer-RoadMap

# 2. Install dependencies
pnpm install

# 3. Set up environment variables
cp apps/web/.env.example apps/web/.env.local

# 4. Generate Prisma client and run migrations
cd apps/web
pnpm prisma generate
pnpm prisma migrate dev

# 5. Start the development server
pnpm dev

Open http://localhost:3000 in your browser!


πŸ“ Detailed Installation

Step 1: Clone the Repository

# Clone the repository
git clone https://github.com/Ahmet-Ruchan/ML-Engineer-RoadMap.git

# Navigate to the project directory
cd ML-Engineer-RoadMap

# Verify you're on the correct branch
git branch

Step 2: Install Dependencies

This project uses pnpm workspaces for monorepo management.

# Install all dependencies for all packages
pnpm install

This will install dependencies for:

  • apps/web - Main Next.js application
  • packages/db - Prisma database package
  • packages/ui - Shared UI components (if any)

Expected output:

Packages: +437
Progress: resolved 437, reused 437, downloaded 0, added 437, done
Done in 8.5s

Step 3: Environment Setup

Copy Environment File

# Navigate to the web app
cd apps/web

# Copy the example environment file
cp .env.example .env.local

Edit .env.local

Open apps/web/.env.local and configure the following:

# Database URL (SQLite for development)
DATABASE_URL="file:./dev.db"

# NextAuth Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-super-secret-key-change-this-in-production"

# Optional: OAuth Providers (GitHub, Google, etc.)
# GITHUB_CLIENT_ID=""
# GITHUB_CLIENT_SECRET=""
# GOOGLE_CLIENT_ID=""
# GOOGLE_CLIENT_SECRET=""

Important: Generate a secure NEXTAUTH_SECRET:

# Generate a random secret
openssl rand -base64 32

πŸ—„οΈ Database Setup

Step 1: Generate Prisma Client

# Make sure you're in apps/web directory
cd apps/web

# Generate Prisma Client
pnpm prisma generate

Step 2: Run Database Migrations

# Run migrations to create database schema
pnpm prisma migrate dev

You'll be prompted to name your migration. Example: init

Expected output:

βœ” Enter a name for the new migration: … init
Applying migration `20250116_init`

Your database is now in sync with your schema.

βœ” Generated Prisma Client

Step 3: (Optional) Seed Database

To populate your database with sample data:

# Run the seed script
pnpm prisma db seed

This will create:

  • Sample tracks (ML Engineer, Data Scientist, etc.)
  • Sample phases and topics
  • Sample resources and quizzes
  • Sample badges

Step 4: View Database (Optional)

# Open Prisma Studio to view your database
pnpm prisma studio

This opens a browser interface at http://localhost:5555


πŸš€ Running the Application

Development Mode

From the root directory of the project:

# Start all apps in development mode
pnpm dev

OR from the apps/web directory:

cd apps/web
pnpm dev

Expected output:

> @ml-roadmap/web@0.1.0 dev
> next dev

   β–² Next.js 14.0.4
   - Local:        http://localhost:3000
   - Environments: .env.local

 βœ“ Ready in 5.7s

Access the Application

Open your browser and navigate to:

Stop the Server

Press Ctrl + C in the terminal


πŸ‘€ Creating Admin User

Method 1: Using Prisma Studio (Recommended)

  1. Open Prisma Studio:

    cd apps/web
    pnpm prisma studio
  2. Navigate to the User model

  3. Click "Add record"

  4. Fill in the details:

    • email: admin@example.com
    • name: Admin User
    • password: (You need to hash it - see Method 2)
    • role: admin
    • emailVerified: (leave null)
  5. Click "Save 1 change"

Method 2: Using Registration + Manual Role Update

  1. Register a new account at http://localhost:3000/en/register

  2. Open Prisma Studio:

    pnpm prisma studio
  3. Find your user in the User table

  4. Edit the user and change role from "user" to "admin"

  5. Save changes

  6. Refresh your browser and you'll have admin access!

Method 3: Using Direct Database Query

# Open Prisma Studio
pnpm prisma studio

# Or use SQLite CLI
sqlite3 apps/web/dev.db

# Update user role
UPDATE users SET role = 'admin' WHERE email = 'youremail@example.com';

πŸ“ Project Structure

ML-Engineer-RoadMap/
β”œβ”€β”€ apps/
β”‚   └── web/                          # Main Next.js application
β”‚       β”œβ”€β”€ app/                      # Next.js 14 App Router
β”‚       β”‚   β”œβ”€β”€ [locale]/             # Internationalized routes
β”‚       β”‚   β”‚   β”œβ”€β”€ (auth)/           # Auth pages (login, register)
β”‚       β”‚   β”‚   β”œβ”€β”€ admin/            # Admin panel pages
β”‚       β”‚   β”‚   β”œβ”€β”€ roadmap/          # Public roadmap pages
β”‚       β”‚   β”‚   β”œβ”€β”€ dashboard/        # User dashboard
β”‚       β”‚   β”‚   β”œβ”€β”€ profile/          # User profile
β”‚       β”‚   β”‚   β”œβ”€β”€ badges/           # Badges page
β”‚       β”‚   β”‚   β”œβ”€β”€ bookmarks/        # Bookmarks page
β”‚       β”‚   β”‚   β”œβ”€β”€ search/           # Search page
β”‚       β”‚   β”‚   └── page.tsx          # Home page
β”‚       β”‚   └── api/                  # API routes
β”‚       β”‚       β”œβ”€β”€ auth/             # NextAuth endpoints
β”‚       β”‚       β”œβ”€β”€ admin/            # Admin CRUD APIs
β”‚       β”‚       β”œβ”€β”€ progress/         # Progress tracking
β”‚       β”‚       β”œβ”€β”€ badges/           # Badge system
β”‚       β”‚       β”œβ”€β”€ bookmarks/        # Bookmarks API
β”‚       β”‚       β”œβ”€β”€ notes/            # Notes API
β”‚       β”‚       └── search/           # Search API
β”‚       β”œβ”€β”€ components/               # React components
β”‚       β”‚   β”œβ”€β”€ ui/                   # shadcn/ui components
β”‚       β”‚   └── layout/               # Layout components (Navbar, etc.)
β”‚       β”œβ”€β”€ lib/                      # Utility functions
β”‚       β”‚   β”œβ”€β”€ auth.ts               # NextAuth configuration
β”‚       β”‚   β”œβ”€β”€ db.ts                 # Prisma client
β”‚       β”‚   └── utils.ts              # Utility functions
β”‚       β”œβ”€β”€ locales/                  # i18n translations
β”‚       β”‚   β”œβ”€β”€ en/                   # English translations
β”‚       β”‚   └── tr/                   # Turkish translations
β”‚       β”œβ”€β”€ public/                   # Static assets
β”‚       β”œβ”€β”€ .env.local                # Environment variables (create this)
β”‚       β”œβ”€β”€ .env.example              # Example environment file
β”‚       β”œβ”€β”€ next.config.js            # Next.js configuration
β”‚       β”œβ”€β”€ i18n.ts                   # i18n configuration
β”‚       └── package.json              # Dependencies
β”œβ”€β”€ packages/
β”‚   └── db/                           # Database package
β”‚       β”œβ”€β”€ prisma/
β”‚       β”‚   β”œβ”€β”€ schema.prisma         # Database schema
β”‚       β”‚   └── migrations/           # Database migrations
β”‚       └── package.json
β”œβ”€β”€ pnpm-workspace.yaml               # pnpm workspace config
β”œβ”€β”€ turbo.json                        # Turborepo config
β”œβ”€β”€ package.json                      # Root package.json
β”œβ”€β”€ README.md                         # Main README
└── INSTALLATION.md                   # This file

πŸ› οΈ Available Commands

Root Level Commands

# Install dependencies
pnpm install

# Start all apps in development
pnpm dev

# Build all apps for production
pnpm build

# Run linter
pnpm lint

# Format code
pnpm format

Web App Commands (run from apps/web/)

# Development
pnpm dev                    # Start dev server
pnpm build                  # Build for production
pnpm start                  # Start production server
pnpm lint                   # Run ESLint

# Database
pnpm prisma generate        # Generate Prisma Client
pnpm prisma migrate dev     # Run migrations (development)
pnpm prisma migrate deploy  # Run migrations (production)
pnpm prisma studio          # Open Prisma Studio
pnpm prisma db seed         # Seed database
pnpm prisma db push         # Push schema changes (prototype)

# Testing (if configured)
pnpm test                   # Run tests
pnpm test:watch             # Run tests in watch mode

πŸ› Troubleshooting

Issue: "Module not found: @radix-ui/react-slot"

Solution:

# Clean install
rm -rf node_modules apps/*/node_modules packages/*/node_modules
pnpm install

Issue: "Port 3000 is already in use"

Solution 1: Kill the process using port 3000

# macOS/Linux
lsof -ti:3000 | xargs kill -9

# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /F

Solution 2: Use a different port

PORT=3001 pnpm dev

Issue: "Prisma Client not generated"

Solution:

cd apps/web
pnpm prisma generate

Issue: "Database connection error"

Solution: Check your DATABASE_URL in .env.local

For SQLite (development):

DATABASE_URL="file:./dev.db"

For PostgreSQL (production):

DATABASE_URL="postgresql://user:password@localhost:5432/dbname"

Issue: "NextAuth session error"

Solution: Ensure NEXTAUTH_SECRET is set

# Generate a new secret
openssl rand -base64 32

# Add to .env.local
NEXTAUTH_SECRET="generated-secret-here"

Issue: "Page not loading / Event handlers error"

Solution: Ensure all pages using hooks have 'use client' directive

Example:

'use client'

import { useTranslations } from 'next-intl'

export default function MyPage() {
  const t = useTranslations()
  // ...
}

Issue: "pnpm command not found"

Solution: Install pnpm globally

npm install -g pnpm

# Or using corepack (Node.js 16.13+)
corepack enable
corepack prepare pnpm@latest --activate

Issue: Build errors after git pull

Solution:

# Clean and reinstall
pnpm install
cd apps/web
pnpm prisma generate
cd ../..
pnpm dev

πŸ”’ Security Notes

Before Deploying to Production:

  1. Change NEXTAUTH_SECRET to a strong, random value
  2. Use PostgreSQL instead of SQLite
  3. Enable HTTPS (configure NEXTAUTH_URL with https://)
  4. Set secure cookies in NextAuth configuration
  5. Review and restrict API route permissions
  6. Add rate limiting for auth endpoints
  7. Configure CORS properly
  8. Use environment variables for all secrets
  9. Never commit .env.local to git

πŸ“š Additional Resources


🀝 Getting Help

If you encounter issues not covered in this guide:

  1. Check existing issues: GitHub Issues
  2. Create a new issue: Provide detailed information about your problem
  3. Discord Community: (Coming soon)
  4. Email: aruchanavci01@gmail.com

βœ… Next Steps After Installation

  1. βœ… Application is running
  2. πŸ“ Create an admin user
  3. 🎨 Explore the admin panel
  4. πŸ“š Add content (tracks, phases, topics, resources)
  5. πŸ§ͺ Test all features
  6. 🎯 Start learning!

Happy Coding! πŸš€

Last Updated: November 16, 2025