Skip to content

Alwurts/chemnitz-maps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chemnitz Maps

Submitted as requirement for the class, Datenbanken und Web-Techniken

Running the client

The client is a TypeScript application created with React and Vite. To run the client, you need to have Node.js 18 or higher installed on your machine.

To run this project you need to setup a Google Maps API key, which in this case is already included in the .env file.

For this project the .env file is already included in the client folder with the following variables:

VITE_MAPS_API_KEY=google_maps_api_key
VITE_API_URL=server_url

To run the client, you need to install the dependencies and run the development server:

cd client
npm install
npm run dev

After running the command, the client will be available at http://localhost:3000.

Exposing the application to the network is useful when you want to access the application from a different device, like a smartphone or tablet.

If you want to expose the application to the network, you can run the following command instead:

npm run dev-host

You will also need to update the server url in the client .env file to the IP address of the machine running the server.

VITE_SERVER_URL=http://your-server-ip:8000

After running the command, the client will be available at http://your-local-ip:5173.

Note: If the client is using dev-host then the server should be using the python manage.py runserver 0.0.0.0:8000 command to be able to access the API from the client.

Running the server

The server is a Django application that provides a REST API. To run the server, you need to have Python 3.12 and pipenv installed on your machine.

First create a pipenv environment and install the dependencies:

cd server
pipenv install
pipenv shell

Then run the server:

python manage.py runserver

If you want to expose the server to the network, you can run the following command instead:

python manage.py runserver 0.0.0.0:8000

Note: If the server is exposed to the network, the client should be using the npm run dev-host command to be able to access the API from the client.

Running the database

The Django project comes with a SQLite database which is located at server/db.sqlite3. The included db.sqlite3 already contains the required migrations and data.

There are 3 users in the database, their login details are as follows:

  • Admin: Has access to the Django admin panel
    {
      "username": "admin",
      "password": "admin"
    }
  • Basic user: User account of type basic
    {
      "username": "user-basic",
      "password": "user-basic"
    }
  • Premium user: User account of type premium
    {
      "username": "user-premium",
      "password": "user-premium"
    }

Creating a new database

If you want to start with a fresh database, you can delete the db.sqlite3 file and run the following commands:

# Create the database
python manage.py runserver
# Apply the migrations
python manage.py migrate
# Create a superuser
python manage.py createsuperuser

After the migrations are applied we can seed the database with the data from the Chemnitz City open data portal, run the following command to do so:

python manage.py import_chemnitz_data

This command can also be used whenever you want to update the database with the data coming from the Chemnitz City open data portal.

Endpoint list

Run the server and visit http://localhost:8000/docs to see the API documentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors