-
Notifications
You must be signed in to change notification settings - Fork 0
(1) How to Setup
David Mang edited this page Aug 30, 2024
·
1 revision
Ensure you have the following installed on your machine:
- Node.js (v14 or higher)
- npm (v6 or higher)
- Python (v3.8 or higher)
- pip
- virtualenv
- Docker (version 20.x or later)
- Docker Compose (version 1.29.x or later)
- Clone the respository
https://github.com/ls1intum/Thaii.git
cd thaii
- Navigate to client directory
cd client
- Install dependencies:
npm install
- Start the development server:
npm run dev
The client development server should now be running at http://localhost:5173
.
- Navigate to the server directory:
cd ../server
- Create a virtual environment:
virtualenv venv
- Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
python manage.py migrate
- Create a superuser:
python manage.py createsuperuser
- Follow the prompts to set up your superuser account.
- Superusers can log in to the system without being whitlisted first.
- Superusers can access the admin panel at
http://localhost:8000/api/admin
and manage the stored data.
- Start the development server:
python manage.py runserver
The server development server should now be running at http://localhost:8000
.
Ensure you have the necessary environment variables set up for both the frontend and backend. You can create a .env
file in the root of each directory and add the required variables.
VITE_API_URL=http://localhost:8000/
VITE_ENABLE_TRACKING=true/false
-
VITE_ENABLE_TRACKING
: Enables or disables tracking of user interactions with the webapplication.
OPENAI_API_KEY=your_open_ai_key
DEBUG=True
SECRET_KEY=your_secret_key
POSTGRES_DB=your_db_name
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_HOST=your_db_host
EMAIL_USE_TLS=True
EMAIL_HOST=your_email_host
EMAIL_HOST_USER=your_email_host_user
EMAIL_HOST_PASSWORD=your_email_host_user_password
DEFAULT_FROM_EMAIL=your_default_email_host
EMAIL_PORT=587
DJANGO_SUPERUSER_USERNAME=your_django_superuser
DJANGO_SUPERUSER_PASSWORD=your_django_superuser_password
DJANGO_SUPERUSER_EMAIL=your_django_superuser_email
-
OPENAI_API_KEY
: Key for an OpenAI project to leverage the OpenAI API -
POSTGRES_DB
,POSTGRES_USER
,POSTGRES_PASSWORD
,POSTGRES_HOST
: Variables to setup and connect to a PostgreSQL database used to store the data created. The POSTGRES_HOST name is 'localhost' for the local development and 'db' when using docker to run it locally or for deloyment -
EMAIL_HOST
,EMAIL_HOST_USER
,EMAIL_HOST_PASSWORD
,DEFAULT_FROM_EMAIL
: Email configurations to send activation emails for the register flow of users -
DJANGO_SUPERUSER_USERNAME
,DJANGO_SUPERUSER_PASSWORD
,DJANGO_SUPERUSER_EMAIL
: Only important for the productive environment. When deployed a superuser with these credentials is created if it does not exist already.
When you only want to run the application locally without setting up the client and server you can use Docker.
- Prerequisites:
- Make sure you installed and run Docker on your local machine
- Make sure you created an .env file with the variables above for the server in the root directory. Set 'db' as POSTGRES_HOST.
- Build and run the containers: To build the Docker images and start the services defined in the Docker Compose file, run the following command:
docker-compose -f compose.dev.yml up --build
- Access the web application: Once the containers are up and running, you can access the web application in your browser at:
http://localhost:80
- Stopping the containers: To stop the running containers, press Ctrl + C in the terminal where Docker Compose is running, or run:
docker-compose -f compose.dev.yml down
With both the client and server running, you should be able to access the web application at http://localhost:5173 (client and server setup) or http://localhost:80 (docker setup).
- Client Build: To create a production build of the frontend, run:
npm run build
- Server Management: You can use standard Django management commands for additional backend tasks.
- Data Management: You can access the data using the admin panel at http://localhost:8000/api/admin (client and server setup) or http://localhost:80/api/admin (docker setup) with your superuser account or connect to the local database with pgAdmin.