Skip to content

Commit d52d29d

Browse files
committed
docs(gemini): updated GEMINI.md
1 parent 02dc30a commit d52d29d

1 file changed

Lines changed: 65 additions & 58 deletions

File tree

GEMINI.md

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,83 @@
1-
# Project Context: MyWebserver (CLI IM System)
2-
3-
## Overview
4-
This project is a high-performance **CLI Instant Messaging (IM) System** written in **C++20**, evolving from a web server foundation. It utilizes a Reactor pattern with **Linux Epoll** for networking, **Google Protobuf** for data serialization, and relies on **MySQL** and **ScyllaDB** for data persistence.
1+
# MyWebserver (CLI IM System) Context
2+
3+
## Project Overview
4+
This project is a high-performance C++ application evolving from a WebServer into a **CLI Instant Messaging (IM) System**. It utilizes modern C++20 standards, a Reactor-based networking model, and Google Protobuf for efficient binary communication. The system features a server backend and a terminal-based client user interface.
5+
6+
## Key Technologies
7+
* **Language:** C++20
8+
* **Build System:** CMake (with Presets), Vcpkg (Dependency Management)
9+
* **Networking:** Linux Epoll (Reactor Pattern), Non-blocking I/O
10+
* **Protocol:** Google Protobuf
11+
* **Database:**
12+
* **New:** ScyllaDB (via `cpp-rs-driver`) - *Current focus*
13+
* **Legacy/Transition:** MySQL (via `sqlpp11`)
14+
* **Client UI:** FTXUI (Functional Terminal User Interface)
15+
* **Other Libs:** `jwt-cpp` (Authentication), `nlohmann-json`, `spdlog` (format supported in custom logger)
16+
* **Containerization:** Docker, DevContainer support
517

618
## Architecture
7-
- **Language**: C++20
8-
- **Network Model**: Linux Epoll (Reactor Pattern)
9-
- **Serialization**: Google Protobuf
10-
- **Database**:
11-
- **MySQL**: User data, auth (port 3306)
12-
- **ScyllaDB**: Message storage (port 9042)
13-
- **Client UI**: FTXUI (Terminal-based UI)
14-
- **Build System**: CMake (Presets enabled) + Vcpkg
15-
- **Orchestration**: Docker Compose (DevContainer)
19+
### Server (`server/src/`)
20+
* **Core:** Custom `Webserver` class utilizing `Epoller` for event handling.
21+
* **Concurrency:** Thread Pool for task execution and connection handling.
22+
* **Storage:** DAO layer abstracting database access (`msg_scylla_dao`, `friend_dao`, etc.).
23+
* **Service Layer:** Business logic separated into services (`AuthService`, `FriendService`, `MsgService`, `PushService`).
24+
* **Logging:** Custom asynchronous logging system.
25+
26+
### Client (`client/`)
27+
* **UI:** Terminal-based UI built with **FTXUI**.
28+
* **Structure:** Network manager handles communication; UI components (`home_page`, `auth_page`, etc.) manage display and user input.
29+
30+
### Protocol (`proto/`)
31+
* Defines message structures and service contracts using `.proto` files.
32+
* CMake automatically generates C++ code from these definitions.
1633

1734
## Directory Structure
18-
- `server/src/`: Core server logic (Reactor, ThreadPool, Database logic).
19-
- `main.cpp`: Entry point. Initializes `Webserver` on port 1316.
20-
- `client/`: CLI client application using FTXUI.
21-
- `main.cpp`: Entry point. Manages UI pages (Auth, Register, Main).
22-
- `proto/`: Protobuf definition files (`.proto`).
23-
- `tests/`: Python integration tests (`test_auth.py`, `test_friend.py`).
24-
- `.devcontainer/`: Development environment configuration (Dockerfile, docker-compose).
25-
- `sql/`: Database schema definitions.
35+
* `server/src/`: Core server source code.
36+
* `client/`: Client application source code.
37+
* `proto/`: Protobuf definition files.
38+
* `tests/`: Python functional tests and C++ unit tests.
39+
* `sql/`: Database schema definitions.
40+
* `vcpkg.json`: Project dependencies.
41+
* `docker-compose.yml`: Deployment configuration.
2642

2743
## Build & Run
2844

29-
### 1. Build
30-
The project uses **CMake Presets** (`debug`, `release`).
45+
**Prerequisites:**
46+
The project is best developed using the provided **DevContainer** (requires Docker & VS Code). Alternatively, ensure `cmake`, `vcpkg`, `clang`, and necessary DB drivers are installed.
3147

32-
**Debug Build:**
48+
**Build Commands (inside DevContainer or configured env):**
3349
```bash
50+
# Configure (Release or Debug)
51+
cmake --preset release
52+
# OR
3453
cmake --preset debug
35-
cmake --build build/debug
36-
```
3754

38-
**Release Build:**
39-
```bash
40-
cmake --preset release
55+
# Build
4156
cmake --build build/release
57+
# OR
58+
cmake --build build/debug
4259
```
4360

44-
### 2. Run Server
45-
The server listens on port **1316**.
61+
**Run Server:**
4662
```bash
47-
# Debug
4863
./build/debug/server/src/server
49-
50-
# Release
64+
# OR
5165
./build/release/server/src/server
66+
# Note: Server listens on port 1316 by default.
5267
```
5368

54-
### 3. Run Client
55-
The client connects to `127.0.0.1:1316`.
69+
**Run Client:**
5670
```bash
57-
# Debug
5871
./build/debug/client/client
72+
# OR
73+
./build/release/client/client
5974
```
6075

6176
## Testing
62-
Python scripts are used for integration testing. They send raw Protobuf packets over TCP.
63-
64-
**Prerequisites:**
65-
Ensure the server is running.
77+
The project includes Python scripts for functional testing of specific features.
6678

67-
**Run Tests:**
6879
```bash
69-
# Test Authentication (Register/Login)
80+
# Test Authentication
7081
python3 tests/test_auth.py [username] [password]
7182

7283
# Test Friend System
@@ -76,18 +87,14 @@ python3 tests/test_friend.py
7687
python3 tests/test_message.py
7788
```
7889

79-
## Infrastructure
80-
The project relies on Docker for database services.
81-
- **MySQL**: 3306 (User/Auth)
82-
- **Scylla**: 9042 (Messages)
83-
84-
**Start Infrastructure:**
85-
```bash
86-
docker-compose -f .devcontainer/docker-compose.yml up -d
87-
```
88-
(Or use the DevContainer which handles this automatically).
89-
90-
## Development Conventions
91-
- **Code Style**: Google C++ Style (PascalCase for classes/functions, snake_case for variables).
92-
- **Protobuf**: When modifying `.proto` files, re-run CMake to regenerate C++ and Python headers.
93-
- **Database**: Schema changes require database re-initialization or migration.
90+
## Development Status & Roadmap
91+
* **Transitioning to ScyllaDB:** The project is moving from MySQL to ScyllaDB for better scalability.
92+
* **Current Focus:**
93+
* Password Encryption (bcrypt/Argon2)
94+
* P2P Message persistence and delivery guarantees.
95+
* Offline message storage.
96+
* **Completed:** User Auth (JWT), Friend System, Real-time Push, Connection Pool.
97+
98+
## Conventions
99+
* **Code Style:** Google Style (PascalCase for classes/functions, snake_case for variables).
100+
* **Formatting:** `clang-format` used on `.h` and `.cpp` files.

0 commit comments

Comments
 (0)