Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Project Architecture

## Overview

This is a React-based developer tools web application built with TypeScript. The application provides various utility tools including timestamp conversion, timers, text comparison, JSON formatting, encoding/decoding, encryption, QR code generation, and IP address lookup.

## Technology Stack

- **Frontend Framework**: React with TypeScript
- **Routing**: React Router v6
- **UI Components**: Ant Design (antd)
- **Build Tool**: Create React App
- **Deployment**: GitHub Pages

## Project Structure

```
.
├── public/ # Static assets
├── src/ # Source code
│ ├── components/ # Reusable UI components
│ │ └── tools/ # Individual tool components
│ ├── pages/ # Page-level components
│ ├── router/ # Routing configuration
│ └── App.tsx # Main application component
├── docs/ # Documentation
└── package.json # Project dependencies and scripts
```

## Key Components

### 1. Routing (src/router/Router.tsx)

The application uses React Router v6 for client-side routing. The main routes include:

- `/` and `/home` - Homepage
- `/tools/*` - Tools layout with nested routes for individual tools:
- `/tools/timestamp` - Timestamp converter
- `/tools/timer` - Timer utility
- `/tools/textdiff` - Text comparison tool
- `/tools/json` - JSON formatting tool
- `/tools/encoder_decoder` - Encoding/decoding utilities
- `/tools/encryption` - Encryption/decryption utilities
- `/tools/qrcode` - QR code generator
- `/tools/ipaddress` - IP address lookup
- `/tools/cron` - Cron expression parser and scheduler

### 2. Tools Layout (src/pages/ToolsLayout.tsx)

The ToolsLayout component serves as the main layout for all tool pages with:

- A horizontal navigation menu with tab items for each tool
- Dynamic tab selection based on the current URL path
- Content area that renders the active tool component via `<Outlet />`

Key features:
- Uses `useLocation` hook to track URL changes
- Implements `useState` and `useEffect` to dynamically update the selected tab
- Automatically activates the corresponding tab based on the URL path

### 3. Individual Tool Components

Each tool is implemented as a standalone component in the `src/components/tools/` directory:

- **TimestampPanel** - Time conversion utilities
- **TimerPanel** - Countdown and stopwatch functionality
- **TextDiffTool** - Text comparison with visual highlighting
- **JsonTools** - JSON formatting and validation
- **EncoderDecoderTabs** - Multiple encoding/decoding formats
- **EncryptionTabs** - Various encryption/decryption algorithms
- **QRCodeGenerator** - QR code generation from text input
- **IPAddressView** - IP address information lookup
- **CronTool** - Cron expression parsing and schedule prediction

## Data Flow

1. User navigates to a URL (e.g., `/tools/json`)
2. React Router matches the route and renders the `ToolsLayout` component
3. `ToolsLayout` determines the active tab based on the URL path
4. The corresponding tool component is rendered in the content area via `<Outlet />`
5. User interacts with the tool, which manages its own state and UI

## GitHub Pages Deployment

The application is configured for deployment to GitHub Pages with special handling in `public/index.html` to support client-side routing:

- Includes a script to handle redirects for single-page applications
- Uses the `spa-github-pages` approach to ensure proper routing

## State Management

- Each tool component manages its own local state using React hooks
- The ToolsLayout component manages the active tab state
- No external state management library is used (e.g., Redux, Zustand)

## Styling

- Primarily uses Ant Design components for UI
- Custom CSS is minimal and located in `src/App.css`
- Responsive design through Ant Design's built-in responsive features

## Build Process

- Uses Create React App's default build process
- Optimizes assets for production deployment
- Outputs to the `build/` directory
200 changes: 200 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,207 @@
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

/* Bright Homepage Styles */
.bright-homepage {
min-height: 100vh;
background-color: #f0f2f5;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.bright-header {
display: flex;
align-items: center;
padding: 0 24px;
background-color: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
position: sticky;
top: 0;
z-index: 100;
}

.logo {
margin-right: 24px;
}

.nav-icons {
display: flex;
align-items: center;
}

.nav-icon-button {
font-size: 18px;
margin-left: 12px;
color: #1890ff;
}

.nav-icon-button:hover {
color: #40a9ff;
}

.bright-content {
padding: 24px;
max-width: 1200px;
margin: 0 auto;
width: 100%;
}

/* Terminal Styles */
.terminal-container {
background-color: #1e1e1e;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
margin: 24px 0;
overflow: hidden;
font-family: 'Courier New', monospace;
}

.terminal-header {
background-color: #333;
padding: 8px 12px;
display: flex;
align-items: center;
}

.terminal-dots {
display: flex;
margin-right: 12px;
}

.dot {
width: 12px;
height: 12px;
border-radius: 50%;
margin-right: 6px;
}

.dot.red {
background-color: #ff5f56;
}

.dot.yellow {
background-color: #ffbd2e;
}

.dot.green {
background-color: #27c93f;
}

.terminal-title {
color: #aaa;
font-size: 14px;
flex: 1;
text-align: center;
}

.terminal-body {
padding: 20px;
color: #ccc;
line-height: 1.5;
font-size: 16px;
text-align: left;
min-height: 400px;
}

.terminal-line {
margin-bottom: 12px;
display: flex;
align-items: baseline;
justify-content: flex-start;
}

.prompt {
color: #4caf50;
font-size: 16px;
margin-right: 12px;
white-space: nowrap;
flex-shrink: 0;
}

.command {
color: #fff;
font-size: 16px;
}

.terminal-response {
color: #ccc;
margin: 0 0 16px 0;
text-align: left;
}

.terminal-response p {
margin: 8px 0;
font-size: 16px;
}

.cursor {
color: #fff;
animation: blink 1s infinite;
display: inline-block;
width: 8px;
height: 16px;
background-color: #fff;
vertical-align: middle;
margin-left: 2px;
}

@keyframes blink {

0%,
100% {
opacity: 1;
}

50% {
opacity: 0;
}
}

/* Contact Section */
.contact-section {
margin: 48px 0;
}

.contact-buttons {
display: flex;
justify-content: center;
margin-top: 24px;
}

.contact-button {
background-color: #fff;
border: 1px solid #d9d9d9;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: all 0.3s;
}

.contact-button:hover {
transform: translateY(-4px);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
border-color: #1890ff;
}

.contact-button .anticon {
margin-right: 8px;
}

/* Footer */
.bright-footer {
background-color: #fff;
border-top: 1px solid #d9d9d9;
padding: 24px 0;
text-align: center;
margin-top: 48px;
}

.footer-content {
max-width: 1200px;
margin: 0 auto;
padding: 0 24px;
}
Loading
Loading