|
| 1 | +# Sparkly Server |
| 2 | + |
| 3 | +Backend API for **Sparkly**, a build‑in‑public social platform. This repository contains the C# / .NET backend that powers authentication, user accounts and the core application features used by the Sparkly web client. |
| 4 | + |
| 5 | +> Status: early development – API surface and architecture are evolving. |
| 6 | +
|
| 7 | +--- |
| 8 | + |
| 9 | +## Tech stack |
| 10 | + |
| 11 | +* **.NET**: .NET 9 (ASP.NET Core Web API) |
| 12 | +* **Data access**: Entity Framework Core (code‑first migrations) |
| 13 | +* **Database**: PostgreSQL (via Docker) or local dev database |
| 14 | +* **Containerization**: Docker + Docker Compose |
| 15 | +* **Tooling**: `dotnet` CLI, EF Core CLI |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Project structure |
| 20 | + |
| 21 | +High‑level layout of the repository: |
| 22 | + |
| 23 | +```text |
| 24 | +sparkly-server/ |
| 25 | +├─ Migrations/ # EF Core migrations |
| 26 | +├─ src/ # Application source code (API, domain, infrastructure) |
| 27 | +├─ Program.cs # Application bootstrap / entrypoint |
| 28 | +├─ compose.yaml # Docker Compose stack (API + database) |
| 29 | +├─ Dockerfile # Image for the API service |
| 30 | +├─ appsettings.json # Base configuration (non‑secret) |
| 31 | +└─ appsettings.Development.json # Local overrides (DO NOT commit secrets) |
| 32 | +``` |
| 33 | + |
| 34 | +The `src` folder is where the actual application code lives (controllers, domain models, services, etc.). As the project grows, this will be organized into clear layers (e.g. `Api`, `Application`, `Domain`, `Infrastructure`). |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Getting started |
| 39 | + |
| 40 | +### Prerequisites |
| 41 | + |
| 42 | +* .NET 9 SDK installed |
| 43 | +* Docker + Docker Compose installed (for running the full stack) |
| 44 | +* Git |
| 45 | + |
| 46 | +### 1. Clone the repository |
| 47 | + |
| 48 | +```bash |
| 49 | +git clone https://github.com/SculptTechProject/sparkly-server.git |
| 50 | +cd sparkly-server |
| 51 | +``` |
| 52 | + |
| 53 | +### 2. Configure environment |
| 54 | + |
| 55 | +The backend expects configuration from `appsettings.json` and environment variables. **Secrets must never be committed to the repo.** |
| 56 | + |
| 57 | +Create a local environment file (for your own use) or set environment variables via your shell / Docker: |
| 58 | + |
| 59 | +```bash |
| 60 | +# Example – adjust names/values to match the codebase |
| 61 | +export ASPNETCORE_ENVIRONMENT=Development |
| 62 | +export ConnectionStrings__DefaultConnection="Host=localhost;Port=5432;Database=sparkly;Username=sparkly;Password=changeme" |
| 63 | + |
| 64 | +# Example if you add auth / JWT later |
| 65 | +export Jwt__Issuer="https://sparkly.local" |
| 66 | +export Jwt__Audience="sparkly-app" |
| 67 | +export Jwt__Secret="super-long-random-secret-key-change-me" |
| 68 | +``` |
| 69 | + |
| 70 | +Keep a non‑secret example in the repo as `appsettings.Development.example.json` or `.env.example` (recommended), and use it to document required keys. |
| 71 | + |
| 72 | +### 3. Apply database migrations (optional but recommended) |
| 73 | + |
| 74 | +If EF Core migrations are used, apply them before running the API: |
| 75 | + |
| 76 | +```bash |
| 77 | +dotnet restore |
| 78 | + |
| 79 | +dotnet ef database update |
| 80 | +``` |
| 81 | + |
| 82 | +If you use Docker with a database container, you can also let the application apply migrations on startup (depending on how the bootstrapping is implemented). |
| 83 | + |
| 84 | +### 4. Run the API locally |
| 85 | + |
| 86 | +**Option A – `dotnet run`** |
| 87 | + |
| 88 | +```bash |
| 89 | +dotnet restore |
| 90 | + |
| 91 | +dotnet run |
| 92 | +``` |
| 93 | + |
| 94 | +By default the API will listen on the ports defined in `appsettings.json` / `launchSettings` / environment variables (commonly `http://localhost:5000` or `http://localhost:8080`). |
| 95 | + |
| 96 | +**Option B – Docker Compose (API + DB)** |
| 97 | + |
| 98 | +```bash |
| 99 | +docker compose up --build |
| 100 | +``` |
| 101 | + |
| 102 | +This will: |
| 103 | + |
| 104 | +* build the backend image using `Dockerfile`, |
| 105 | +* start the API container, |
| 106 | +* start the database container defined in `compose.yaml`. |
| 107 | + |
| 108 | +Check the logs to confirm that the API is healthy and connected to the database. |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## API surface (high‑level) |
| 113 | + |
| 114 | +This backend is responsible for the core Sparkly features, for example: |
| 115 | + |
| 116 | +* user registration and login, |
| 117 | +* user profile data and settings, |
| 118 | +* Sparkly dashboard / feed backend endpoints, |
| 119 | +* future billing / subscriptions integration (Stripe), |
| 120 | +* admin / internal endpoints for moderation and analytics. |
| 121 | + |
| 122 | +As the project grows, consider documenting endpoints using: |
| 123 | + |
| 124 | +* **OpenAPI / Swagger** (Swashbuckle), |
| 125 | +* or minimal API documentation in `README` (auth endpoints, example requests/responses). |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +## Docker |
| 130 | + |
| 131 | +### Build image manually |
| 132 | + |
| 133 | +```bash |
| 134 | +docker build -t sparkly-server . |
| 135 | +``` |
| 136 | + |
| 137 | +### Run container manually |
| 138 | + |
| 139 | +```bash |
| 140 | +docker run \ |
| 141 | + -e ASPNETCORE_ENVIRONMENT=Development \ |
| 142 | + -e ConnectionStrings__DefaultConnection="Host=db;Port=5432;Database=sparkly;Username=sparkly;Password=changeme" \ |
| 143 | + -p 8080:8080 \ |
| 144 | + sparkly-server |
| 145 | +``` |
| 146 | + |
| 147 | +In practice you will usually prefer `docker compose up` because it brings up the database and the API together. |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## Configuration & secrets |
| 152 | + |
| 153 | +**Important:** |
| 154 | + |
| 155 | +* API keys, JWT secrets, Stripe keys, and real database credentials **must never** live in the Git repository. |
| 156 | +* Use environment variables / secret managers in development and production. |
| 157 | + |
| 158 | +Recommended pattern: |
| 159 | + |
| 160 | +* commit a `.env.example` (or `appsettings.Development.example.json`) with all required keys but without real secrets, |
| 161 | +* document each key in a short comment / table so contributors know what to set. |
| 162 | + |
| 163 | +Example keys you are likely to add as Sparkly evolves: |
| 164 | + |
| 165 | +* `Stripe__SecretKey` |
| 166 | +* `Stripe__WebhookSecret` |
| 167 | +* `Jwt__Secret` |
| 168 | +* `Jwt__Issuer` |
| 169 | +* `Jwt__Audience` |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## Development workflow |
| 174 | + |
| 175 | +Suggested workflow while the project is young: |
| 176 | + |
| 177 | +1. Create a small issue / task (feature, refactor, bugfix). |
| 178 | +2. Work on a feature branch. |
| 179 | +3. Add or update tests (unit/integration) around new behaviour. |
| 180 | +4. Run tests and `dotnet build` locally. |
| 181 | +5. Open a PR (even if you are the only contributor – PR history becomes project documentation). |
| 182 | + |
| 183 | +This keeps the history clean and makes it easier to reason about changes later. |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +## Roadmap ideas |
| 188 | + |
| 189 | +Some directions for the Sparkly backend: |
| 190 | + |
| 191 | +* Authentication & authorization layer (JWT, refresh tokens, roles/permissions). |
| 192 | +* First version of the "build in public" feed (posts, comments, reactions). |
| 193 | +* Real‑time communication (SignalR or WebSockets) for live rooms / chats. |
| 194 | +* Stripe integration for paid plans (billing, webhooks, subscription status synced to users). |
| 195 | +* Observability (logging, metrics, health checks, readiness / liveness probes for Docker / Kubernetes). |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +## Contributing |
| 200 | + |
| 201 | +This project is currently developed by the SculptTech / Sparkly team. External contributions are welcome once the core architecture stabilises. |
| 202 | + |
| 203 | +If you want to propose a change: |
| 204 | + |
| 205 | +* open an issue with a short description and motivation, |
| 206 | +* or open a draft PR with your idea. |
| 207 | + |
| 208 | +--- |
| 209 | + |
| 210 | +## License |
| 211 | + |
| 212 | +License: **TBD** |
| 213 | + |
| 214 | +Until a license is added, treat this repository as source‑available but not licensed for unrestricted commercial reuse. |
0 commit comments