Skip to content

juwei-w/Express-Training-Student-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyMahir Student Management System

This is a backend-focused web application built with Express.js as part of the Agmo x MyMahir Full Stack Training (Week 1). It demonstrates the fundamentals of building a RESTful API and a Server-Side Rendered (SSR) web application using Node.js.

The project covers essential concepts including routing, middleware, database connectivity (MySQL), template rendering (EJS), and authentication flows.

Student Management System Screenshot

🚀 Features

  • Web Server: Built with Express.js to handle HTTP requests.
  • MVC Architecture: implementation of Models, Views, and Controllers (via Routes).
  • Template Engine: Dynamic HTML rendering using EJS.
  • RESTful API:
    • Student API: CRUD operations for managing students.
    • Auth API: Authentication endpoints (Register/Login) using JWT & bcrypt.
  • Database Integration: Asynchronous MySQL connection using mysql2.
  • Middleware:
    • CORS: Cross-Origin Resource Sharing configuration.
    • Method Override: Support for PUT/DELETE methods in HTML forms.
    • Body Parsing: JSON and URL-encoded data handling.
  • Demonstration Routes: Examples of GET, POST, PUT, DELETE, Query Params, and URL Params.

🛠️ Technology Stack

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MySQL
  • Templating: EJS
  • Authentication: jsonwebtoken, bcrypt
  • Utilities: dotenv (Environment Variables), nodemon (Dev Server)

📂 Project Structure

├── public/           # Static files (HTML, CSS, Images)
├── routes/           # Application routes
│   ├── api/          # API endpoints (Auth, Students)
│   ├── contact/      # Contact feature routes
│   ├── student/      # Student UI routes
│   └── blogRoutes.js # Blog post routes
├── views/            # EJS Templates
├── database.js       # Database connection configuration
├── server.js         # Main application entry point
├── package.json      # Project dependencies and scripts
└── .env              # Environment variables (not committed)

⚙️ Installation & Setup

  1. Clone the repository:

    git clone <repository-url>
    cd <project-folder>
  2. Install dependencies:

    npm install
  3. Configure Environment Variables: Create a .env file in the root directory and add your MySQL configuration:

    PORT=3000
    DB_HOST=localhost
    DB_USER=root
    DB_PASSWORD=your_password
    DB_NAME=mymahirdb
    DB_PORT=3306
    JWT_SECRET=your_jwt_secret_key

    (Note: Ensure you have a MySQL database created similar to mymahirdb)

  4. Database Setup:

    • Ensure your MySQL server is running.
    • Create the necessary tables (Students, Users, etc.) expected by the application in your database.

🏃‍♂️ Running the Application

Development Mode (with auto-reload):

npm run dev

Production Start:

npm start

Access the application at: http://localhost:3000

🔗 Key Endpoints

  • Home: GET /
  • Students (UI): GET /students
  • Blog (UI): GET /posting
  • API - Students: GET /api/students
  • API - Auth: POST /api/auth/login, POST /api/auth/register

📝 License

This project is for educational purposes as part of the Agmo x MyMahir training program.

About

Agmo x MyMahir FSTC • Express.js • Oct 2025 - Jan 2026

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published