Skip to content

Commit e4f4d94

Browse files
Add complete setup guide for CIVWATCH application
Added a complete setup guide for the CIVWATCH application, detailing architecture, prerequisites, quick start instructions, local development setup, repository structure, environment configuration, common tasks, troubleshooting, production deployment, additional resources, and support information.
1 parent e4ff7b8 commit e4f4d94

File tree

1 file changed

+332
-0
lines changed

1 file changed

+332
-0
lines changed

SETUP.md

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,333 @@
1+
# CIVWATCH - Complete Setup Guide
12

3+
## Overview
4+
CIVWATCH is a three-tier microservices web application for civic transparency and government oversight.
5+
6+
**Architecture:**
7+
- **Backend** (Node.js/Express): REST API on port 3000
8+
- **Frontend** (React/TypeScript): UI on port 4000
9+
- **ML Service** (Python/FastAPI): ML/NLP on port 5000
10+
11+
---
12+
13+
## Prerequisites
14+
15+
### Required Software
16+
1. **Docker & Docker Compose**
17+
- Docker Engine 20.10+
18+
- Docker Compose 2.0+
19+
- [Installation Guide](https://docs.docker.com/get-docker/)
20+
21+
2. **Node.js** (for local development)
22+
- Version: 18.x or 20.x LTS
23+
- npm 9.x+
24+
- [Download](https://nodejs.org/)
25+
26+
3. **Python** (for ML service)
27+
- Version: 3.9+
28+
- pip 21.x+
29+
30+
4. **Git**
31+
- Version 2.30+
32+
33+
---
34+
35+
## Quick Start (Docker)
36+
37+
The fastest way to run CIVWATCH:
38+
39+
```bash
40+
# Clone the repository
41+
git clone https://github.com/POWDER-RANGER/CIVWATCH.git
42+
cd CIVWATCH
43+
44+
# Start all services with Docker Compose
45+
docker-compose up
46+
```
47+
48+
**Services will be available at:**
49+
- Backend API: http://localhost:3000
50+
- Backend Health: http://localhost:3000/api/health
51+
- Frontend UI: http://localhost:4000
52+
- ML Service: http://localhost:5000
53+
- ML Health: http://localhost:5000/health
54+
55+
**To stop services:**
56+
```bash
57+
docker-compose down
58+
```
59+
60+
---
61+
62+
## Local Development Setup
63+
64+
For active development without Docker:
65+
66+
### 1. Backend Setup
67+
68+
```bash
69+
cd backend
70+
71+
# Install dependencies
72+
npm install
73+
74+
# Run development server
75+
npm run dev
76+
77+
# Run tests
78+
npm test
79+
```
80+
81+
**Backend runs on:** http://localhost:3000
82+
83+
### 2. Frontend Setup
84+
85+
```bash
86+
cd frontend
87+
88+
# Install dependencies
89+
npm install
90+
91+
# Run development server
92+
npm start
93+
94+
# Build for production
95+
npm run build
96+
97+
# Run tests
98+
npm test
99+
```
100+
101+
**Frontend runs on:** http://localhost:4000
102+
103+
### 3. ML Service Setup
104+
105+
```bash
106+
cd ml
107+
108+
# Create virtual environment (recommended)
109+
python -m venv venv
110+
source venv/bin/activate # On Windows: venv\Scripts\activate
111+
112+
# Install dependencies
113+
pip install -r ../requirements.txt
114+
115+
# Run development server
116+
python main.py
117+
118+
# Run tests
119+
pytest
120+
```
121+
122+
**ML Service runs on:** http://localhost:5000
123+
124+
---
125+
126+
## Repository Structure
127+
128+
```
129+
CIVWATCH/
130+
├── backend/ # Node.js/Express backend
131+
│ ├── src/
132+
│ │ ├── services/ # Business logic
133+
│ │ ├── server.ts # Express server
134+
│ │ └── types.ts # TypeScript types
135+
│ ├── index.js # Entry point
136+
│ ├── package.json # Dependencies
137+
│ └── Dockerfile.dev # Docker config
138+
139+
├── frontend/ # React/TypeScript frontend
140+
│ ├── src/
141+
│ │ ├── components/ # React components
142+
│ │ └── main.tsx # Entry point
143+
│ ├── package.json # Dependencies
144+
│ └── Dockerfile.dev # Docker config
145+
146+
├── ml/ # Python ML service
147+
│ ├── src/
148+
│ │ └── models/ # ML models
149+
│ ├── main.py # FastAPI server
150+
│ ├── package.json # Metadata
151+
│ └── Dockerfile.dev # Docker config
152+
153+
├── docs/ # Documentation
154+
│ ├── architecture.md # System design
155+
│ ├── api.md # API specs
156+
│ └── testing.md # QA strategy
157+
158+
├── docker-compose.yml # Multi-service orchestration
159+
├── requirements.txt # Python dependencies
160+
├── package.json # Root workspace config
161+
├── tsconfig.json # TypeScript config
162+
└── README.md # Project overview
163+
```
164+
165+
---
166+
167+
## Environment Configuration
168+
169+
### Backend Environment Variables
170+
Create `backend/.env`:
171+
172+
```env
173+
PORT=3000
174+
NODE_ENV=development
175+
DATABASE_URL=postgresql://user:pass@localhost:5432/civwatch
176+
REDIS_URL=redis://localhost:6379
177+
JWT_SECRET=your-secret-key-here
178+
JWT_EXPIRY=1h
179+
REFRESH_TOKEN_EXPIRY=7d
180+
```
181+
182+
### Frontend Environment Variables
183+
Create `frontend/.env`:
184+
185+
```env
186+
VITE_API_URL=http://localhost:3000
187+
VITE_ML_URL=http://localhost:5000
188+
```
189+
190+
### ML Service Environment Variables
191+
Create `ml/.env`:
192+
193+
```env
194+
PORT=5000
195+
MODEL_PATH=./models
196+
```
197+
198+
---
199+
200+
## Common Tasks
201+
202+
### Build All Services
203+
```bash
204+
docker-compose build
205+
```
206+
207+
### View Service Logs
208+
```bash
209+
docker-compose logs -f backend
210+
docker-compose logs -f frontend
211+
docker-compose logs -f ml
212+
```
213+
214+
### Restart a Single Service
215+
```bash
216+
docker-compose restart backend
217+
```
218+
219+
### Run Tests
220+
```bash
221+
# Backend tests
222+
cd backend && npm test
223+
224+
# Frontend tests
225+
cd frontend && npm test
226+
227+
# ML tests
228+
cd ml && pytest
229+
```
230+
231+
### Code Linting
232+
```bash
233+
# Backend/Frontend
234+
npm run lint
235+
236+
# Python
237+
flake8 ml/
238+
```
239+
240+
---
241+
242+
## Troubleshooting
243+
244+
### Port Already in Use
245+
If ports 3000, 4000, or 5000 are occupied:
246+
247+
```bash
248+
# Check port usage
249+
lsof -i :3000
250+
lsof -i :4000
251+
lsof -i :5000
252+
253+
# Kill process
254+
kill -9 <PID>
255+
```
256+
257+
### Docker Issues
258+
```bash
259+
# Clean Docker cache
260+
docker-compose down -v
261+
docker system prune -a
262+
263+
# Rebuild from scratch
264+
docker-compose build --no-cache
265+
```
266+
267+
### Dependencies Not Installing
268+
```bash
269+
# Clear npm cache
270+
npm cache clean --force
271+
272+
# Clear pip cache
273+
pip cache purge
274+
275+
# Reinstall
276+
rm -rf node_modules package-lock.json
277+
npm install
278+
```
279+
280+
### Health Check Failures
281+
Wait 40 seconds after starting services for health checks to stabilize.
282+
283+
```bash
284+
# Test health endpoints manually
285+
curl http://localhost:3000/api/health
286+
curl http://localhost:5000/health
287+
```
288+
289+
---
290+
291+
## Production Deployment
292+
293+
### Build Production Images
294+
```bash
295+
docker-compose -f docker-compose.prod.yml build
296+
```
297+
298+
### Environment Setup
299+
1. Set secure `JWT_SECRET` values
300+
2. Configure production databases (PostgreSQL)
301+
3. Set up Redis for caching
302+
4. Enable HTTPS/TLS
303+
5. Configure CORS origins
304+
305+
### Security Checklist
306+
- [ ] Change all default credentials
307+
- [ ] Enable rate limiting (100 req/min)
308+
- [ ] Configure TLS 1.3
309+
- [ ] Whitelist CORS origins
310+
- [ ] Set bcrypt cost factor (12)
311+
- [ ] Enable security headers
312+
- [ ] Configure firewall rules
313+
314+
---
315+
316+
## Additional Resources
317+
318+
- [Architecture Documentation](docs/architecture.md)
319+
- [API Reference](docs/api.md)
320+
- [Testing Strategy](docs/testing.md)
321+
- [Contributing Guidelines](CONTRIBUTING.md)
322+
- [Code of Conduct](CODE_OF_CONDUCT.md)
323+
- [Security Policy](SECURITY.md)
324+
325+
---
326+
327+
## Support
328+
329+
**Issues:** [GitHub Issues](https://github.com/POWDER-RANGER/CIVWATCH/issues)
330+
331+
**Development Status:** Early-stage MVP (Q1 2026 target)
332+
333+
**License:** MIT

0 commit comments

Comments
 (0)