Skip to content

TATCHIwillyjunior/Node_JS_App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š User & Book Management Application

A full-stack Node.js web application for managing users and books with a SQLite database, built using Express.js for the backend and vanilla JavaScript for the frontend.
Developed as part of the EPITA Bachelor in Computer Science β€” S3, Advanced Web Development course.


✨ Features

πŸ“– Books Management

  • Browse all books with automatic 3‑second refresh
  • Full CRUD operations (Create, Read, Update, Delete)
  • Responsive card-based grid layout with hover effects

πŸ‘€ User Management

  • Manage users with full CRUD operations
  • API key authentication for /users endpoints
  • Email uniqueness validation

πŸ—„ Database

  • SQLite persistent storage
  • Automatic schema creation on startup
  • Development seed data

πŸ”Œ API

  • RESTful endpoints for books and users
  • CORS enabled for cross-origin requests
  • Comprehensive error handling

🎨 Frontend

  • Responsive design (desktop, tablet, mobile)
  • Real-time auto-refresh
  • Clean, minimal UI

πŸ›  System Requirements

Requirement Version Notes
Node.js v22.14.0+ Required
npm Latest Comes with Node.js
SQLite 3.x Usually pre-installed
OS Windows/Mac/Linux Compatible

πŸš€ Installation & Setup

1. Clone Repository

git clone https://github.com/TATCHIwillyjunior/Node_JS_App.git
cd "Node Js App"

2. Install Dependencies

npm install

Installs:

  • express (web framework)
  • cors (cross-origin support)
  • better-sqlite3 (database)
  • nodemon (development auto-reload)

3. Configure Environment

cp .env.example .env

Edit .env:

PORT=3000
NODE_ENV=development
DATABASE_URL=./database.sqlite
API_KEY=Your_Choicen_Key
JWT_SECRET=Your_Choicen_secret_key
JWT_EXPIRES_IN=24h

4. Start Backend

npm run dev

Expected output:

βœ… Server listening on http://localhost:3000
πŸ“Š Database path: ./database.sqlite
πŸ“ Seeding books...
βœ… Database initialization complete
image

5. Start Frontend

# Option A: Simple HTTP server
npx http-server public -c-1 -p 8080

# Option B: Live reload
npx live-server public --port=8080
image

6. Open Application

Visit:

http://localhost:8080

βœ… Books will auto-load after 3 seconds!


πŸ“ Project Structure

Node Js App/
β”œβ”€β”€ src/                # Backend
β”‚   β”œβ”€β”€ config/         # Env & DB setup
β”‚   β”œβ”€β”€ models/         # Book & User schemas
β”‚   β”œβ”€β”€ controllers/    # Request handlers
β”‚   β”œβ”€β”€ routes/         # API routes
β”‚   β”œβ”€β”€ middleware/     # Auth middleware
β”‚   └── index.js        # Express entry point
β”‚
β”œβ”€β”€ public/             # Frontend
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.js     # Frontend logic
β”‚   β”‚   └── api.js      # API client
β”‚   └── styles/
β”‚       └── globals.css # Styling
β”‚
β”œβ”€β”€ .env                # Local environment
β”œβ”€β”€ .env.example        # Template
β”œβ”€β”€ package.json
β”œβ”€β”€ database.sqlite     # SQLite DB
└── README.md

πŸ› οΈ Continuous Integration & Automated Dependency Updates

βš™οΈ GitHub Actions β€” CI Pipeline

This project now includes a CI workflow (.github/workflows/ci.yml) that automatically runs on:

  • Pushes to main
  • All Pull Requests

The pipeline performs:

  • Install dependencies
  • Build (if a build script exists)

This ensures every changes including Renovate updates is validated before merging

βš™οΈ πŸ€– Renovate β€” Automated Dependency Updates

Renovate is configured using the renovate.json file at the root of the project.

Key settings:

  • Timezone: Europe/Paris
  • Schedule:
  • Every Sunday at 03:00
  • Every Sunday at 18:00
  • No automerge (CI must pass first)
  • Uses config:base for standard Renovate rules

A dedicated workflow (.github/workflows/renovate.yml) runs Renovate on a schedule and can also be triggered manually.

Renovate automatically creates Pull Requests to update:

  • npm dependencies
  • devDependencies
  • minor/patch updates
  • major updates (separate PRs)

Each PR triggers the CI pipeline to ensure updates are safe.

πŸ”Œ API Documentation

Base URL

  • Development: http://localhost:3000

Books Endpoints (Public)

Method Endpoint Description
GET /books Get all books
GET /books/:id Get book by ID
POST /books Create book
PUT /books/:id Update book
DELETE /books/:id Delete book

Users Endpoints (Protected)

⚠️ Requires API Key (X-API-Key header)

Method Endpoint Description
GET /users Get all users
GET /users/:id Get user by ID
POST /users Create user
PUT /users/:id Update user
DELETE /users/:id Delete user

🎨 Frontend Features

  • Auto-load books after 3 seconds
  • Manual refresh button
  • Responsive card grid (desktop, tablet, mobile)
  • Book cards show title, author, year, genre
  • Hover effects for better UX

πŸ” Security

  • API Key protection for /users
  • Email uniqueness validation
  • Input validation for required fields

πŸ“¦ NPM Scripts

npm run dev     # Development with nodemon
npm start       # Production

🚒 Deployment (Render)

  1. Connect GitHub repo to Render
  2. Configure service:
    • Build Command: npm install
    • Start Command: node src/index.js
  3. Add environment variables in Render dashboard
  4. Deploy πŸš€

⚠️ Note: SQLite resets on redeploy. Use PostgreSQL or another persistent DB for production.


πŸ› Troubleshooting

  • No books showing? Ensure backend and frontend servers are running, DB exists, and API returns data.
  • 401 Unauthorized on /users? Check API key in .env and request headers.
  • Port in use? Kill process using port 3000 before restarting.

🀝 Contributing

  1. Fork the repo
  2. Create a feature branch
  3. Commit changes
  4. Push branch
  5. Open a Pull Request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages