aboutsummaryrefslogtreecommitdiff
path: root/readme_en.md
blob: 3ae3d3f4a40605bc9f19a286b585669e6f8697a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# PO connect-4

<div style="text-align: center;"><img src="./banner.png"/></div>

## This is a school project using Python and SQL

Note to English spreakers: most of this project is in Dutch (commit messages, documents etc.). I'll try to maintain this after the assignment deadline because I think this is a pretty cool project, and I'll be fixing issues/merging pr's after the deadline aswell. I think the deadline is ~January 25th~ sometime in March? though I'm not sure about this.

## Things that we'd like to have working:

- Working connect 4 game
- Client-server connection with socket.io
- Account creation
- Anonymous accounts / invite links
- Safe password authentication
- Play against the computer
- Rest API that handles all of this instead of some janky solution

## Maybe:

- ~Log in with google / apple / other~
- Messages
- Follow people/add as friend
- Multiple game modes
- Game rating like on chess.com
- Different themes (minimalist or skeumorphic with realistic bouncing animation)

## Used libraries:

- [Flask](https://flask.palletsprojects.com/) for the http server and REST API
- [ReactJS](https://reactjs.org/) to create the website
- [NextJS](https://nextjs.org/) for static page routing
- [socket.io](https://socket.io/) for bidirecitonal communication during a game
- [SQLite](https://sqlite.org/index.html) for the database

An example database can be found on [Google Docs](https://docs.google.com/spreadsheets/d/1mDN9IUqRIMjr_9RmLxKybjIgVuaUadalmPEFnG-XeJg/edit?usp=sharing) along with the API endpoints, and the website prototypes can be found on [Figma](https://www.figma.com/file/rTciVQApAe6cwrH1Prl5Wn/4-op-een-rij?node-id=0%3A1)

## How to set up

0. `git clone https://github.com/lonkaars/po-4-op-een-rij`
1. Make sure you have [python](https://python.org/downloads) installed.
2. Make sure you have [nodejs](https://nodejs.org/en/download) installed.
3. Install typescript, react-scripts and yarn:
	```sh
	npm i -g typescript yarn react-scripts
	```
4. Create a new python virtual environment and install pip modules:
	```sh
	python -m venv venv
	
	# activate virtual environment (see next section)

	pip install -r requirements.txt
	```
5. Install node modules:
	```sh
	yarn
	```

## How to activate Python virtual environment

### Windows (cmd)

```
.\venv\Scripts\activate.bat
```

### Windows (powershell)

```
.\venv\Scripts\Activate.ps1
```

### Windows (git bash)

```
source venv/Scripts/activate
```

### Linux (bash/zsh/sh)

```
source venv/bin/activate
```

If you did this step correctly you should see `(venv)` prefixed to your prompt.

## How to start

In order to start this project you'll need three terminal windows to start the flask server, react server, and nginx seperately:

```sh
# term 1

# activate virtual environment

python3 api/main.py

# term 2

yarn dev

# term 3

sudo nginx -c $PWD/nginx.conf # this only works on unix (i'm going to test on windows later)
```

## How to test API endpoints
```sh
# If you're running the standalone flask server:
curl http://localhost:5000/<endpoint>

# If you're running flask and nginx at the same time:
curl http://localhost:2080/api/<endpoint>
```