start express react

Educational Express-React framework for intermediate developers. Complete industrial architecture with TypeScript, Docker and modern tools. Detailed progressive documentation, concrete examples and preconfigured environment. Ideal solution for teaching and learning structured fullstack development.

70
1
TypeScript

GitHub tag
License
issues - start-express-react

en-US
fr-FR

StartER

Use this template

Read the manual

This project is an educational framework, following an Express-React architecture connected to a database:

sequenceDiagram
    box Web Client
    participant React as React
    participant Fetcher as Fetcher
    end
    box Web Server
    participant Express as Express
    participant Module as Module
    end
    box DB Server
    participant DB as MySQL Server
    end

    React-)Fetcher: event
    activate Fetcher
    Fetcher-)Express: request (HTTP)
    activate Express
    Express-)Module: route
    activate Module
    Module-)DB: request (SQL)
    activate DB
    DB--)Module: data
    deactivate DB
    Module--)Express: json
    deactivate Module
    Express--)Fetcher: response (HTTP)
    deactivate Express
    Fetcher--)React: render
    deactivate Fetcher

The framework comes pre-configured with a set of tools to help junior developers produce industrial-quality code, while remaining an educational tool:

  • Express: Minimalist framework for building web servers and APIs with Node.js.
  • React: JavaScript library for building interactive and modular user interfaces.

Under the hood (in alphabetical order, non-exhaustive list):

  • Biome: All-in-one tool for linting, formatting, and static code analysis, designed to ensure code quality and readability in a powerful and modern way.
  • Docker: Containerization platform for standardizing and automating development and deployment environments, ensuring reproducible configurations.
  • MySQL: Relational database management system used to store and query data.
  • Pico CSS: Minimalist and lightweight CSS kit that prioritizes semantic syntax.
  • React Router (Data Mode): Routing manager for React applications, allowing the creation of dynamic paths and components.
  • TypeScript: JavaScript superset that adds static types, eases maintenance, and reduces errors.
  • Vite: Fast and lightweight build tool for front-end applications, with a blazing-fast development server and optimized bundles for production.
  • Vitest: JavaScript testing framework.
  • Zod: TypeScript-based schema declaration and validation library.

Installation and Usage

Complete documentation is available in our wiki.

To get started, refer to the following pages:

Things to remember

Directory structure

.
├── .env
├── .env.sample
├── compose.yaml
├── compose.prod.yaml
├── Dockerfile
├── index.html
├── server.ts
└── src
    ├── database
    │   └── schema.sql
    ├── express
    │   ├── routes.ts
    │   └── modules
    │       └── ...
    ├── react
    │   ├── routes.tsx
    │   ├── components
    │   │   └── ...
    │   └── pages
    │       └── ...
    └── types
        └── index.d.ts

Basic Commands

Command Description
docker compose up --build Build and start services (add -d to start in detached mode)
docker compose -f compose.prod.yaml up --build -d Build and start in production mode
docker compose logs -t Displays logs with timestamps
docker compose run --build --rm server npm run database:sync Synchronizes database contents with src/database/schema.sql
docker compose run --build --rm server npm run test Runs tests
npm run check Checks code quality with Biome (executed on pre-commit)
npm run check-types Checks type consistency with TypeScript (executed on pre-commit)

REST cheatsheet

Operation Method URL Path Request Body SQL Response (Success) Response (Error)
Browse GET /api/items SELECT 200 (OK), list of items.
Read GET /api/items/:id SELECT 200 (OK), one item. 404 (Not Found), if invalid id.
Add POST /api/items Item Data INSERT 201 (Created), insert id. 400 (Bad Request), if invalid body.
Edit PUT /api/items/:id Item Data UPDATE 204 (No Content). 400 (Bad Request), if invalid body. 404 (Not Found), if invalid id.
Destroy DELETE /api/items/:id DELETE 204 (No Content).