|
1 | | -- # Development Guide |
2 | | -- |
3 | | -- ## Code Organization |
4 | | -- |
5 | | -- ``` |
6 | | -
|
7 | | - ``` |
8 | | -- lib/ |
9 | | -- ├── realtime_server/ # Business logic |
10 | | -- │ ├── accounts/ # User management |
11 | | -- │ ├── comments/ # Comment context |
12 | | -- │ ├── firebase/ # Firebase integration |
13 | | -- │ ├── presence/ # Presence tracking |
14 | | -- │ └── observability/ # Monitoring |
15 | | -- ├── realtime_server_web/ # Web layer |
16 | | -- │ ├── channels/ # WebSocket channels |
17 | | -- │ ├── controllers/ # REST controllers |
18 | | -- │ └── views/ # JSON views |
19 | | -- └── mix.exs # Project configuration |
20 | | -- ``` |
21 | | -
|
22 | | - ``` |
23 | | -- |
24 | | -- ## Development Workflow |
25 | | -- |
26 | | -- ### 1. Setup Development Environment |
27 | | -- |
28 | | -- ```bash |
29 | | - |
30 | | - ``` |
31 | | -- # Clone repository |
32 | | -- git clone https://github.com/your-org/realtime-server.git |
33 | | -- cd realtime-server |
34 | | -- |
35 | | -- # Install dependencies |
36 | | -- mix deps.get |
37 | | -- |
38 | | -- # Setup database |
39 | | -- mix ecto.setup |
40 | | -- ``` |
41 | | -
|
42 | | - ``` |
43 | | -- |
44 | | -- ### 2. Running Tests |
45 | | -- |
46 | | -- ```bash |
47 | | - |
48 | | - ``` |
49 | | -- # Run all tests |
50 | | -- mix test |
51 | | -- |
52 | | -- # Run with coverage |
53 | | -- mix coveralls |
54 | | -- |
55 | | -- # Run specific test file |
56 | | -- mix test test/realtime_server/comments_test.exs |
57 | | -- ``` |
58 | | -
|
59 | | - ``` |
60 | | -- |
61 | | -- ### 3. Code Quality |
62 | | -- |
63 | | -- ```bash |
64 | | - |
65 | | - ``` |
66 | | -- # Format code |
67 | | -- mix format |
68 | | -- |
69 | | -- # Run linter |
70 | | -- mix credo --strict |
71 | | -- |
72 | | -- # Run type checking |
73 | | -- mix dialyzer |
74 | | -- ``` |
75 | | -
|
76 | | - ``` |
77 | | -- |
78 | | -- ## Testing Strategy |
79 | | -- |
80 | | -- ### Unit Tests |
81 | | -- - Controllers |
82 | | -- - Contexts |
83 | | -- - Channels |
84 | | -- - Views |
85 | | -- |
86 | | -- ### Integration Tests |
87 | | -- - API endpoints |
88 | | -- - WebSocket connections |
89 | | -- - Database operations |
90 | | -- |
91 | | -- ### Performance Tests |
92 | | -- - Load testing |
93 | | -- - Stress testing |
94 | | -- - Connection limits |
95 | | -- |
96 | | -- ## Git Workflow |
97 | | -- |
98 | | -- ### Branch Naming |
99 | | -- - `feature/` - New features |
100 | | -- - `fix/` - Bug fixes |
101 | | -- - `docs/` - Documentation |
102 | | -- - `refactor/` - Code refactoring |
103 | | -- |
104 | | -- ### Commit Messages |
105 | | -- ``` |
106 | | -
|
107 | | - ``` |
| 1 | +# Development Guide |
| 2 | + |
| 3 | +## Code Organization |
| 4 | + |
| 5 | +``` |
| 6 | +lib/ |
| 7 | +├── realtime_server/ # Business logic |
| 8 | +│ ├── accounts/ # User management |
| 9 | +│ ├── comments/ # Comment context |
| 10 | +│ ├── firebase/ # Firebase integration |
| 11 | +│ ├── presence/ # Presence tracking |
| 12 | +│ └── observability/ # Monitoring |
| 13 | +├── realtime_server_web/ # Web layer |
| 14 | +│ ├── channels/ # WebSocket channels |
| 15 | +│ ├── controllers/ # REST controllers |
| 16 | +│ └── views/ # JSON views |
| 17 | +└── mix.exs # Project configuration |
| 18 | +``` |
| 19 | + |
| 20 | +## Development Workflow |
| 21 | + |
| 22 | +### 1. Setup Development Environment |
| 23 | + |
| 24 | +```bash |
| 25 | +# Clone repository |
| 26 | +git clone https://github.com/your-org/realtime-server.git |
| 27 | +cd realtime-server |
| 28 | + |
| 29 | +# Install dependencies |
| 30 | +mix deps.get |
| 31 | + |
| 32 | +# Setup database |
| 33 | +mix ecto.setup |
| 34 | +``` |
| 35 | + |
| 36 | +### 2. Running Tests |
| 37 | + |
| 38 | +```bash |
| 39 | +# Run all tests |
| 40 | +mix test |
| 41 | + |
| 42 | +# Run with coverage |
| 43 | +mix coveralls |
| 44 | + |
| 45 | +# Run specific test file |
| 46 | +mix test test/realtime_server/comments_test.exs |
| 47 | +``` |
| 48 | + |
| 49 | +### 3. Code Quality |
| 50 | + |
| 51 | +```bash |
| 52 | +# Format code |
| 53 | +mix format |
| 54 | + |
| 55 | +# Run linter |
| 56 | +mix credo --strict |
| 57 | + |
| 58 | +# Run type checking |
| 59 | +mix dialyzer |
| 60 | +``` |
| 61 | + |
| 62 | +## Testing Strategy |
| 63 | + |
| 64 | +### Unit Tests |
| 65 | + |
| 66 | +- Controllers |
| 67 | +- Contexts |
| 68 | +- Channels |
| 69 | +- Views |
| 70 | + |
| 71 | +### Integration Tests |
| 72 | + |
| 73 | +- API endpoints |
| 74 | +- WebSocket connections |
| 75 | +- Database operations |
| 76 | + |
| 77 | +### Performance Tests |
| 78 | + |
| 79 | +- Load testing |
| 80 | +- Stress testing |
| 81 | +- Connection limits |
| 82 | + |
| 83 | +## Git Workflow |
| 84 | + |
| 85 | +### Branch Naming |
| 86 | + |
| 87 | +- `feature/` - New features |
| 88 | +- `fix/` - Bug fixes |
| 89 | +- `docs/` - Documentation |
| 90 | +- `refactor/` - Code refactoring |
| 91 | + |
| 92 | +### Commit Messages |
| 93 | + |
| 94 | +``` |
108 | 95 | - feat: add user presence tracking |
109 | 96 | - fix: handle disconnection edge case |
110 | 97 | - docs: update API documentation |
111 | 98 | - refactor: improve error handling |
112 | | -- ``` |
113 | | -
|
114 | | - ``` |
115 | | -- |
116 | | -- ## Debugging |
117 | | -- |
118 | | -- ### Logging |
119 | | -- ```elixir |
120 | | - |
121 | | - ``` |
122 | | -- Logger.debug("Debug message", user_id: user.id) |
123 | | -- Logger.info("Info message", %{event: "user_login"}) |
124 | | -- Logger.warning("Warning message", %{error: error}) |
125 | | -- ``` |
126 | | -
|
127 | | - ``` |
128 | | -- |
129 | | -- ### IEx Session |
130 | | -- ```bash |
131 | | - |
132 | | - ``` |
133 | | -- iex -S mix phx.server |
134 | | -- ``` |
135 | | -
|
136 | | - ``` |
137 | | -- |
138 | | -- ### Observer |
139 | | -- ```bash |
140 | | - |
141 | | - ``` |
142 | | -- :observer.start() |
143 | | -- ``` |
144 | | -
|
145 | | - ``` |
| 99 | +``` |
| 100 | + |
| 101 | +## Debugging |
| 102 | + |
| 103 | +### Logging |
| 104 | + |
| 105 | +```elixir |
| 106 | +Logger.debug("Debug message", user_id: user.id) |
| 107 | +Logger.info("Info message", %{event: "user_login"}) |
| 108 | +Logger.warning("Warning message", %{error: error}) |
| 109 | +``` |
| 110 | + |
| 111 | +### IEx Session |
| 112 | + |
| 113 | +```bash |
| 114 | +iex -S mix phx.server |
| 115 | +``` |
| 116 | + |
| 117 | +### Observer |
| 118 | + |
| 119 | +```bash |
| 120 | +:observer.start() |
| 121 | +``` |
0 commit comments