Getting Started
Introduction
PlazaNet is a social network inspired by Miiverse, built using Python Flask. It’s designed for creative communities, allowing users to post, draw, and interact in themed hubs.
Accounts
Installation
The PlazaNet Accounts service handles user authentication and management. Follow the steps below to set it up locally.
1. Create a working directory
mkdir plazanet && cd plazanet
2. Clone the repository
git clone https://github.com/PlazaNetOrg/Accounts accounts
cd accounts
3. Install all requirements
- Python & pip:
sudo apt install python3 python3-pip - Python dependencies:
pip install -r requirements.txt - OpenSSL (for secret key generation):
sudo apt install openssl
4. Configure environment variables
Rename the provided example configuration file:
mv .env.example .env
Then replace the placeholder values with your own. You can generate secure keys with OpenSSL:
openssl rand -base64 32
Adjust values in the .env file to customize. Below are recommended full examples for development and production (copy and adapt — do not show secrets to anyone!).
Development `.env` (local)
APP_NAME=PlazaNet
PLAZANET_ENABLE=true
PLAZANET_DOMAIN=127.0.0.1:7593
PLAZANET_ALLOWED_ORIGINS=http://127.0.0.1:7592,http://127.0.0.1:7593
SECRET_KEY=dev-secret
JWT_SECRET_KEY=dev-jwt-secret
DATABASE_URL=sqlite:///plazanet.db
FLASK_ENV=development
JWT_TOKEN_LOCATION=cookies,headers
JWT_ACCESS_COOKIE_NAME=access_token
JWT_REFRESH_COOKIE_NAME=refresh_token
JWT_COOKIE_CSRF_PROTECT=False
JWT_ACCESS_TOKEN_EXPIRES=3600
JWT_COOKIE_DOMAIN=127.0.0.1
JWT_COOKIE_SECURE=False
JWT_COOKIE_SAMESITE=Lax
Production `.env` (example)
APP_NAME=PlazaNet
PLAZANET_ENABLE=true
PLAZANET_DOMAIN=app.plazanet.org
PLAZANET_ALLOWED_ORIGINS=https://accounts.plazanet.org,https://app.plazanet.org
SECRET_KEY=GENERATE_WITH_OPENSSL
JWT_SECRET_KEY=GENERATE_WITH_OPENSSL
DATABASE_URL=sqlite:///plazanet.db
FLASK_ENV=production
JWT_TOKEN_LOCATION=cookies,headers
JWT_ACCESS_COOKIE_NAME=access_token
JWT_REFRESH_COOKIE_NAME=refresh_token
JWT_COOKIE_CSRF_PROTECT=True
JWT_ACCESS_TOKEN_EXPIRES=604800
JWT_COOKIE_DOMAIN=.plazanet.org
JWT_COOKIE_SECURE=True
JWT_COOKIE_SAMESITE=None
Notes: generate strong values for SECRET_KEY and JWT_SECRET_KEY (e.g. openssl rand -base64 32) and never commit them. If you use cross-site cookies, set JWT_COOKIE_DOMAIN to a shared domain (e.g. .plazanet.org), JWT_COOKIE_SAMESITE=None, and ensure JWT_COOKIE_SECURE=True in production. Browsers require exact origins when Access-Control-Allow-Credentials is true (do not use *).
5. Initialize the database
Run the following commands to create and migrate the database schema:
flask --app run.py db init
flask --app run.py db migrate -m "Initial migration"
flask --app run.py db upgrade
6. Start the server
python3 run.py
Once the server starts, you can access it at: http://your-ip-or-domain:7592