This is my first Project with React and Go. It is a simple Ticketsystem.
This ticketsystem is a simple system to manage tickets. It is written in React and Go. The Database is a PostgreSQL Database.
Ensure Docker and Docker Compose are installed on your system. Follow the installation guides:
-
Docker Compose: https://docs.docker.com/compose/install/
Start Traefik Proxy as a Docker container with the following command:
docker run -d -p 80:80 -p 8080:8080 --name traefik \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik:v3.0 \
--api.insecure=true \
--providers.docker=true \
--entrypoints.web.address=:80Copy the example environment file and edit .env in your project root:
cp .env.example .env
nano .env # or use your preferred text editor to edit .envEnsure your project directory structure is as follows:
project_root/
ββ app/
β ββββ backend/
β β ββββ Dockerfile
β β ββββ (your Go backend files)
β ββββ frontend/
β ββββ Dockerfile
β ββββ (your Next.js frontend files)
ββ .env.example
ββ docker-compose.ymlNavigate to the root directory of your project and run the following command to start the services:
docker-compose up -dThis command will build and start all the containers defined in your docker-compose.yml file in detached mode.
-
Frontend: Access the frontend application via the domain specified in
FRONTEND_DOMAIN(e.g., http://frontend.yourdomain.com). -
Backend: Access the backend application via the domain specified in
BACKEND_DOMAIN(e.g., http://backend.yourdomain.com). -
Traefik Dashboard: Access the Traefik dashboard (if enabled) at http://localhost:8080.
This setup ensures your project is configured with Docker, Docker Compose, Traefik Proxy, and environment variables, allowing for seamless development and deployment of your applications.
Ensure Node.js is installed on your system. Follow the installation guide: https://nodejs.org/en/download/
Ensure Go is installed on your system. Follow the installation guide: https://golang.org/doc/install
Ensure PostgreSQL is installed on your system. Follow the installation guide: https://www.postgresql.org/download/
Ensure your project directory structure is as follows:
project_root/
ββ app/
β ββββ backend/
β β ββββ (your Go backend files)
β ββββ frontend/
β ββββ (your React frontend files)
ββ .env.example
ββ README.adocNavigate to the root directory of your project and run the following commands to start the services:
-
Frontend: Navigate to the
frontenddirectory and run the following commands: -
Development Mode:
cd app/frontend yarn install yarn dev
-
Backend: Navigate to the
backenddirectory and run the following commands:
cd app/backend
go run main.goThis command will start the backend server.
-
Frontend: Access the frontend application via the domain specified in
FRONTEND_DOMAIN(e.g., http://localhost:3000). -
Backend: Access the backend application via the domain specified in
BACKEND_DOMAIN(e.g., http://localhost:8080).
This setup ensures your project is configured with Node.js, Go, PostgreSQL, and environment variables, allowing for seamless development and deployment of your applications.
To set up the database, run the following commands:
-
Create the database:
createdb ticketsystem
-
Run the database migrations:
cd app/backend go run main.go migrate
This will create the necessary tables in the database.
You can access the database using the following command:
psql ticketsystemThis will open the PostgreSQL command-line interface for the ticketsystem database.
If you are using NGINX or Apache, you can configure the web server to serve the frontend and backend applications.
For NGINX, you can create a configuration file in /etc/nginx/sites-available/ and symlink it to /etc/nginx/sites-enabled/.
For Apache, you can create a configuration file in /etc/apache2/sites-available/ and symlink it to /etc/apache2/sites-enabled/.
React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies.
More information about React can be found here: https://reactjs.org/
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
More information about Go can be found here: https://golang.org/
The following environment variables are used in this project:
| Name | Description | Default |
|---|---|---|
APP_ENV |
The environment in which the application is running (e.g., DEV, PROD). |
PROD |
GIN_MODE |
The mode in which the Go application is running (e.g., release, debug). |
debug |
The environment variables follow the following hierarchy:
-
β .env contains default values for the environment variables needed by the app
-
β .env.local uncommitted file with local overrides
-
β .env.$APP_ENV committed environment-specific defaults
-
β .env.$APP_ENV.local uncommitted environment-specific overrides