A full-stack user registration and authentication application built with React frontend and Python FastAPI backend.
- Technology: FastAPI with Python 3.9
- Port: 8000 (mapped to 9091 externally)
- Authentication: JWT token-based authentication
- Password Security: bcrypt hashing
- CORS: Enabled for frontend communication
- Technology: React 18 with Material-UI
- Port: 3000 (mapped to 9090 externally)
- State Management: React Context API
- Routing: React Router DOM
- UI Framework: Material-UI (MUI)
- Technology: PostgreSQL 13
- Port: 5432 (mapped to 9092 externally)
- Status: Configured but backend currently uses in-memory storage
POST /api/register- User registrationPOST /api/token- User login (OAuth2)GET /api/users/me- Get current user info (protected)GET /api/health- Health check
- Login Page - User authentication
- Registration Page - New user signup
- Dashboard - Protected user dashboard
- Auth Context - Authentication state management
- Docker and Docker Compose
- Node.js 18+ (for local development)
- Python 3.9+ (for local development)
-
Clone the repository
git clone https://github.com/emanet1/registration-app.git cd registration-app -
Create environment file
# Create .env file in the root directory echo "JWT_SECRET_KEY=your-secret-key-here" > .env
-
Build and run with Docker Compose
docker-compose up --build
-
Access the application
- Frontend: http://localhost:9090
- Backend API: http://localhost:9091
- Database: localhost:9092
cd backend
pip install -r requirements.txt
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reloadhttp://localhost:8000/docs
http://localhost:8000/api/health
cd frontend
npm install
# Set environment variable
export REACT_APP_API_URL=http://localhost:8000
npm startCreate a .env file in the root directory:
# JWT Secret Key for token signing
JWT_SECRET_KEY=your-secret-key-here
# Database Configuration (if using real database)
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=magaxThe frontend expects the following environment variable:
REACT_APP_API_URL- Backend API URL (default: http://localhost:9091)
docker build -t reg-backend .
docker build -t reg-frontend-single:latest --build-arg REACT_APP_API_URL=http://localhost:8000 .
docker build --build-arg REACT_APP_API_URL=http://localhost:8000 -t frontend .
docker run -d --name reg-backend -p 8000:8000 reg-backend
docker run -d --name reg-frontend -p 3000:3000 frontend:latest
docker exec -it reg-frontend sh
docker exec -it reg-backend sh
In Docker, a volume is a persistent storage mechanism for containers. By default, any data created inside a container is ephemeralβit disappears when the container stops or is removed. Volumes solve this problem by providing:
Persistence: Data survives container restarts or removals.
Sharing: Multiple containers can access the same data.
Separation of concerns: Keeps container filesystem clean while storing data outside.
Volumes are stored on the host filesystem but managed by Docker.
Volumes β Recommended. Managed by Docker, easy to back up and share.
Bind mounts β Directly map host directory to container. Gives more control but less portable.
Tmpfs mounts β Stored in host RAM, non-persistent.
Weβll focus on volumes & Bing Mounts
docker volume create backend_data
docker volume ls
Persist files at /data inside reg-backend:
docker rm -f reg-backend
docker run -d --name reg-backend -p 8000:8000 -v backend_data:/data reg-backend
!!! Anything written to /data will survive container removal.
docker exec -it reg-backend sh -c "echo hello > /data/hello.txt && ls -l /data"
docker rm -f reg-backend
docker run -d --name reg-backend -p 8000:8000 -v backend_data:/data reg-backend
docker exec -it reg-backend sh -c "cat /data/hello.txt"
##Bind mount (live-edit) your backend code Mount your local backend folder into the container:
docker rm -f reg-backend
MSYS_NO_PATHCONV=1 docker run -d --name reg-backend -p 8000:8000 \
-v "C:/Users/user/Documents/Organization/DIGITAL-WITCH/DOCKER/practical-class/registration-app/backend:/app" \
reg-backend
docker exec -it reg-backend sh -c 'echo hi > /app/test.txt'
registration-app/
βββ backend/
β βββ main.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend Docker configuration
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Login.js # Login component
β β β βββ Register.js # Registration component
β β β βββ Dashboard.js # Dashboard component
β β βββ contexts/
β β β βββ AuthContext.js # Authentication context
β β βββ App.js # Main App component
β β βββ index.js # Entry point
β βββ package.json # Frontend dependencies
β βββ Dockerfile # Frontend Docker configuration
β βββ nginx.conf # Nginx configuration
βββ docker-compose.yml # Docker services configuration
βββ README.md # This file
- Registration: User creates account with username, email, and password
- Login: User authenticates with username/password
- Token: Backend returns JWT token
- Storage: Frontend stores token in localStorage
- Protected Routes: Token used for API calls and route protection
| Service | Port | Description |
|---|---|---|
| frontend | 9090 | React application |
| backend | 9091 | FastAPI application |
| db | 9092 | PostgreSQL database |
- In-Memory Storage: Backend currently uses in-memory storage instead of PostgreSQL
- No Database Persistence: User data is lost on server restart
- Missing Environment Setup: .env file needs to be created manually
# Run with auto-reload
uvicorn main:app --reload
# Run with specific host/port
uvicorn main:app --host 0.0.0.0 --port 8000# Start development server
npm start
# Build for production
npm run build
# Run tests
npm test# Build and start all services
docker-compose up --build
# Start in background
docker-compose up -d
# Stop all services
docker-compose down
# View logs
docker-compose logs -f# Health check
curl http://localhost:9091/api/health
# Register user
curl -X POST http://localhost:9091/api/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@example.com","password":"testpass"}'
# Login
curl -X POST http://localhost:9091/api/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=testuser&password=testpass"visit https://github.com/docker/awesome-compose
Once the backend is running, you can access the interactive API documentation at:
- Swagger UI: http://localhost:9091/docs
- ReDoc: http://localhost:9091/redoc
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For support and questions, please open an issue in the repository or contact the development team.

