A modern full-stack TypeScript application template with React frontend and Node.js backend. This scaffold provides a production-ready setup with Docker containerization, automated testing, and CI/CD integration.
- Express.js web framework
- PostgreSQL database with Sequelize ORM
- TypeScript for type safety
- Docker containerization
- Automated testing with Mocha and Chai
- Vite for fast development and building
- React 18 with TypeScript
- Testing with Vitest and React Testing Library
- ESLint for code quality
- Docker and Docker Compose
- Node.js 22.15.0 and npm 10.9.2 (matches the Docker images; consider using nvm to pin locally)
- PostgreSQL (if running locally without Docker)
-
Clone the repository:
git clone <repository-url> cd scaffold
-
Create environment files:
# Server environment cp server/.env.example server/.env cp server/.env.example server/.env-test # Client environment (if needed) cp client/.env.example client/.env
-
Update configuration:
- In
server/.env
, set your database and API configurations - In
src/config/config.ts
, update the production values for:BASE_URL
CLIENT_BASE_URL
GOOGLE_SIGNIN_REDIRECT_URL
- In
-
Start the development environment:
# Update docker-compose.yaml container_name entries to match your project prefix (e.g., "myapp-postgres") # or set COMPOSE_PROJECT_NAME=myapp when running docker compose to avoid container name conflicts. docker-compose up
-
(Optional) Install the formatting pre-commit hook:
./hooks/setup.sh
This hook runs Prettier inside the existing Docker containers before each commit. Make sure
docker-compose up
(ormake launch
) is running when committing changes. You can trigger the hook manually anytime with./hooks/pre-commit
while the containers are running.This will start:
- Frontend at http://localhost:3000
- Backend API at http://localhost:10020
- Background worker container running
npm run worker
- PostgreSQL database at localhost:5432
- Database migrations will run automatically
npm run dev
- Compile TypeScript in watch mode and restart the built server fromdist/
npm test
- Run the Mocha/Chai test suite (uses.env-test
)npm run lint
- Fail on ESLint warnings and ensure Prettier formatting is cleannpm run prettier:write
- Format server files with Prettiernpm run build
- Compile TypeScript and run migrationsnpm run migrate
/npm run migrate:all
- Run database migrations locally and against the test DBnpm run worker
- Execute the background worker entry point (src/worker.ts
)
npm run dev
- Start the Vite dev servernpm test
- Run Vitest with coveragenpm run lint
- Fail on ESLint warnings and check Prettier formattingnpm run prettier:write
- Format client files with Prettiernpm run build
- Build the production bundle
The Makefile
wraps common Docker tasks. Highlights:
make install
– copy.env
templates and build the Docker imagesmake launch
/make launch-detached
– start the full stack (foreground or detached)make logs
,make logs-server
,make logs-client
– follow container logsmake logs-worker
– follow the worker container logsmake test-server
,make test-client
– run tests in containersmake lint-server
,make lint-client
,make prettier-all
– enforce formatting and linting through Dockermake migrate
,make migrate-all
,make generate-migration NAME=add-table
– manage migrations
The project uses Docker Compose for development:
docker-compose up
- Start all servicesdocker-compose up server
- Start only the backenddocker-compose up client
- Start only the frontenddocker-compose up worker
- Start only the workerdocker-compose down
- Stop all services- If you customized the
container_name
placeholders, use those names when runningdocker exec
; Compose targets continue to be the service names (server
,client
,postgres
, etc.).
- Backend tests use Mocha/Chai and run in a separate test database
- Frontend tests use Vitest with React Testing Library
- Run all tests with:
docker-compose run server npm test docker-compose run client npm test
The API is documented using OpenAPI 3.0 (Swagger) specification. Documentation is available at:
/docs
- Interactive ReDoc documentation UI/swagger.json
or/api-docs
- Raw OpenAPI specification
-
Endpoint Documentation
- Each controller has its own
api.docs.yaml
file in the same directory - Example:
src/api/healthCheck/healthCheck.api.docs.yaml
documents the health check endpoint - These files contain only the path definitions without the root
paths:
element
# Example: healthCheck.api.docs.yaml /api/health: get: tags: - Health summary: Health Check # ... rest of the endpoint documentation
- Each controller has its own
-
Shared Components
- Common models, schemas, and responses are defined in YAML files in the
src/docs
directory - Example:
src/docs/models/error.yaml
for common error responses - These files can include any valid OpenAPI components (schemas, responses, parameters, etc.)
# Example: src/docs/models/error.yaml components: schemas: Error: type: object properties: message: type: string
- Common models, schemas, and responses are defined in YAML files in the
- Keep endpoint documentation close to the controller code
- Use shared components to maintain consistency across endpoints
- Use tags to group related endpoints
- Include examples in your documentation
- Document all possible responses, including errors
-
Copy the
.circleci/config.yml
file from this repo to your new repository's.circleci
directory -
Sign up for CircleCI at https://circleci.com/ and connect your GitHub repository
-
In your CircleCI project settings, add the following environment variables:
DOCKERHUB_USERNAME
,DOCKERHUB_PASSWORD
HEROKU_STAGING_APP_NAME
,HEROKU_STAGING_EMAIL
,HEROKU_STAGING_API_KEY
HEROKU_APP_NAME
Deploy jobs automatically halt if any of the required variables above are missing. CircleCI usesDOCKERHUB_USERNAME
/DOCKERHUB_PASSWORD
to authenticate before running Docker Compose builds; create a Docker Hub account (free tier is fine) and store the credentials as project-level environment variables.
-
The CircleCI configuration includes:
- Automated testing for both server and client
- Linting checks
- Automated deployment to Heroku on pushes to the
develop
branch - Promotion of the staging slug to production on pushes to
main
- Proper handling of build artifacts, migrations, and environment validation
-
The deployment pipeline:
- Builds the TypeScript code
- Runs tests
- Prepares the deployment package
- Deploys to Heroku with proper release commands
Note: Make sure your Heroku application is created and properly configured before enabling the CircleCI integration.
├── client/ # React frontend
│ ├── src/ # Source files
│ ├── tests/ # Test files
│ └── vite.config.ts # Vite configuration
├── server/ # Node.js backend
│ ├── src/ # Source files
│ ├── tests/ # Test files
│ └── migrations/ # Database migrations
├── docker/ # Docker configuration
└── .circleci/ # CI/CD configuration
- Create a feature branch from
develop
- Make your changes
- Run tests and linting
- Submit a pull request to
develop
ISC License