A simple user registration website built with Flask, PostgreSQL, and Redis.
- User registration with email and name
- Email validation and uniqueness checking
- Redis caching for improved performance
- PostgreSQL database for persistent storage
- Modern, responsive UI
- Docker support for easy deployment
- Python 3.8+
- Docker and Docker Compose
- PostgreSQL 15
- Redis 7
-
Clone the repository
git clone <repository-url> cd register-demo-app
-
Start the services
docker-compose up --build
-
Access the application
- Web app: http://localhost:5000
- PostgreSQL: localhost:5432
- Redis: localhost:6379
-
Install Python dependencies
pip install -r requirements.txt
-
Set up environment variables
cp env.example .env # Edit .env with your local database credentials -
Start PostgreSQL and Redis
# Using Docker for services only docker-compose up postgres redis -d -
Run the Flask application
python app.py
GET /- Homepage with registration formPOST /register- Register a new userGET /users- Get all registered usersGET /health- Health check for database and Redis connections
CREATE TABLE users (
email VARCHAR(120) PRIMARY KEY,
name VARCHAR(100) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);The application uses Redis to cache user data temporarily before writing to the database:
- Cache key format:
user:{email} - TTL: 5 minutes
- Prevents duplicate registrations during high concurrency
register-demo-app/
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker services orchestration
├── templates/ # HTML templates
│ └── index.html # Homepage template
├── env.example # Environment variables template
└── README.md # This file
FLASK_ENV: Flask environment (development/production)DATABASE_URL: PostgreSQL connection stringREDIS_HOST: Redis server hostnameREDIS_PORT: Redis server portSECRET_KEY: Flask secret key for sessions
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
# The sonar token is mock up and can not be used
export SONAR_TOKEN=sqp_d6ae6bbe4b48ea29f573459462b90565e02dc123
pysonar \
--sonar-host-url=https://sonarqube-enterprise.demo.opsta.co.th \
--sonar-project-key=opsta_register-demo-app_36ebe093-bcc0-4164-8375-4ed6dd2a6aa3