devtools
PERN Stack Backend Application with GraphQL and Apollo
Explore a backend application built with the PERN stack, featuring GraphQL API management and user authentication.
Shipped January 2026
A backend application built using the PERN stack (PostgreSQL, Express, React, Node.js) enhanced with GraphQL and Apollo Server for API management. This project serves as a foundation for building a React client to interact with a knowledge graph backend.
Features
- User authentication and authorization with JWT tokens
- GraphQL API powered by Apollo Server
- Sequelize ORM for PostgreSQL database interactions
- Real-time updates with GraphQL subscriptions
- DataLoader integration for optimized batch loading
- Logging with Winston and request logging with Morgan
- Environment-based configuration for development, testing, and production
Tech Stack
- Node.js
- Express
- PostgreSQL
- Sequelize
- GraphQL
- Apollo Server
- JWT (jsonwebtoken)
- DataLoader
- bcrypt (password hashing)
- Winston (logging)
- Mocha & Chai (testing)
Getting Started
Prerequisites
- Node.js (v10.11.0 or higher)
- PostgreSQL
- npm or yarn
Installation
git clone https://github.com/justin-napolitano/sup-court-pern-stack.git
cd sup-court-pern-stack
npm install
Environment Setup
Create a .env file in the project root with the following variables:
DATABASE_URL=postgres://username:password@localhost:5432/supreme_court
SECRET=your_jwt_secret_key
PORT=8000
NODE_ENV=development
Running the Application
npm start
The server will start on http://localhost:8000/graphql with GraphQL Playground enabled.
Running Tests
npm run test:execute-test
Project Structure
├── LICENSE
├── README.md
├── package.json
├── package-lock.json
├── src
│ ├── config
│ │ ├── db.js # Database configuration
│ │ ├── index.js # Environment config
│ │ └── logger.js # Winston logger setup
│ ├── loaders
│ │ └── user.js # DataLoader batch functions
│ ├── models
│ │ ├── index.js # Sequelize initialization
│ │ ├── user.js # User model
│ │ └── message.js # Message model
│ ├── resolvers
│ │ ├── index.js # Combined resolvers
│ │ ├── user.js # User resolvers
│ │ ├── message.js # Message resolvers
│ │ └── authorization.js# Authorization middleware
│ ├── schema
│ │ ├── index.js # Schema aggregation
│ │ ├── user.js # User GraphQL schema
│ │ └── message.js # Message GraphQL schema
│ ├── subscription
│ │ ├── index.js # PubSub setup
│ │ └── message.js # Subscription events
│ ├── tests
│ │ ├── api.js # API test utilities
│ │ └── user.spec.js # User tests
│ ├── utils
│ │ └── auth.js # JWT token helpers
│ ├── index.js # Entry point
│ ├── server.js # Express and Apollo server setup
│ └── first_start.js # (Possibly legacy or initial server start)
Future Work / Roadmap
- Add frontend React client to consume the GraphQL API
- Expand test coverage and add integration tests
- Implement role-based access control with more granular permissions
- Add support for pagination and filtering on more queries
- Enhance subscription support for real-time features
- Improve error handling and validation
- Containerize the application with Docker for easier deployment
- Add CI/CD pipeline for automated testing and deployment
Note: This project currently focuses on backend setup and API development. Frontend integration and deployment strategies are planned for future iterations.
Need more context?
Want help adapting this playbook?
Send me the constraints and I'll annotate the relevant docs, share risks I see, and outline the first sprint so the work keeps moving.