This project shows how to use the stack tool to build and deploy a simple Todo List application built with React for the frontend and Node.js for the backend, using PostgreSQL as the database. It was AI generated using GitHub Copilot.
todo-list-app
├── backend # Backend application
│ ├── src # Source files for the backend
│ ├── package.json # Backend dependencies and scripts
│ ├── tsconfig.json # TypeScript configuration for the backend
│ └── README.md # Documentation for the backend
├── frontend # Frontend application
│ ├── src # Source files for the frontend
│ ├── package.json # Frontend dependencies and scripts
│ ├── tsconfig.json # TypeScript configuration for the frontend
│ └── README.md # Documentation for the frontend
├── composefile.yml # Stack/Docker configuration for the application
└── README.md # Main documentation for the project
This diagram was auto-generated with the stack chart command:
flowchart RL
todo-backend-http>:5000]:::http_target
todo-frontend-http>:3000]:::http_target
todo-backend-http --> todo-backend
todo-frontend-http --> todo-frontend
subgraph todo [todo]
todo-backend[[backend]]:::http_service
todo-frontend[[frontend]]:::http_service
todo-db[[db]]:::service
todo-db-volume-db-data:/var/lib/postgresql/data(db-data:/var/lib/postgresql/data):::volume
todo-db --> todo-db-volume-db-data:/var/lib/postgresql/data
end
classDef super_stack stroke:#FFF176,fill:#FFFEEF,color:#6B5E13,stroke-width:2px,font-size:small;
classDef stack stroke:#00C9A7,fill:#EDFDFB,color:#1A3A38,stroke-width:2px,font-size:small;
classDef service stroke:#43E97B,fill:#F5FFF7,color:#236247,stroke-width:2px;
classDef http_service stroke:#FFB236,fill:#FFFAF4,color:#7A5800,stroke-width:2px;
classDef http_target stroke:#FF6363,fill:#FFF5F5,color:#7C2323,stroke-width:2px;
classDef port stroke:#26C6DA,fill:#E6FAFB,color:#074953,stroke-width:2px,font-size:x-small;
classDef volume stroke:#A259DF,fill:#F4EEFB,color:#320963,stroke-width:2px,font-size:x-small;
class todo stack;
- Node.js
- PostgreSQL
- Docker (optional, for running with Docker)
-
Navigate to the
backenddirectory:cd backend -
Install dependencies:
npm install -
Set up the PostgreSQL database and update the connection settings in
backend/src/database/index.ts. -
Start the backend server:
npm start
-
Navigate to the
frontenddirectory:cd frontend -
Install dependencies:
npm install -
Start the frontend application:
npm start
To download, build, configure, and deploy the application using stack, run:
# clone
stack fetch repo bozemanpass/example-todo-list
# build
stack prepare --stack todo
# configure
stack init --stack todo --output todo.yml --map-ports-to-host localhost-same
# deploy
stack deploy --spec-file todo.yml --deployment-dir ~/deployments/todo
# run
stack manage --dir ~/deployments/todo start
To run the application using Docker, you can use the provided composefile.yml file. Simply run:
docker compose -f composefile.yml up --build
This will start both the backend and PostgreSQL database in separate containers.
The backend provides the following API endpoints for managing todos:
GET /todos- Retrieve all todosPOST /todos- Create a new todoPUT /todos/:id- Update an existing todoDELETE /todos/:id- Delete a todo
This project is licensed under the MIT License.