The Mars Mission CRUD App is a student project. Built with Flask, SQLite, and Docker, it provides a RESTful API and a simple UI for CRUD operations. The project includes a CI/CD pipeline (GitHub Actions) for automated testing, Docker image builds, and secure deployment.
- 📦 CRUD Operations: Manage resources via API or web UI
- 🧪 Automated Testing: Unit tests with
pytest
(86% coverage) + code quality checks withpylint
- ⚙️ CI/CD Pipeline:
- Linting, testing, and Docker image builds on every commit
- Automatic push to Docker Hub on
main
branch updates
- 🐳 Infrastructure as Code:
- Docker Compose setup (Flask + Nginx)
- Persistent SQLite database with volume mounting
- 🖥️ Simple UI: Vanilla JavaScript frontend
Prerequisites:
- Docker and Docker Compose installed
- On Windows/macOS: Install Docker Desktop.
- On Linux: Install Docker Engine and Docker Compose.
-
Clone the repository:
git clone https://github.com/xaris96/Mars-Mission.git cd Mars-Mission
-
Start the stack:
docker-compose up --build
Note: This command rebuilds the Docker image every time to ensure the latest changes are included.
To stop the stack, use:
docker-compose down
Note: This command rebuilds the Docker image every time to ensure the latest changes are included.
-
Access the application:
- Web UI:
http://localhost
(orhttp://127.0.0.1:5000
if running Flask directly) - API Endpoints:
- Get all users:
GET /api/users
- Add a user:
POST /add
- Edit a user:
POST /edit
- Delete a user:
POST /delete
- Get all users:
- Web UI:
-
Clone the repository:
git clone https://github.com/xaris96/Mars-Mission.git cd Mars-Mission
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Initialize the database:
python -c "from app import init_db; init_db()"
-
Start the server:
python app.py
-
Access the application at:
http://localhost:5000
To run the unit tests inside the Docker container:
docker-compose run app /venv/bin/pytest --cov=app
mars-mission/
├── app.py # Flask backend
├── static/ # Frontend assets
│ └── app.js # JavaScript logic
├── templates/ # HTML templates
│ └── index.html # Main UI
├── data/ # Database storage
│ └── db.sqlite3 # Main database file
│ └── db.sqlite3 # Database for testings
├── test_app.py # Tests for the Flask app
├── nginx.conf # Nginx configuration file
├── Dockerfile # Container setup
├── docker-compose.yml # Full-stack config
├── .env # Environment variables (not included in version control)
├── .env.production # Environment variables for production
├── pytest.ini # Pytest configuration file
├── requirements.txt # Python dependencies
├── .gitignore # Files and folders to ignore in Git version control
├── README.MD # Project documentation (description, setup instructions)
├── setup.py # Configuration for packaging the project as a Python package
└── .github/workflows/ # CI/CD pipelines
└── main.yml # GitHub Actions workflow
This code is provided for educational purposes only.