icon_library is a web application based on a separated front-end and back-end architecture, designed for managing and distributing various icon resources. The system supports icon uploading, category management, search and download functions, and is suitable for unified management of icon resources within teams.
- Development Background: I developed this software using AI tools because I found it difficult to manage icons when using sun-panel (https://github.com/hslr-s/sun-panel)
The project adopts a modern separated front-end and back-end architecture:
- Back-end: RESTful API service built with Python Flask framework
- Front-end: Single-page application built with vanilla JavaScript, HTML5, and CSS3
- Data Storage: Supports multiple databases like SQLite, MySQL, PostgreSQL
- File Storage: Local file system for storing icon resources
icon_library/
├── backend/ # Back-end application
│ ├── app/ # Main application module
│ │ ├── api/ # API routing layer
│ │ ├── models/ # Data model layer
│ │ ├── services/ # Business logic layer
│ │ ├── utils/ # Utility functions
│ │ ├── middlewares/ # Middlewares
│ │ ├── config.py # Configuration file
│ │ └── __init__.py # Application initialization
│ ├── uploads/ # Upload file storage directory
│ ├── app.py # Application entry
│ ├── init_db.py # Database initialization script
│ ├── requirements.txt # Python dependencies
│ ├── .env # Environment variables
│ └── .env.example # Environment variables example
├── frontend/ # Front-end application
│ ├── public/ # Static resources
│ ├── src/ # Source code
│ │ ├── api/ # API communication module
│ │ ├── components/ # Components
│ │ ├── styles/ # CSS styles
│ │ ├── utils/ # Utility functions
│ │ └── main.js # Main script
│ ├── index.html # Entry HTML
│ └── package.json # NPM configuration
├── start.bat # Windows startup script
├── start.sh # Linux/Mac startup script
└── README.md # Project documentation
-
Complete Separation of Front-end and Back-end
- Backend provides RESTful API interfaces
- Frontend fetches data through AJAX calls
- Supports Cross-Origin Resource Sharing (CORS)
-
Modular Design
- Backend adopts MVC architectural pattern
- Layered design: API layer, service layer, data access layer
- Easy to extend and maintain
-
Complete Functionality
- Icon uploading, previewing, downloading
- Category management
- User authentication
- Responsive design
- Docker: 18.09+
- Docker Compose: 1.25+
- Ensure Docker and Docker Compose are installed
- Execute in the project root directory:
# Windows
start.bat
# Linux/Mac
chmod +x start.sh
./start.shOr directly use Docker Compose command:
docker-compose up -d- Visit http://localhost:5000
The project has optimized Docker image building with the following main features:
- Multi-stage Build: Reduces the final image size
- Domestic Mirror Source Support: Solves network connection issues
- Alpine Base Image: Lighter runtime environment
- Resource Limitations: CPU and memory usage restrictions
- Log Optimization: Limits log size and quantity
You can customize Docker configuration by modifying the following files:
Dockerfile: Container image build configurationdocker-compose.yml: Container orchestration configuration.dockerignore: Specify files to ignore during build
The project has implemented the following Docker image optimization measures:
- Using Alpine base image, reducing image size by approximately 80%
- Adopting multi-stage build to separate build and runtime environments
- Using virtual environments to isolate Python dependencies
- Removing unnecessary build dependencies
- Consolidating RUN commands to reduce image layers
- Using lightweight waitress server instead of gunicorn
Detailed optimization information can be found in the DOCKER_OPTIMIZATION.md file.
- Python: 3.7+
- Node.js: 12.x+
- Browser: Chrome, Firefox, Safari, Edge and other modern browsers
- Ensure Docker and Python are installed
- Double-click to run the
start.batscript - Access http://localhost:5000 in the browser
- Ensure Docker and Python are installed
- Set script execution permissions:
chmod +x start.sh - Run the script:
./start.sh - Access http://localhost:5000 in the browser
cd backend
# Create virtual environment (optional)
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env file, set database connection and other parameters
# Initialize database
python init_db.py
# Start backend service
python app.pycd frontend
# Install dependencies
npm install
# Start development mode
npm run dev
# Or build production version
npm run buildGET /api/icons- Get icon listGET /api/icons/:id- Get single icon informationPOST /api/icons- Upload new iconDELETE /api/icons/:id- Delete iconGET /api/icons/files/:filename- Download icon file
GET /api/categories- Get all categoriesPOST /api/categories- Create new categoryDELETE /api/categories/:id- Delete category
POST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/status- Get login status
The main configuration file is .env, which can set the following environment variables:
FLASK_APP- Flask application entryFLASK_ENV- Running environment (development/production)FLASK_DEBUG- Debug modeFLASK_HOST- Host addressFLASK_PORT- Port numberSECRET_KEY- Application secret keySQLALCHEMY_DATABASE_URI- Database connection URIICON_STORAGE_PATH- Icon storage pathMAX_CONTENT_LENGTH- Maximum upload file sizeAUTH_USERNAME- Authentication usernameAUTH_PASSWORD- Authentication password
Frontend configuration is mainly in src/api/api.js:
API_BASE_URL- Backend API base URLICON_BASE_URL- Icon file base URL
- Create new API routes: Create new routing modules in the
app/api/directory - Add business logic: Implement business functions in the
app/services/directory - Define data models: Create model classes in the
app/models/directory - Add utility functions: Add helper functions in the
app/utils/directory
- Create components: Organize UI components in the
src/components/directory - Add styles: Write CSS styles in the
src/styles/directory - API calls: Use the global
apiobject for backend communication - State management: Use the
appStateobject inmain.jsto manage application state
- In production environments, default authentication information in the
.envfile must be changed - HTTPS protocol is recommended for production environments
- Consider using more secure authentication mechanisms instead of simple authentication
- Reasonably set file upload size limits to prevent DoS attacks
- Strictly validate the type and content of uploaded files
This project is licensed under the MIT License. See the LICENSE file for details.
- 实现图标删除功能
- 基于登录状态隐藏编辑区域按钮
- 实现图片在不同分类间转移功能
- 优化用户界面体验
- Optimized Docker image configuration, reduced image size
- Added multi-stage build and domestic mirror source support
- Improved containerized deployment solution
- Added resource limitations and log optimization
- Created
.dockerignoreand.gitignorefiles
- Refactored to separated front-end and back-end architecture
- Adopted modular design to improve code maintainability
- Optimized API design to support more functions
- Added responsive frontend interface
- Provided one-click startup script
- Initial project version
- Basic icon management functionality